feat: add date range filters
diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.js b/erpnext/buying/report/procurement_tracker/procurement_tracker.js
index 0013666..283d56c 100644
--- a/erpnext/buying/report/procurement_tracker/procurement_tracker.js
+++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.js
@@ -10,21 +10,30 @@
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"),
+ },
]
}
diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
index 064bf6f..7889d95 100644
--- a/erpnext/buying/report/procurement_tracker/procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
@@ -142,11 +142,19 @@
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):