From 47071cec5df815534e72ef4730349d8cd8d0d749 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 20 May 2024 16:00:39 +0530 Subject: [PATCH] refactor: for advances uses the party account in references table (cherry picked from commit 7dce6e03c7f8452fa9ca942b38a0cf1bd2264d3e) --- erpnext/controllers/accounts_controller.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 40ce8b6bc57..f576ecc1b11 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1430,10 +1430,13 @@ class AccountsController(TransactionBase): if d.exchange_gain_loss and ( (d.reference_doctype, d.reference_name, str(d.idx)) not in booked ): - if self.payment_type == "Receive": - party_account = self.paid_from - elif self.payment_type == "Pay": - party_account = self.paid_to + if self.book_advance_payments_in_separate_party_account: + party_account = d.account + else: + if self.payment_type == "Receive": + party_account = self.paid_from + elif self.payment_type == "Pay": + party_account = self.paid_to dr_or_cr = "debit" if d.exchange_gain_loss > 0 else "credit"