Reconcile always takes the newest invoice

I have the following situation:

  1. On day 1, customer X buys some products. I send an invoice A with total amount Y and a payment term of 60 days.
  2. On day 30, customer X comes back and buys the same products again, so I send an invoice B with total amount Y and a payment term of 60 days.
  3. On day 40, customer X pays invoice A
  4. I export the bank statement and import it into Tryton
  5. I start the reconcile wizard to reconcile the invoice

The (nasty) problem is that the wizard takes invoice B to be reconciled. This means that the customer 70 days later is asked to pay invoice A, which he already did. And because the amounts of the invoices are the same it is overlooked easily.

Is this something which can be enhanced in the code with a date sorting?

I guess the combination lines could be ordered by maturity date (or move date when empty) this will increase the chance to stop on a combination having the lower maturity date: Issue 10291: Order reconcile line per maturity date - Tryton issue tracker

But usually if the statement contain information about which invoice it is paying, it is usually good to fill the invoice on the statement line.

Thanks for looking into this!

Completely agree, but that’s not the case and this issue pops up after years of everything working perfectly. So the users are not used to add the invoice.

There is room for improvement here also, for example when using rules if we only have the party information the invoice is not filed and the user needs to select it manually and most of the time forgets it.