fix: report full planned qty as pending when a plan has no work order

This commit is contained in:
Nabin Hait
2026-07-02 13:58:31 +05:30
parent 4e88157ed7
commit 14091a8996
2 changed files with 5 additions and 1 deletions

View File

@@ -42,7 +42,9 @@ def get_production_plan_item_details(filters, data, order_details):
order_qty = row.planned_qty
total_produced_qty = 0.0
pending_qty = 0.0
# default to the full planned qty so a plan without any work order still
# reports everything as pending rather than a misleading zero
pending_qty = flt(order_qty)
for work_order in work_orders:
produced_qty = flt(order_details.get((work_order, row.item_code), {}).get("produced_qty", 0))
pending_qty = flt(order_qty) - produced_qty

View File

@@ -72,6 +72,8 @@ class TestProductionPlanSummary(ERPNextTestSuite):
self.assertIsNotNone(summary)
self.assertEqual(summary.get("qty"), 2)
self.assertEqual(summary.get("produced_qty"), 0)
# nothing produced yet, so the whole planned qty is pending
self.assertEqual(summary.get("pending_qty"), 2)
self.assertIsNone(self.get_work_order_row(data, "_Test FG Item"))
def test_summary_with_pending_work_order(self):