feat: add date range filters
This commit is contained in:
parent
cc8e2b6aca
commit
13d393247a
@ -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"),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user