2015-03-03 09:25:30 +00:00
|
|
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
2013-08-05 09:29:54 +00:00
|
|
|
// License: GNU General Public License v3. See license.txt
|
|
|
|
|
2014-02-14 10:17:51 +00:00
|
|
|
frappe.query_reports["Gross Profit"] = {
|
2013-02-25 12:47:51 +00:00
|
|
|
"filters": [
|
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "company",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("Company"),
|
2013-02-25 12:47:51 +00:00
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Company",
|
2022-02-10 07:37:51 +00:00
|
|
|
"default": frappe.defaults.get_user_default("Company"),
|
|
|
|
"reqd": 1
|
2013-03-21 14:54:10 +00:00
|
|
|
},
|
2013-03-22 07:46:10 +00:00
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "from_date",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("From Date"),
|
2013-03-22 07:46:10 +00:00
|
|
|
"fieldtype": "Date",
|
2022-02-10 07:37:51 +00:00
|
|
|
"default": frappe.defaults.get_user_default("year_start_date"),
|
|
|
|
"reqd": 1
|
2013-03-22 07:46:10 +00:00
|
|
|
},
|
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "to_date",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("To Date"),
|
2013-03-22 07:46:10 +00:00
|
|
|
"fieldtype": "Date",
|
2022-02-10 07:37:51 +00:00
|
|
|
"default": frappe.defaults.get_user_default("year_end_date"),
|
|
|
|
"reqd": 1
|
2013-03-22 07:46:10 +00:00
|
|
|
},
|
2019-04-23 13:03:01 +00:00
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "sales_invoice",
|
2019-04-23 13:03:01 +00:00
|
|
|
"label": __("Sales Invoice"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Sales Invoice"
|
|
|
|
},
|
2014-11-24 09:42:37 +00:00
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "group_by",
|
2014-11-24 09:42:37 +00:00
|
|
|
"label": __("Group By"),
|
|
|
|
"fieldtype": "Select",
|
2022-05-31 13:46:56 +00:00
|
|
|
"options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term",
|
2014-11-24 09:42:37 +00:00
|
|
|
"default": "Invoice"
|
|
|
|
},
|
2022-08-15 12:14:23 +00:00
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "item_group",
|
2022-08-15 12:14:23 +00:00
|
|
|
"label": __("Item Group"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Item Group"
|
|
|
|
},
|
|
|
|
{
|
2022-09-04 07:45:59 +00:00
|
|
|
"fieldname": "sales_person",
|
2022-08-15 12:14:23 +00:00
|
|
|
"label": __("Sales Person"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Sales Person"
|
|
|
|
},
|
2021-08-19 20:49:18 +00:00
|
|
|
],
|
|
|
|
"tree": true,
|
|
|
|
"name_field": "parent",
|
|
|
|
"parent_field": "parent_invoice",
|
2021-08-20 00:36:47 +00:00
|
|
|
"initial_depth": 3,
|
2021-08-19 21:08:34 +00:00
|
|
|
"formatter": function(value, row, column, data, default_formatter) {
|
2022-08-03 05:51:30 +00:00
|
|
|
if (column.fieldname == "sales_invoice" && column.options == "Item" && data && data.indent == 0) {
|
2022-02-11 07:02:45 +00:00
|
|
|
column._options = "Sales Invoice";
|
|
|
|
} else {
|
|
|
|
column._options = "Item";
|
|
|
|
}
|
2021-08-19 21:08:34 +00:00
|
|
|
value = default_formatter(value, row, column, data);
|
|
|
|
|
2022-08-03 05:51:30 +00:00
|
|
|
if (data && (data.indent == 0.0 || (row[1] && row[1].content == "Total"))) {
|
2021-08-19 21:08:34 +00:00
|
|
|
value = $(`<span>${value}</span>`);
|
|
|
|
var $value = $(value).css("font-weight", "bold");
|
|
|
|
value = $value.wrap("<p></p>").parent().html();
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
},
|
2014-11-24 09:42:37 +00:00
|
|
|
}
|