From 7071f583aa877dad1677f6a878afd6b832f1e6fe 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) # Conflicts: # erpnext/accounts/doctype/sales_invoice/sales_invoice.py --- .../doctype/sales_invoice/sales_invoice.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7f1f47a74c1..6f6c43d1fec 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -2541,10 +2541,26 @@ def create_dunning(source_name, target_doc=None): target.dunning_amount = amounts.get("dunning_amount") target.grand_total = amounts.get("grand_total") +<<<<<<< HEAD doclist = get_mapped_doc( "Sales Invoice", source_name, { +======= + # update outstanding from doc + if source.payment_schedule and len(source.payment_schedule) == 1: + for row in target.overdue_payments: + if row.payment_schedule == source.payment_schedule[0].name: + row.outstanding = source.get("outstanding_amount") + + target.validate() + + return get_mapped_doc( + from_doctype="Sales Invoice", + from_docname=source_name, + target_doc=target_doc, + table_maps={ +>>>>>>> c2bdd30e6d (fix: correct outstanding amount for invoice in dunning) "Sales Invoice": { "doctype": "Dunning", }