The transaction matching in the bank reconciliation is flawed. The code expects the ledger transaction amount to always be less than or equal to the bank transaction.
This is fine in scenarios for example where a customer has several sales invoices and pays them all at once.
But consider the scenario the customer has one invoice and pays it in multiple instalments, which is what the Payment Terms Template is designed to allow.
My actual scenario is multiple bank transactions reconciling against a single Journal Entry (Payroll). But there are a lot of scenarios in bank transactions that the current reconciliation code does not cater for, e.g. typos.
You could argue the above Sales Invoice scenario is covered by making a Payment Entry for the invoice. I would argue the Bank Transaction/Reconciliation code should be able to cater for all scenarios without a Payment Entry being required, since the Bank Transaction has a child Bank Transaction Payments table specifically designed for this. And Payment Entries are only applicable to Invoices (so not Journal Entries).
Reading between the lines I think the intention is to deprecate the Payment Entry doctype since there appears to be nothing that couldn’t be done with a Journal Entry anyway.
I suggest extending the transaction ranking idea in the reconciliation, and removing the SQL transaction where clause
for the amount:
Changes also required in reconcile_vouchers
and preferably code moved to bank_transaction.py
:
if total_amount > transaction.unallocated_amount:
frappe.throw(_("The sum total of amounts of all selected vouchers should be less than the unallocated amount of the bank transaction"))