From f9eff57531f67b955b6de93425caaa61446fdb29 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jan 2016 15:59:14 +0530 Subject: [PATCH] [fix] credit limit --- erpnext/selling/doctype/customer/customer.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 72ec1dce17..8a7da63853 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -229,9 +229,15 @@ def get_customer_outstanding(customer, company): def get_credit_limit(customer, company): - credit_limit, customer_group = frappe.db.get_value("Customer", customer, ["credit_limit", "customer_group"]) - if not credit_limit: - credit_limit = frappe.db.get_value("Customer Group", customer_group, "credit_limit") or \ - frappe.db.get_value("Company", company, "credit_limit") + credit_limit = None - return credit_limit + if customer: + credit_limit, customer_group = frappe.db.get_value("Customer", customer, ["credit_limit", "customer_group"]) + + if not credit_limit: + credit_limit = frappe.db.get_value("Customer Group", customer_group, "credit_limit") + + if not credit_limit: + credit_limit = frappe.db.get_value("Company", company, "credit_limit") + + return flt(credit_limit)