From b7c3fa23d278ca328072e43dd2e9834754b028df Mon Sep 17 00:00:00 2001 From: ljain112 Date: Fri, 28 Mar 2025 13:26:28 +0530 Subject: [PATCH] fix: correct outstanding amount for invoice in dunning (cherry picked from commit c2bdd30e6de215c79f40bf20d95a797a711f7080) --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a57e313e2e9..7761dc832de 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -2720,9 +2720,11 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False): target.closing_text = letter_text.get("closing_text") target.language = letter_text.get("language") - # update outstanding + # update outstanding from doc if source.payment_schedule and len(source.payment_schedule) == 1: - target.overdue_payments[0].outstanding = source.get("outstanding_amount") + for row in target.overdue_payments: + if row.payment_schedule == source.payment_schedule[0].name: + row.outstanding = source.get("outstanding_amount") target.validate()