Payment entry shows stale outstanding when invoice settled via journal entry or reconciliation

I’ve hit a data mismatch that I can reproduce reliably, and I’d like to confirm whether it’s expected behaviour before opening a GitHub issue.

if an invoice uses a Payment Terms Template with allocate payment based on payment terms enabled, and that invoice is settled by anything other than a payment entry that directly references it, the invoice’s payment schedule table never updates. Payment Entry then reads its outstanding figure from that stale table instead of from the actual ledger, and shows a number that’s too high.

Setup:

  • Payment Terms Template named “Net 30” - a single term(30days), 100%, with Allocate Payment Based On Payment Terms ticked
  • Create and submit a Sales Invoice for a customer, grand total 10,000, with that template applied

Case A: Journal Entry carrying the invoice reference

  • Journal Entry: Debit Cash 2,000, Credit Debtors 2,000 with the customer as Party. On the Debtors row, set Reference Type = Sales Invoice and Reference Name = the invoice. Submit.

Case B: on-account Journal Entry, reconciled afterwards

  • Journal Entry: Debit Cash 2,000, Credit Debtors 2,000 with the customer as Party, no reference. Submit.
  • Payment Reconciliation → select the customer → Get Unreconciled Entries → allocate 2,000 to the invoice → Reconcile

Case C: Payment Entry, reconciled afterwards

  • Payment Entry: Receive 2,000 from the customer, no references filled in. Submit.
  • Payment Reconciliation → allocate 2,000 to the invoice → Reconcile

I include Case C to show this isn’t about Journal Entries specifically. Any settlement routed through Payment Reconciliation behaves the same way, even a plain Payment Entry.

What you see:

All three cases give an identical result.

Open the Sales Invoice. Outstanding Amount reads 8,000(correct). Scroll to the Payment Schedule table in the Payment Terms section: Outstanding still reads 10,000 and Paid Amount is 0. Those two figures on the same document now disagree.

Now create a new Payment Entry for the customer and click Get Outstanding Invoices. It pulls the invoice showing 10,000 outstanding, not 8,000.

Expected:

The Payment Schedule outstanding should total the invoice’s outstanding amount. It’s meant to break that figure into instalments, so the two should never diverge.

As a stopgap I’ve turned off allocate payment based on payment terms, so new invoices aren’t affected. But I already have a few invoices carrying wrong Payment Schedule values from before that change, and I’m unsure how to handle them. I’d rather not edit those rows directly if there’s a supported way to correct them, I couldn’t find one, as reposting the ledgers doesn’t touch the Payment Schedule table. So: if this turns out to be a bug and a fix is released, would that fix be expected to repair existing records, or should I assume it only prevents new ones and correct the old data myself?

Note: Accounts are fine: General Ledger, Accounts Receivable, trial balance and customer ledgers are all correct throughout. It’s the Payment Schedule table alone that goes stale, and Payment Entry trusting it over the ledger is what surfaces the problem.


I am on version 16 erpnext(erpnext: 16.25.0)

Hi @mihir-kandoi . Adding you for visibility.