Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down