From d81d6069fb8688223fd5e777c781347990100aa7 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 22 Jun 2023 18:28:16 +0530 Subject: [PATCH] fix: JV query --- erpnext/accounts/utils.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index d9561ad468..f92e2c7cba 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -502,24 +502,19 @@ def check_if_advance_entry_modified(args): frappe.qb.from_(journal_entry) .inner_join(journal_acc) .on(journal_entry.name == journal_acc.parent) - ) - - if args.get("dr_or_cr") == "debit_in_account_currency": - q = q.select(journal_acc.debit_in_account_currency) - else: - q = q.select(journal_acc.credit_in_account_currency) - - q = q.where( - (journal_acc.account == args.get("account")) - & ((journal_acc.party_type == args.get("party_type"))) - & ((journal_acc.party == args.get("party"))) - & ( - (journal_acc.reference_type == None) - | (journal_acc.reference_type.isin(["", "Sales Order", "Purchase Order"])) + .select(journal_acc[args.get("dr_or_cr")]) + .where( + (journal_acc.account == args.get("account")) + & ((journal_acc.party_type == args.get("party_type"))) + & ((journal_acc.party == args.get("party"))) + & ( + (journal_acc.reference_type.isnull()) + | (journal_acc.reference_type.isin(["", "Sales Order", "Purchase Order"])) + ) + & ((journal_entry.name == args.get("voucher_no"))) + & ((journal_acc.name == args.get("voucher_detail_no"))) + & ((journal_entry.docstatus == 1)) ) - & ((journal_entry.name == args.get("voucher_no"))) - & ((journal_acc.name == args.get("voucher_detail_no"))) - & ((journal_entry.docstatus == 1)) ) else: