diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index dea6b7bac86d..a1f97fbfbef0 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -476,7 +476,7 @@ def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, -def get_customer_outstanding(customer, company, ignore_outstanding_sales_order=False, cost_center=None): +def get_customer_outstanding(customer, company, ignore_outstanding_sales_order=False, cost_center=None, no_sum=False): # Outstanding based on GL Entries cond = "" @@ -530,8 +530,10 @@ def get_customer_outstanding(customer, company, ignore_outstanding_sales_order=F if flt(dn_item.amount) > flt(si_amount) and dn_item.base_net_total: outstanding_based_on_dn += ((flt(dn_item.amount) - flt(si_amount)) \ / dn_item.base_net_total) * dn_item.base_grand_total - - return outstanding_based_on_gle + outstanding_based_on_so + outstanding_based_on_dn + if not no_sum: + return outstanding_based_on_gle + outstanding_based_on_so + outstanding_based_on_dn + else: + return outstanding_based_on_gle, outstanding_based_on_so, outstanding_based_on_dn def get_credit_limit(customer, company): diff --git a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py index aaa9df5bf617..70599094ee6a 100644 --- a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py +++ b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py @@ -19,20 +19,26 @@ def execute(filters=None): for d in customer_list: row = [] - outstanding_amt = get_customer_outstanding(d.name, filters.get("company"), - ignore_outstanding_sales_order=d.bypass_credit_limit_check_at_sales_order) + outstanding_based_on_gle, outstanding_based_on_so, outstanding_based_on_dn = get_customer_outstanding(d.name, filters.get("company"), + ignore_outstanding_sales_order=d.bypass_credit_limit_check, no_sum=True) + + total_outstanding_amount = outstanding_based_on_gle+outstanding_based_on_so+outstanding_based_on_dn credit_limit = get_credit_limit(d.name, filters.get("company")) - bal = flt(credit_limit) - flt(outstanding_amt) + bal = flt(credit_limit) - flt(total_outstanding_amount) if customer_naming_type == "Naming Series": - row = [d.name, d.customer_name, credit_limit, outstanding_amt, bal, + row = [ + d.name, d.customer_name, credit_limit, + outstanding_based_on_gle, outstanding_based_on_so, + outstanding_based_on_dn, total_outstanding_amount, bal, d.bypass_credit_limit_check, d.is_frozen, d.disabled] else: - row = [d.name, credit_limit, outstanding_amt, bal, - d.bypass_credit_limit_check_at_sales_order, d.is_frozen, d.disabled] + row = [d.name, credit_limit, outstanding_based_on_gle, outstanding_based_on_so, + outstanding_based_on_dn, total_outstanding_amount, bal, + d.bypass_credit_limit_check, d.is_frozen, d.disabled] if credit_limit: data.append(row) @@ -43,7 +49,10 @@ def get_columns(customer_naming_type): columns = [ _("Customer") + ":Link/Customer:120", _("Credit Limit") + ":Currency:120", - _("Outstanding Amt") + ":Currency:100", + _("General Ledger Outstanding Amt") + ":Currency:100", + _("Sales Order Outstanding Amt") + ":Currency:100", + _("Delivery Note Outstanding Amt") + ":Currency:100", + _("Total Outstanding Amt") + ":Currency:100", _("Credit Balance") + ":Currency:120", _("Bypass credit check at Sales Order ") + ":Check:80", _("Is Frozen") + ":Check:80",