From 50a74ee7fe95f1b58bdf8ef935eae5ba0bc04ffc Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 16 Apr 2024 08:53:29 +0530 Subject: [PATCH] fix: incorrect exc gain/loss for PE against JE for payable accounts (cherry picked from commit 81b574053ffc15c4337fbe497c53d8696d26f878) # Conflicts: # erpnext/controllers/accounts_controller.py --- erpnext/controllers/accounts_controller.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index dd4a247e0a1..29ac86cb941 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1293,7 +1293,8 @@ class AccountsController(TransactionBase): dr_or_cr = "debit" if d.exchange_gain_loss > 0 else "credit" - if d.reference_doctype == "Purchase Invoice": + # Inverse debit/credit for payable accounts + if self.is_payable_account(d.reference_doctype, party_account): dr_or_cr = "debit" if dr_or_cr == "credit" else "credit" reverse_dr_or_cr = "debit" if dr_or_cr == "credit" else "credit" @@ -1327,6 +1328,7 @@ class AccountsController(TransactionBase): ) ) +<<<<<<< HEAD def make_precision_loss_gl_entry(self, gl_entries): round_off_account, round_off_cost_center = get_round_off_account_and_cost_center( self.company, "Purchase Invoice", self.name, self.use_company_roundoff_cost_center @@ -1353,6 +1355,15 @@ class AccountsController(TransactionBase): } ) ) +======= + def is_payable_account(self, reference_doctype, account): + if reference_doctype == "Purchase Invoice" or ( + reference_doctype == "Journal Entry" + and frappe.get_cached_value("Account", account, "account_type") == "Payable" + ): + return True + return False +>>>>>>> 81b574053f (fix: incorrect exc gain/loss for PE against JE for payable accounts) def update_against_document_in_jv(self): """