diff --git a/wizard/ebics_statement_rop_import_wizard.py b/wizard/ebics_statement_rop_import_wizard.py index 15b7800c1597a49e94648f11ee717cf7d92321e4..27b531e15eba31931248f68217e9f9282614c71d 100644 --- a/wizard/ebics_statement_rop_import_wizard.py +++ b/wizard/ebics_statement_rop_import_wizard.py @@ -178,18 +178,24 @@ class EbicsStatementRopImport(models.TransientModel): rop_lines = [] content = base64.b64decode(data).decode("utf-8").split("\n") for line in content: - if line[0:2] in ("11", "12", "21", "22"): - sens = 87 if line[0:2] in ("11", "21") else 86 - amount = int(line[75:87]) / 100 - rop_lines.append( - { - "date": datetime.strptime(line[177:185], "%Y%m%d").date(), - "payment_ref": line[29:61].rstrip() - + " - " - + line[138:158].rstrip() - + " - " - + line[104:128].rstrip(), - "amount": amount if line[sens] == "C" else -amount, - } - ) + if line[0:2] in ("11", "21"): + multiplier = 1 if line[87] == "C" else -1 + amount = int(line[75:87]) * multiplier / 100 + elif line[0:2] in ("12", "22"): + multiplier = 1 if line[86] == "C" else -1 + amount = int(line[75:86]) * multiplier / 100 + else: + continue + + rop_lines.append( + { + "date": datetime.strptime(line[177:185], "%Y%m%d").date(), + "payment_ref": line[29:61].rstrip() + + " - " + + line[138:158].rstrip() + + " - " + + line[104:128].rstrip(), + "amount": amount, + } + ) return rop_lines