diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 064fac10253..19050a419f3 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -42,8 +42,8 @@ cur_frm.cscript.make_dashboard = function(doc) { if(r.message["company_currency"].length == 1) { cur_frm.dashboard.set_headline( __("Total Billing This Year: ") + "" - + format_currency(r.message.total_billing, r.message.company_currency[0]) - + ' / ' + __("Unpaid") + ": " + + format_currency(r.message.billing_this_year, r.message.company_currency[0]) + + ' / ' + __("Total Unpaid") + ": " + format_currency(r.message.total_unpaid, r.message.company_currency[0]) + ''); } diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 2dc2fd50af5..af7716be0ea 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -89,14 +89,18 @@ def get_dashboard_info(supplier): out[doctype] = frappe.db.get_value(doctype, {"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)") - billing = frappe.db.sql("""select sum(base_grand_total), sum(outstanding_amount) + billing_this_year = frappe.db.sql("""select sum(base_grand_total) from `tabPurchase Invoice` - where supplier=%s - and docstatus = 1 - and fiscal_year = %s""", (supplier, frappe.db.get_default("fiscal_year"))) + where supplier=%s and docstatus = 1 and fiscal_year = %s""", + (supplier, frappe.db.get_default("fiscal_year"))) + + total_unpaid = frappe.db.sql("""select sum(outstanding_amount) + from `tabPurchase Invoice` + where supplier=%s and docstatus = 1""", supplier) + - out["total_billing"] = billing[0][0] - out["total_unpaid"] = billing[0][1] + out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 + out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 out["company_currency"] = frappe.db.sql_list("select distinct default_currency from tabCompany") return out diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index d83628da24b..1f9a12bdd3c 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -58,7 +58,7 @@ cur_frm.cscript.setup_dashboard = function(doc) { if(r.message["company_currency"].length == 1) { cur_frm.dashboard.set_headline( __("Total Billing This Year: ") + "" - + format_currency(r.message.total_billing, r.message["company_currency"][0]) + + format_currency(r.message.billing_this_year, r.message["company_currency"][0]) + ' / ' + __("Unpaid") + ": " + format_currency(r.message.total_unpaid, r.message["company_currency"][0]) + ''); diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 2d0f850a5cf..19a9aae84d5 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -123,14 +123,17 @@ def get_dashboard_info(customer): out[doctype] = frappe.db.get_value(doctype, {"customer": customer, "docstatus": ["!=", 2] }, "count(*)") - billing = frappe.db.sql("""select sum(base_grand_total), sum(outstanding_amount) + billing_this_year = frappe.db.sql("""select sum(base_grand_total) from `tabSales Invoice` - where customer=%s - and docstatus = 1 - and fiscal_year = %s""", (customer, frappe.db.get_default("fiscal_year"))) + where customer=%s and docstatus = 1 and fiscal_year = %s""", + (customer, frappe.db.get_default("fiscal_year"))) + + total_unpaid = frappe.db.sql("""select sum(outstanding_amount) + from `tabSales Invoice` + where customer=%s and docstatus = 1""", customer) - out["total_billing"] = billing[0][0] - out["total_unpaid"] = billing[0][1] + out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 + out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 out["company_currency"] = frappe.db.sql_list("select distinct default_currency from tabCompany") return out