frappe.query_reports["Sport and Lottery Report"] = {
    "filters": [
        {
            "fieldname": "company",
            "label": __("Company"),
            "fieldtype": "Link",
            "options": "Company",
            "default": frappe.defaults.get_user_default("Company"),
            "reqd": 1
        },
        {
            "fieldname": "from_date",
            "label": __("From Date"),
            "fieldtype": "Date",
            "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
            "reqd": 1
        },
        {
            "fieldname": "to_date",
            "label": __("To Date"),
            "fieldtype": "Date",
            "default": frappe.datetime.get_today(),
            "reqd": 1
        }
    ],
    "columns": [
        {
            "label": __("Sales Invoice"),
            "fieldname": "sales_invoice",
            "fieldtype": "Link",
            "options": "Sales Invoice",
            "width": 200
        },
        {
            "label": __("Posting Date"),
            "fieldname": "posting_date",
            "fieldtype": "Date",
            "width": 120
        },
        {
            "label": __("Grand Total"),
            "fieldname": "grand_total",
            "fieldtype": "Currency",
            "options": "currency",
            "width": 150
        },
        {
            "label": __("Amount up to 500"),
            "fieldname": "amount_up_to_500",
            "fieldtype": "Currency",
            "options": "currency",
            "width": 180
        },
        {
            "label": __("Amount over 500"),
            "fieldname": "amount_over_500",
            "fieldtype": "Currency",
            "options": "currency",
            "width": 180
        }
    ],
    "formatter": function(value, row, column, data, default_formatter) {
        value = default_formatter(value, row, column, data);
        if (column.fieldname === "amount_up_to_500" && data.amount_up_to_500 > 0) {
            value = "<span style='color:green;'>" + value + "</span>";
        } else if (column.fieldname === "amount_over_500" && data.amount_over_500 > 0) {
            value = "<span style='color:red;'>" + value + "</span>";
        }
        return value;
    }
};
