fix: Target variance report signs
This commit is contained in:
parent
d6615248a8
commit
5d5f026a0d
@ -63,13 +63,13 @@ def get_columns(filters, period_list, partner_doctype):
|
||||
"label": _(partner_doctype),
|
||||
"fieldtype": "Link",
|
||||
"options": partner_doctype,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}, {
|
||||
"fieldname": "item_group",
|
||||
"label": _("Item Group"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Item Group",
|
||||
"width": 100
|
||||
"width": 150
|
||||
}]
|
||||
|
||||
for period in period_list:
|
||||
@ -81,19 +81,19 @@ def get_columns(filters, period_list, partner_doctype):
|
||||
"label": _("Target ({})").format(period.label),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}, {
|
||||
"fieldname": period.key,
|
||||
"label": _("Achieved ({})").format(period.label),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}, {
|
||||
"fieldname": variance_key,
|
||||
"label": _("Variance ({})").format(period.label),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}])
|
||||
|
||||
columns.extend([{
|
||||
@ -101,19 +101,19 @@ def get_columns(filters, period_list, partner_doctype):
|
||||
"label": _("Total Target"),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}, {
|
||||
"fieldname": "total_achieved",
|
||||
"label": _("Total Achieved"),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}, {
|
||||
"fieldname": "total_variance",
|
||||
"label": _("Total Variance"),
|
||||
"fieldtype": fieldtype,
|
||||
"options": options,
|
||||
"width": 100
|
||||
"width": 150
|
||||
}])
|
||||
|
||||
return columns
|
||||
@ -154,10 +154,10 @@ def prepare_data(filters, sales_users_data, actual_data, date_field, period_list
|
||||
if (r.get(sales_field) == d.parent and r.item_group == d.item_group and
|
||||
period.from_date <= r.get(date_field) and r.get(date_field) <= period.to_date):
|
||||
details[p_key] += r.get(qty_or_amount_field, 0)
|
||||
details[variance_key] = details.get(target_key) - details.get(p_key)
|
||||
details[variance_key] = details.get(p_key) - details.get(target_key)
|
||||
|
||||
details["total_achieved"] += details.get(p_key)
|
||||
details["total_variance"] = details.get("total_target") - details.get("total_achieved")
|
||||
details["total_variance"] = details.get("total_achieved") - details.get("total_target")
|
||||
|
||||
return rows
|
||||
|
||||
|
@ -44,5 +44,20 @@ frappe.query_reports["Sales Partner Target Variance based on Item Group"] = {
|
||||
options: "Quantity\nAmount",
|
||||
default: "Quantity"
|
||||
},
|
||||
]
|
||||
],
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname.includes('variance')) {
|
||||
|
||||
if (data[column.fieldname] < 0) {
|
||||
value = "<span style='color:red'>" + value + "</span>";
|
||||
}
|
||||
else if (data[column.fieldname] > 0) {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -44,5 +44,20 @@ frappe.query_reports["Sales Person Target Variance Based On Item Group"] = {
|
||||
options: "Quantity\nAmount",
|
||||
default: "Quantity"
|
||||
},
|
||||
]
|
||||
],
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname.includes('variance')) {
|
||||
|
||||
if (data[column.fieldname] < 0) {
|
||||
value = "<span style='color:red'>" + value + "</span>";
|
||||
}
|
||||
else if (data[column.fieldname] > 0) {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -44,5 +44,20 @@ frappe.query_reports["Territory Target Variance Based On Item Group"] = {
|
||||
options: "Quantity\nAmount",
|
||||
default: "Quantity"
|
||||
},
|
||||
]
|
||||
],
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname.includes('variance')) {
|
||||
|
||||
if (data[column.fieldname] < 0) {
|
||||
value = "<span style='color:red'>" + value + "</span>";
|
||||
}
|
||||
else if (data[column.fieldname] > 0) {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user