[fix] Sales partner details get from sales Order and company currency details from selected company
diff --git a/erpnext/utilities/page/leaderboard/leaderboard.js b/erpnext/utilities/page/leaderboard/leaderboard.js
index 860506b..36dbc62 100644
--- a/erpnext/utilities/page/leaderboard/leaderboard.js
+++ b/erpnext/utilities/page/leaderboard/leaderboard.js
@@ -273,7 +273,7 @@
get_item_html: function (item) {
var me = this;
- const company = frappe.defaults.get_default('Company');
+ const company = me.options.selected_company
const currency = frappe.get_doc(":Company", company).default_currency;
const _selected_filter = me.options.selected_filter
.map(i => frappe.model.unscrub(i));
diff --git a/erpnext/utilities/page/leaderboard/leaderboard.py b/erpnext/utilities/page/leaderboard/leaderboard.py
index 0d580b4..9797d47 100644
--- a/erpnext/utilities/page/leaderboard/leaderboard.py
+++ b/erpnext/utilities/page/leaderboard/leaderboard.py
@@ -115,15 +115,15 @@
elif field == "target_amount":
select_field = "target_detail.target_amount"
elif field == "total_sales_amount":
- select_field = "sum(sales_invoice.total_commission)"
+ select_field = "sum(sales_order.total_commission)"
return frappe.db.sql("""select sales_partner.partner_name as name, {0} as value
from
`tabSales Partner` as sales_partner inner join `tabTarget Detail` as target_detail ON sales_partner.name = target_detail.parent
inner join
- `tabSales Invoice` as sales_invoice ON sales_invoice.sales_partner = sales_partner.name
+ `tabSales Order` as sales_order ON sales_order.sales_partner = sales_partner.name
where
- sales_invoice.docstatus = 1 and sales_invoice.modified >= "{1}"
+ sales_order.docstatus = 1 and sales_order.modified >= "{1}"
group by
sales_partner.partner_name
order by value DESC