diff --git a/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js index 7c6ccfdf743..7629c102d7c 100644 --- a/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js +++ b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js @@ -45,9 +45,9 @@ frappe.query_reports["BOM Stock Analysis"] = { } if (data && data.bold) { - if (column.fieldname === "description" || column.fieldname === "item_name") { - const qty_to_make = frappe.query_report.get_filter_value("qty_to_make"); - const producible = parseFloat(value) || 0; + if (column.fieldname === "description") { + const qty_to_make = Number(frappe.query_report.get_filter_value("qty_to_make")) || 0; + const producible = Number(String(data.description ?? "").replace(/,/g, "")) || 0; const colour = qty_to_make && producible < qty_to_make ? "red" : "green"; return `${value}`; } diff --git a/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.py b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.py index 78aa75aa7fa..59578127f9f 100644 --- a/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.py +++ b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.py @@ -10,6 +10,7 @@ from pypika.terms import ExistsCriterion def execute(filters=None): + filters = filters or {} if filters.get("qty_to_make"): columns = get_columns_with_qty_to_make() data = get_data_with_qty_to_make(filters) @@ -35,7 +36,7 @@ def get_data_with_qty_to_make(filters): bom_data = get_bom_data(filters) manufacture_details = get_manufacturer_records() purchase_rates = batch_fetch_purchase_rates(bom_data) - qty_to_make = filters.get("qty_to_make") + qty_to_make = flt(filters.get("qty_to_make")) data = [] for row in bom_data: @@ -203,7 +204,7 @@ def get_bom_data(filters): bom_item.item_code, bom_item.description, bom_item.parent.as_("from_bom_no"), - bom_item.qty_consumed_per_unit.as_("qty_per_unit"), + Sum(bom_item.qty_consumed_per_unit).as_("qty_per_unit"), IfNull(Sum(bin.actual_qty), 0).as_("actual_qty"), ) .where((bom_item.parent == filters.get("bom")) & (bom_item.parenttype == "BOM")) diff --git a/erpnext/manufacturing/report/test_reports.py b/erpnext/manufacturing/report/test_reports.py index adeddd996a5..505a82c3501 100644 --- a/erpnext/manufacturing/report/test_reports.py +++ b/erpnext/manufacturing/report/test_reports.py @@ -21,8 +21,7 @@ class TestManufacturingReports(ERPNextTestSuite): self.REPORT_FILTER_TEST_CASES: list[tuple[ReportName, ReportFilters]] = [ ("BOM Explorer", {"bom": self.last_bom}), ("BOM Operations Time", {}), - ("BOM Stock Calculated", {"bom": self.last_bom, "qty_to_make": 2}), - ("BOM Stock Report", {"bom": self.last_bom, "qty_to_produce": 2}), + ("BOM Stock Analysis", {"bom": self.last_bom, "_optional": ["warehouse"]}), ("Cost of Poor Quality Report", {"item": "_Test Item", "serial_no": "00"}), ("Downtime Analysis", {}), (