Skip to content

Commit

Permalink
payments: probably-too-clever hack: use a non-safechar to delimit the…
Browse files Browse the repository at this point in the history
… structured creditor reference from the bankref; this should allow existing transaction-matching logic to function as-is
  • Loading branch information
jayaddison committed Dec 18, 2023
1 parent a35cbd6 commit 5d30c7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def customer_reference(self):

# Derive an ISO-11649 payment reference for EUR-currency payments
if self.currency == "EUR":
order_check_digits = mod_97_10.calc_check_digits(f"{self.bankref}RF")
customer_reference = f"RF{order_check_digits}{self.bankref}"
order_check_digits = mod_97_10.calc_check_digits(f"E{self.bankref}RF")
customer_reference = f"RF{order_check_digits}E{self.bankref}"
assert iso11649.validate(customer_reference)
return customer_reference
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_format_inline_epc_qr(app):

# Ensure that the structured creditor reference is valid and contains the bankref
assert iso11649.is_valid(payment.customer_reference)
assert re.match(f"^RF[0-9][0-9]{payment.bankref}$", payment.customer_reference)
assert re.match(f"^RF[0-9][0-9]E{payment.bankref}$", payment.customer_reference)

qr_inline = format_inline_epc_qr(payment)
qr_image = render_svg(qr_inline)
Expand Down

0 comments on commit 5d30c7e

Please sign in to comment.