Skip to content

Instantly share code, notes, and snippets.

@f7urry
Last active January 28, 2022 09:15
Show Gist options
  • Save f7urry/101cceeadb6218184e338808cca3fea5 to your computer and use it in GitHub Desktop.
Save f7urry/101cceeadb6218184e338808cca3fea5 to your computer and use it in GitHub Desktop.

frappe.query_reports["Budget vs Claim"] = {
	"filters": [
		{
			"fieldname": "company",
			"label": __("Company"),
			"fieldtype": "Link",
			"width": "80",
			"options": "Company",
			"default": frappe.defaults.get_default("company")
		},
		{
			"fieldname":"from_date",
			"label": __("From Date"),
			"fieldtype": "Date",
			"width": "80",
			"reqd": 1,
			"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
		},
		{
			"fieldname":"to_date",
			"label": __("To Date"),
			"fieldtype": "Date",
			"width": "80",
			"reqd": 1,
			"default": frappe.datetime.get_today()
		}
    ],
    "formatter": function (value, row, column, data, default_formatter) {
		value = default_formatter(value, row, column, data);

		if (column.fieldname == "sisa" && data && data.sisa < 0) {
			value = "<span style='color:red'>" + value + "</span>";
		}
        return value;
	}
};
//you can check fieldname on this object
//console.log(frappe.query_report);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment