feat: additional filters on Payment terms report
Filter on Status and Due dates
diff --git a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js
index c068ae3..991ac71 100644
--- a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js
+++ b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js
@@ -74,7 +74,35 @@
]
}
}
- }
+ },
+ {
+ "fieldname":"from_due_date",
+ "label": __("From Due Date"),
+ "fieldtype": "Date",
+ },
+ {
+ "fieldname":"to_due_date",
+ "label": __("To Due Date"),
+ "fieldtype": "Date",
+ },
+ {
+ "fieldname":"status",
+ "label": __("Status"),
+ "fieldtype": "MultiSelectList",
+ "width": 100,
+ get_data: function(txt) {
+ let status = ["Overdue", "Unpaid", "Completed", "Partly Paid"]
+ let options = []
+ for (let option of status){
+ options.push({
+ "value": option,
+ "label": __(option),
+ "description": ""
+ })
+ }
+ return options
+ }
+ },
]
return filters;
}
diff --git a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py
index 91f4a5e..8bf5686 100644
--- a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py
+++ b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py
@@ -162,6 +162,12 @@
if filters.item:
qb_criterions.append(qb.DocType("Sales Order Item").item_code == filters.item)
+ if filters.from_due_date:
+ qb_criterions.append(qb.DocType("Payment Schedule").due_date.gte(filters.from_due_date))
+
+ if filters.to_due_date:
+ qb_criterions.append(qb.DocType("Payment Schedule").due_date.lte(filters.to_due_date))
+
return qb_criterions
@@ -279,11 +285,19 @@
return chart
+def filter_on_calculated_status(filters, sales_orders):
+ if filters.status and sales_orders:
+ return [x for x in sales_orders if x.status in filters.status]
+ return sales_orders
+
+
def execute(filters=None):
columns = get_columns()
sales_orders, so_invoices = get_so_with_invoices(filters)
sales_orders, so_invoices = set_payment_terms_statuses(sales_orders, so_invoices, filters)
+ sales_orders = filter_on_calculated_status(filters, sales_orders)
+
prepare_chart(sales_orders)
data = sales_orders