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",
|
fieldtype: "Link",
|
||||||
options: "Company",
|
options: "Company",
|
||||||
default: frappe.defaults.get_user_default("Company"),
|
default: frappe.defaults.get_user_default("Company"),
|
||||||
reqd: 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
reqd: 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "project",
|
fieldname: "project",
|
||||||
label: __("Project"),
|
label: __("Project"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Project",
|
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"):
|
if filters.get("company"):
|
||||||
conditions += " AND company='%s'"% filters.get('company')
|
conditions += " AND company='%s'"% filters.get('company')
|
||||||
|
|
||||||
if filters.get("cost_center") or filters.get("project"):
|
if filters.get("cost_center") or filters.get("project"):
|
||||||
conditions += """
|
conditions += """
|
||||||
AND (cost_center='%s'
|
AND (cost_center='%s'
|
||||||
OR project='%s')
|
OR project='%s')
|
||||||
"""% (filters.get('cost_center'), filters.get('project'))
|
"""% (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
|
return conditions
|
||||||
|
|
||||||
def get_data(filters):
|
def get_data(filters):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user