feat: additional filters on Payment terms report
Filter on Status and Due dates
This commit is contained in:
parent
c52b41d311
commit
aadb6b1772
@ -74,7 +74,35 @@ function get_filters() {
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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;
|
||||
}
|
||||
|
@ -162,6 +162,12 @@ def build_filter_criterions(filters):
|
||||
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 @@ def prepare_chart(s_orders):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user