[fix] Dashboard info in accounting currency for Customer and Supplier #4017

This commit is contained in:
Nabin Hait 2015-09-17 14:16:01 +05:30
parent 2a04d98c16
commit 87c2d1d634
6 changed files with 648 additions and 653 deletions

View File

@ -39,16 +39,12 @@ cur_frm.cscript.make_dashboard = function(doc) {
},
callback: function(r) {
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) {
if(r.message["company_currency"].length == 1) {
cur_frm.dashboard.set_headline(
__("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.billing_this_year, r.message.company_currency[0])
+ '</b> / <span class="text-muted">' + __("Total Unpaid") + ": <b>"
+ format_currency(r.message.total_unpaid, r.message.company_currency[0])
+ '</b></span>');
} else {
cur_frm.dashboard.set_headline("");
}
cur_frm.dashboard.set_headline(
__("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.billing_this_year, cur_frm.doc.party_account_currency)
+ '</b> / <span class="text-muted">' + __("Total Unpaid") + ": <b>"
+ format_currency(r.message.total_unpaid, cur_frm.doc.party_account_currency)
+ '</b></span>');
}
cur_frm.dashboard.set_badge_count(r.message);
}

File diff suppressed because it is too large Load Diff

View File

@ -93,9 +93,11 @@ def get_dashboard_info(supplier):
out[doctype] = frappe.db.get_value(doctype,
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
billing_this_year = frappe.db.sql("""select sum(base_grand_total)
from `tabPurchase Invoice`
where supplier=%s and docstatus = 1 and fiscal_year = %s""",
billing_this_year = frappe.db.sql("""
select sum(ifnull(credit_in_account_currency, 0)) - sum(ifnull(debit_in_account_currency, 0))
from `tabGL Entry`
where voucher_type='Purchase Invoice' and party_type = 'Supplier'
and party=%s and fiscal_year = %s""",
(supplier, frappe.db.get_default("fiscal_year")))
total_unpaid = frappe.db.sql("""select sum(outstanding_amount)

View File

@ -64,16 +64,12 @@ cur_frm.cscript.setup_dashboard = function(doc) {
},
callback: function(r) {
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) {
if(r.message["company_currency"].length == 1) {
cur_frm.dashboard.set_headline(
__("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.billing_this_year, r.message["company_currency"][0])
+ '</b> / <span class="text-muted">' + __("Unpaid") + ": <b>"
+ format_currency(r.message.total_unpaid, r.message["company_currency"][0])
+ '</b></span>');
} else {
cur_frm.dashboard.set_headline("");
}
cur_frm.dashboard.set_headline(
__("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.billing_this_year, cur_frm.doc.party_account_currency)
+ '</b> / <span class="text-muted">' + __("Unpaid") + ": <b>"
+ format_currency(r.message.total_unpaid, cur_frm.doc.party_account_currency)
+ '</b></span>');
}
cur_frm.dashboard.set_badge_count(r.message);
}

View File

@ -273,7 +273,7 @@
"ignore_user_permissions": 1,
"in_filter": 0,
"in_list_view": 0,
"label": "Default Currency",
"label": "Billing Currency",
"no_copy": 1,
"options": "Currency",
"permlevel": 0,
@ -819,7 +819,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"modified": "2015-09-14 02:57:54.098402",
"modified": "2015-09-17 14:05:38.541266",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
@ -827,7 +827,7 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"apply_user_permissions": 1,
"cancel": 0,
"create": 1,
"delete": 0,
@ -987,7 +987,7 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"apply_user_permissions": 1,
"cancel": 0,
"create": 0,
"delete": 0,

View File

@ -128,9 +128,11 @@ def get_dashboard_info(customer):
out[doctype] = frappe.db.get_value(doctype,
{"customer": customer, "docstatus": ["!=", 2] }, "count(*)")
billing_this_year = frappe.db.sql("""select sum(base_grand_total)
from `tabSales Invoice`
where customer=%s and docstatus = 1 and fiscal_year = %s""",
billing_this_year = frappe.db.sql("""
select sum(ifnull(debit_in_account_currency, 0)) - sum(ifnull(credit_in_account_currency, 0))
from `tabGL Entry`
where voucher_type='Sales Invoice' and party_type = 'Customer'
and party=%s and fiscal_year = %s""",
(customer, frappe.db.get_default("fiscal_year")))
total_unpaid = frappe.db.sql("""select sum(outstanding_amount)
@ -139,7 +141,6 @@ def get_dashboard_info(customer):
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