From 54acaa2aec5efaf0a921e35a65b4d7b661ba1e81 Mon Sep 17 00:00:00 2001 From: diptanilsaha Date: Thu, 22 Jan 2026 01:43:46 +0530 Subject: [PATCH] fix(payment_reconciliation): retain journal entry accounts child table order --- erpnext/accounts/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 4e0079abf02..c769b54648e 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -663,6 +663,7 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): d["allocated_amount"] = d["allocated_amount"] * -1 d["unadjusted_amount"] = d["unadjusted_amount"] * -1 + insert_position = -1 if flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) != 0: # adjust the unreconciled balance amount_in_account_currency = flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) @@ -674,9 +675,10 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): ) else: journal_entry.remove(jv_detail) + insert_position += jv_detail.idx # new row with references - new_row = journal_entry.append("accounts") + new_row = journal_entry.append("accounts", position=insert_position) # Copy field values into new row [