feat: add date range filters

This commit is contained in:
Mangesh-Khairnar 2019-05-03 16:00:02 +05:30
parent cc8e2b6aca
commit 13d393247a
2 changed files with 21 additions and 4 deletions

View File

@ -10,21 +10,30 @@ frappe.query_reports["Procurement Tracker"] = {
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("Company"),
reqd: 1
},
{
fieldname: "cost_center",
label: __("Cost Center"),
fieldtype: "Link",
options: "Cost Center",
reqd: 1
},
{
fieldname: "project",
label: __("Project"),
fieldtype: "Link",
options: "Project",
reqd: 1
}
},
{
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
},
{
fieldname:"to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
},
]
}

View File

@ -142,11 +142,19 @@ def get_conditions(filters):
if filters.get("company"):
conditions += " AND company='%s'"% filters.get('company')
if filters.get("cost_center") or filters.get("project"):
conditions += """
AND (cost_center='%s'
OR project='%s')
"""% (filters.get('cost_center'), filters.get('project'))
if filters.get("from_date"):
conditions.append("transaction_date>=%s", filters.get('from_date'))
if filters.get("to_date"):
conditions.append("transaction_date<=%s", filters.get('to_date')
return conditions
def get_data(filters):