Changes in get_dashboard_info
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 1330efc..777b209 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -469,21 +469,23 @@
company_wise_info = []
- company_wise_grand_total = frappe._dict(frappe.db.sql("""
- select company, sum(grand_total)
+ company_wise_grand_total = frappe.db.sql("""
+ select company, sum(grand_total) as grand_total, sum(base_grand_total) as base_grand_total
from `tab{0}`
where {1}=%s and docstatus=1 and posting_date between %s and %s
group by company"""
.format(doctype, party_type.lower()),
- (party, current_fiscal_year.year_start_date, current_fiscal_year.year_end_date)))
+ (party, current_fiscal_year.year_start_date, current_fiscal_year.year_end_date), as_dict=1)
- company_wise_base_grand_total = frappe._dict(frappe.db.sql("""
- select company, sum(base_grand_total)
- from `tab{0}`
- where {1}=%s and docstatus=1 and posting_date between %s and %s
- group by company"""
- .format(doctype, party_type.lower()),
- (party, current_fiscal_year.year_start_date, current_fiscal_year.year_end_date)))
+ company_wise_billing_this_year = frappe._dict()
+
+ for d in company_wise_grand_total:
+ company_wise_billing_this_year.setdefault(
+ d.company,{
+ "grand_total": d.grand_total,
+ "base_grand_total": d.base_grand_total
+ })
+
company_wise_total_unpaid = frappe._dict(frappe.db.sql("""
select company, sum(debit_in_account_currency) - sum(credit_in_account_currency)
@@ -496,9 +498,9 @@
party_account_currency = get_party_account_currency(party_type, party, d.company)
if party_account_currency==company_default_currency:
- billing_this_year = flt(company_wise_base_grand_total.get(d.company))
+ billing_this_year = flt(company_wise_billing_this_year.get(d.company,{}).get("base_grand_total"))
else:
- billing_this_year = flt(company_wise_grand_total.get(d.company))
+ billing_this_year = flt(company_wise_billing_this_year.get(d.company,{}).get("grand_total"))
total_unpaid = flt(company_wise_total_unpaid.get(d.company))
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index b80f8ac..18716a9 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -104,7 +104,7 @@
set_party_dashboard_indicators: function(frm) {
if(frm.doc.__onload && frm.doc.__onload.dashboard_info) {
var company_wise_info = frm.doc.__onload.dashboard_info;
- if(company_wise_info[0]) {
+ if(company_wise_info.length > 1) {
frm.dashboard.stats_area.removeClass('hidden');
frm.dashboard.stats_area_row.append(
'<div class="col-xs-4"><h6>Company</h6></div>'+
@@ -114,11 +114,18 @@
company_wise_info.forEach(function(info) {
frm.dashboard.stats_area_row.append(
'<div class="col-xs-4 small" style="margin-bottom:10px">'+info.company+'</div>' +
- '</div><div class="col-xs-4 small" style="margin-bottom:10px"><span class="indicator blue">'+format_currency(info.billing_this_year, info.currency)+'</span></div>' +
- '<div class="col-xs-4 small" style="margin-bottom:10px"><span class="indicator orange">'+format_currency(info.billing_this_year, info.currency)+'</span></div>'
+ '</div><div class="col-xs-4 small" style="margin-bottom:10px">'+format_currency(info.billing_this_year, info.currency)+'</div>' +
+ '<div class="col-xs-4 small" style="margin-bottom:10px">'+format_currency(info.billing_this_year, info.currency)+'</div>'
);
});
}
+ else {
+ frm.dashboard.stats_area.removeClass('hidden');
+ frm.dashboard.stats_area_row.append(
+ '</div><div class="col-xs-6 small" style="margin-bottom:10px">Annual Billing: '+format_currency(company_wise_info[0].billing_this_year, company_wise_info[0].currency)+'</div>' +
+ '<div class="col-xs-6 small" style="margin-bottom:10px">Total Unpaid: '+format_currency(company_wise_info[0].billing_this_year, company_wise_info[0].currency)+'</div>'
+ );
+ }
}
},