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.

Revisions

  1. f7urry revised this gist Jan 28, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Example Custom Format For Query Report.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ```
    frappe.query_reports["Budget vs Claim"] = {
    "filters": [
    @@ -36,4 +37,5 @@ frappe.query_reports["Budget vs Claim"] = {
    }
    };
    //you can check fieldname on this object
    //console.log(frappe.query_report);
    //console.log(frappe.query_report);
    ```
  2. f7urry renamed this gist Jan 28, 2022. 1 changed file with 0 additions and 0 deletions.
  3. f7urry created this gist Jan 28, 2022.
    39 changes: 39 additions & 0 deletions Example Custom Format For Query Report
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@

    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);