Fragile invoice matching
Currently we expect only one number to be present in the payment description when matching payments to invoices . If there are two, only the first one is matched and considered to be invoice number, which subsequently used for matching.
I find this assumption wrong and error-prone. This involves additional debugging in trying to find out why invoice has not been matched and fixing production data (marking invoice as paid manually).
irb(main):001:0> bank_transaction = BankTransaction.first
=> #<BankTransaction id: 980190962, description: "RKID:123456789 FOOBAR INC SA invoice no. 1234">
irb(main):003:0> bank_transaction.invoice_num
=> 123456789
Related: https://github.com/internetee/registry/issues/1224
to be exact we expect invoice nr being the first numeric value in description field and this is communicated as requirement to registrars as well. Unfortunately people forget. There are no other limitations on the description content nor number of numerical values in it. But we have planned to change the current invoice matching logic (#1415 ) so that this specific problem here is resolved as well.
Unfortunately people forget
Exactly. And I think this is just a fact that should be taken into account. I believe it's naive to keep fingers crossed that everybody will follow this pattern.
#1224 doesn't seem to above mentioned problem, since it's still possible to put no reference number and description with random numbers. We need to rethink description parsing algorithm anyway.
#1415 removes the invoice number from the equation altogether we will only search for reference nr on refnr field or if this is missing from description field and then use transferred amount to find match among open invoices for that registrar. Yes this requires changing parsing algorithm.
#1224 states:
where only one of the above mentioned properties is provided.
It says nothing that only payment reference number will be checked for a match. The logic you described in your previous comment differs from what is described in #1224.
now I understand what you meant. I actually had this ticket in mind: https://github.com/internetee/registry/issues/1415