frappe.pages["leaderboard"].on_page_load = function (wrapper) { frappe.leaderboard = new frappe.Leaderboard(wrapper); } frappe.Leaderboard = Class.extend({ init: function (parent) { frappe.ui.make_app_page({ parent: parent, title: "Leaderboard", single_column: false }); this.parent = parent; this.page = this.parent.page; this.page.sidebar.html(`
`); this.$sidebar_list = this.page.sidebar.find('ul'); // const list of doctypes this.doctypes = ["Customer", "Item", "Supplier", "Sales Partner","Sales Person"]; this.timespans = ["Week", "Month", "Quarter", "Year"]; this.desc_fields = ["total_sales_amount", "total_request","total_purchase_amount","commission_rate"]; this.filters = { "Customer": ["total_item_purchased_qty", "total_sales_amount","receivable_amount_outstanding_amount"], "Item": ["total_purchase_amount", "total_purchased_qty", "total_sales_amount", "total_sold_qty","available_stock_qty"], "Supplier": ["total_item_sold_qty", "total_purchase_amount","payable_amount_outstanding_amount"], "Sales Partner": ["commission_rate", "target_qty", "target_amount", "total_sales_amount"], "Sales Person": ["target_qty", "target_amount", "total_sales_amount"], }; // for saving current selected filters // TODO: revert to 0 index for doctype and timespan, and remove preset down const _initial_doctype = this.doctypes[0]; const _initial_timespan = this.timespans[0]; const _initial_filter = this.filters[_initial_doctype]; this.options = { selected_doctype: _initial_doctype, selected_filter: _initial_filter, selected_filter_item: _initial_filter[0], selected_timespan: _initial_timespan, }; this.message = null; this.make(); }, make: function () { var me = this; var $container = $(`No Item found