fix: get filters to work
- reorder and rename columns
- add work order filter
diff --git a/erpnext/stock/report/process_loss_report/process_loss_report.js b/erpnext/stock/report/process_loss_report/process_loss_report.js
index 078b9e1..b0c2b94 100644
--- a/erpnext/stock/report/process_loss_report/process_loss_report.js
+++ b/erpnext/stock/report/process_loss_report/process_loss_report.js
@@ -19,6 +19,13 @@
options: "Item",
mandatory: false,
},
+ {
+ label: __("Work Order"),
+ fieldname: "work_order",
+ fieldtype: "Link",
+ options: "Work Order",
+ mandatory: false,
+ },
{
label: __("From Date"),
fieldname: "from_date",
diff --git a/erpnext/stock/report/process_loss_report/process_loss_report.py b/erpnext/stock/report/process_loss_report/process_loss_report.py
index be0f015..7494328 100644
--- a/erpnext/stock/report/process_loss_report/process_loss_report.py
+++ b/erpnext/stock/report/process_loss_report/process_loss_report.py
@@ -44,19 +44,13 @@
'width': '100'
},
{
- 'label': 'Qty To Manufacture',
- 'fieldname': 'qty',
- 'fieldtype': 'Float',
- 'width': '150'
- },
- {
'label': 'Manufactured Qty',
'fieldname': 'produced_qty',
'fieldtype': 'Float',
'width': '150'
},
{
- 'label': 'Process Loss Qty',
+ 'label': 'Loss Qty',
'fieldname': 'process_loss_qty',
'fieldtype': 'Float',
'width': '150'
@@ -68,23 +62,23 @@
'width': '150'
},
{
- 'label': 'Total FG Value',
+ 'label': 'Loss Value',
+ 'fieldname': 'total_pl_value',
+ 'fieldtype': 'Float',
+ 'width': '150'
+ },
+ {
+ 'label': 'FG Value',
'fieldname': 'total_fg_value',
'fieldtype': 'Float',
'width': '150'
},
{
- 'label': 'Total Raw Material Value',
+ 'label': 'Raw Material Value',
'fieldname': 'total_rm_value',
'fieldtype': 'Float',
'width': '150'
- },
- {
- 'label': 'Total Process Loss Value',
- 'fieldname': 'total_pl_value',
- 'fieldtype': 'Float',
- 'width': '150'
- },
+ }
]
def get_query_args(filters: Filters) -> QueryArgs:
@@ -111,10 +105,11 @@
AND wo.company = %(company)s
AND se.docstatus = 1
AND se.posting_date BETWEEN %(from_date)s AND %(to_date)s
- %(item_filter)s
+ {item_filter}
+ {work_order_filter}
GROUP BY
se.work_order
- """, query_args, as_dict=1)
+ """.format(**query_args), query_args, as_dict=1, debug=1)
def update_data_with_total_pl_value(data: Data) -> None:
for row in data:
@@ -122,11 +117,16 @@
row['total_pl_value'] = row['process_loss_qty'] * value_per_unit_fg
def get_filter_conditions(filters: Filters) -> QueryArgs:
- filter_conditions = dict(item_filter="")
+ filter_conditions = dict(item_filter="", work_order_filter="")
if "item" in filters:
production_item = filters.get("item")
filter_conditions.update(
- {"item_filter": f"wo.production_item='{production_item}'"}
+ {"item_filter": f"AND wo.production_item='{production_item}'"}
+ )
+ if "work_order" in filters:
+ work_order_name = filters.get("work_order")
+ filter_conditions.update(
+ {"work_order_filter": f"AND wo.name='{work_order_name}'"}
)
return filter_conditions