fix: Contribution amount against invoices in Sales Person Dashboard
This commit is contained in:
parent
01638a01cb
commit
3a7776ea7f
@ -4,8 +4,12 @@
|
||||
frappe.ui.form.on('Sales Person', {
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.__onload && frm.doc.__onload.dashboard_info) {
|
||||
var info = frm.doc.__onload.dashboard_info;
|
||||
frm.dashboard.add_indicator(__('Total Contribution Amount: {0}', [format_currency(info.allocated_amount, info.currency)]), 'blue');
|
||||
let info = frm.doc.__onload.dashboard_info;
|
||||
frm.dashboard.add_indicator(__('Total Contribution Amount Against Orders: {0}',
|
||||
[format_currency(info.allocated_amount_against_order, info.currency)]), 'blue');
|
||||
|
||||
frm.dashboard.add_indicator(__('Total Contribution Amount Against Invoices: {0}',
|
||||
[format_currency(info.allocated_amount_against_invoice, info.currency)]), 'blue');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -28,14 +28,17 @@ class SalesPerson(NestedSet):
|
||||
def load_dashboard_info(self):
|
||||
company_default_currency = get_default_currency()
|
||||
|
||||
allocated_amount = frappe.db.sql("""
|
||||
select sum(allocated_amount)
|
||||
from `tabSales Team`
|
||||
where sales_person = %s and docstatus=1 and parenttype = 'Sales Order'
|
||||
""",(self.sales_person_name))
|
||||
allocated_amount_against_order = flt(frappe.db.get_value('Sales Team',
|
||||
{'docstatus': 1, 'parenttype': 'Sales Order', 'sales_person': self.sales_person_name},
|
||||
'sum(allocated_amount)'))
|
||||
|
||||
allocated_amount_against_invoice = flt(frappe.db.get_value('Sales Team',
|
||||
{'docstatus': 1, 'parenttype': 'Sales Invoice', 'sales_person': self.sales_person_name},
|
||||
'sum(allocated_amount)'))
|
||||
|
||||
info = {}
|
||||
info["allocated_amount"] = flt(allocated_amount[0][0]) if allocated_amount else 0
|
||||
info["allocated_amount_against_order"] = allocated_amount_against_order
|
||||
info["allocated_amount_against_invoice"] = allocated_amount_against_invoice
|
||||
info["currency"] = company_default_currency
|
||||
|
||||
self.set_onload('dashboard_info', info)
|
||||
|
Loading…
Reference in New Issue
Block a user