From c9daa85985e998f96a885100b7763c7ea7a5b49f Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 25 Jul 2023 16:50:46 +0530 Subject: [PATCH 1/3] fix: cost center filter for fetching payments --- erpnext/controllers/accounts_controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index b70ea36dcde..11358a482ba 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2223,15 +2223,15 @@ def get_advance_payment_entries( 'Payment Entry' as reference_type, t1.name as reference_name, t1.remarks, t2.allocated_amount as amount, t2.name as reference_row, t2.reference_name as against_order, t1.posting_date, - t1.{0} as currency, t1.{4} as exchange_rate + t1.{0} as currency, t1.{5} as exchange_rate from `tabPayment Entry` t1, `tabPayment Entry Reference` t2 where t1.name = t2.parent and t1.{1} = %s and t1.payment_type = %s and t1.party_type = %s and t1.party = %s and t1.docstatus = 1 - and t2.reference_doctype = %s {2} - order by t1.posting_date {3} + and t2.reference_doctype = %s {2} {3} + order by t1.posting_date {4} """.format( - currency_field, party_account_field, reference_condition, limit_cond, exchange_rate_field + currency_field, party_account_field, reference_condition, condition, limit_cond, exchange_rate_field ), [party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1, From c3b21a6c30dfcc3a6f6fd52479333b294b900e76 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 25 Jul 2023 17:04:03 +0530 Subject: [PATCH 2/3] chore: linting issues --- erpnext/controllers/accounts_controller.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 11358a482ba..7fec6310207 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2231,7 +2231,12 @@ def get_advance_payment_entries( and t2.reference_doctype = %s {2} {3} order by t1.posting_date {4} """.format( - currency_field, party_account_field, reference_condition, condition, limit_cond, exchange_rate_field + currency_field, + party_account_field, + reference_condition, + condition, + limit_cond, + exchange_rate_field ), [party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1, From 479cab0336cd024477367bd8f7e535ce638f7251 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 26 Jul 2023 09:56:48 +0530 Subject: [PATCH 3/3] fix: test with None conditon in PE --- erpnext/controllers/accounts_controller.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7fec6310207..f4b6e01cc4b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2217,6 +2217,9 @@ def get_advance_payment_entries( reference_condition = "" order_list = [] + if not condition: + condition = "" + payment_entries_against_order = frappe.db.sql( """ select @@ -2231,12 +2234,12 @@ def get_advance_payment_entries( and t2.reference_doctype = %s {2} {3} order by t1.posting_date {4} """.format( - currency_field, - party_account_field, - reference_condition, - condition, - limit_cond, - exchange_rate_field + currency_field, + party_account_field, + reference_condition, + condition, + limit_cond, + exchange_rate_field, ), [party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1,