From 17ff395f9a230a8ffbb3c821fb5c357d9261daba Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 20 Jul 2023 20:54:43 +0530 Subject: [PATCH] fix: Reverse GL entries only for submitted Dunnings --- erpnext/patches/v14_0/single_to_multi_dunning.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v14_0/single_to_multi_dunning.py b/erpnext/patches/v14_0/single_to_multi_dunning.py index 3567522eb3c..3b01871d437 100644 --- a/erpnext/patches/v14_0/single_to_multi_dunning.py +++ b/erpnext/patches/v14_0/single_to_multi_dunning.py @@ -7,6 +7,7 @@ def execute(): frappe.reload_doc("accounts", "doctype", "overdue_payment") frappe.reload_doc("accounts", "doctype", "dunning") + # Migrate schema of all uncancelled dunnings filters = {"docstatus": ("!=", 2)} can_edit_accounts_after = get_accounts_closing_date() @@ -49,7 +50,8 @@ def execute(): dunning.flags.ignore_validate_update_after_submit = True dunning.save() - if dunning.status != "Resolved": + # Reverse entries only if dunning is submitted and not resolved + if dunning.docstatus == 1 and dunning.status != "Resolved": # With the new logic, dunning amount gets recorded as additional income # at time of payment. We don't want to record the dunning amount twice, # so we reverse previous GL Entries that recorded the dunning amount at