From 1ca20b97d066d3758fe85dd0bc6b9cc65d449bb3 Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Fri, 27 May 2022 20:08:04 -0400 Subject: [PATCH] fix: payment entry get outstanding documents for advance payments --- .../doctype/payment_entry/payment_entry.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 54a1ebd26316..c32dfbd7aec2 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1406,7 +1406,7 @@ def get_orders_to_be_billed( if voucher_type: doc = frappe.get_doc({"doctype": voucher_type}) condition = "" - if doc and hasattr(doc, "cost_center"): + if doc and hasattr(doc, "cost_center") and doc.cost_center is not None: condition = " and cost_center='%s'" % cost_center orders = [] @@ -1452,9 +1452,15 @@ def get_orders_to_be_billed( order_list = [] for d in orders: - if not ( - flt(d.outstanding_amount) >= flt(filters.get("outstanding_amt_greater_than")) - and flt(d.outstanding_amount) <= flt(filters.get("outstanding_amt_less_than")) + if ( + filters + and filters.get("outstanding_amt_greater_than") + and filters.get("outstanding_amt_less_than") + and not ( + flt(filters.get("outstanding_amt_greater_than")) + <= flt(d.outstanding_amount) + <= flt(filters.get("outstanding_amt_less_than")) + ) ): continue