From d176d86e2c9a96ec0f7d884b89a170b7dc8e020e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Thu, 15 Jun 2023 16:01:08 +0530 Subject: [PATCH] fix: `Process Loss Report` --- .../process_loss_report.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/erpnext/manufacturing/report/process_loss_report/process_loss_report.py b/erpnext/manufacturing/report/process_loss_report/process_loss_report.py index ce8f4f35a3..c3dd9cf9b1 100644 --- a/erpnext/manufacturing/report/process_loss_report/process_loss_report.py +++ b/erpnext/manufacturing/report/process_loss_report/process_loss_report.py @@ -33,10 +33,9 @@ def get_data(filters: Filters) -> Data: wo.name, wo.status, wo.production_item, - wo.qty, wo.produced_qty, wo.process_loss_qty, - (wo.produced_qty - wo.process_loss_qty).as_("actual_produced_qty"), + wo.qty.as_("qty_to_manufacture"), Sum(se.total_incoming_value).as_("total_fg_value"), Sum(se.total_outgoing_value).as_("total_rm_value"), ) @@ -44,6 +43,7 @@ def get_data(filters: Filters) -> Data: (wo.process_loss_qty > 0) & (wo.company == filters.company) & (se.docstatus == 1) + & (se.purpose == "Manufacture") & (se.posting_date.between(filters.from_date, filters.to_date)) ) .groupby(se.work_order) @@ -79,20 +79,30 @@ def get_columns() -> Columns: "width": "100", }, {"label": _("Status"), "fieldname": "status", "fieldtype": "Data", "width": "100"}, + { + "label": _("Qty To Manufacture"), + "fieldname": "qty_to_manufacture", + "fieldtype": "Float", + "width": "150", + }, { "label": _("Manufactured Qty"), "fieldname": "produced_qty", "fieldtype": "Float", "width": "150", }, - {"label": _("Loss Qty"), "fieldname": "process_loss_qty", "fieldtype": "Float", "width": "150"}, { - "label": _("Actual Manufactured Qty"), - "fieldname": "actual_produced_qty", + "label": _("Process Loss Qty"), + "fieldname": "process_loss_qty", + "fieldtype": "Float", + "width": "150", + }, + { + "label": _("Process Loss Value"), + "fieldname": "total_pl_value", "fieldtype": "Float", "width": "150", }, - {"label": _("Loss Value"), "fieldname": "total_pl_value", "fieldtype": "Float", "width": "150"}, {"label": _("FG Value"), "fieldname": "total_fg_value", "fieldtype": "Float", "width": "150"}, { "label": _("Raw Material Value"), @@ -105,5 +115,5 @@ def get_columns() -> Columns: def update_data_with_total_pl_value(data: Data) -> None: for row in data: - value_per_unit_fg = row["total_fg_value"] / row["actual_produced_qty"] + value_per_unit_fg = row["total_fg_value"] / row["qty_to_manufacture"] row["total_pl_value"] = row["process_loss_qty"] * value_per_unit_fg