| @@ -432,11 +432,11 @@ open class ProductionScheduleService( | |||||
| val bom = bomService.findByItemId(itemId) | val bom = bomService.findByItemId(itemId) | ||||
| ?: throw NoSuchElementException("BOM not found for Item ID $itemId.") | ?: throw NoSuchElementException("BOM not found for Item ID $itemId.") | ||||
| // 4. Update Prod Schedule Line fields | |||||
| // 4. Update Prod Schedule Line fields (keep prodQty = total = outputQty * batchNeed) | |||||
| val outputQtyDouble = bom.outputQty?.toDouble() | |||||
| ?: throw IllegalStateException("BOM output quantity is null for Item ID $itemId.") | |||||
| prodScheduleLine.apply { | prodScheduleLine.apply { | ||||
| // Use bom.outputQty, ensuring it's treated as Double for prodQty | |||||
| prodQty = bom.outputQty?.toDouble() | |||||
| ?: throw IllegalStateException("BOM output quantity is null for Item ID $itemId.") | |||||
| prodQty = outputQtyDouble * batchNeed.toLong().coerceAtLeast(0) | |||||
| approverId = approver?.id | approverId = approver?.id | ||||
| } | } | ||||
| @@ -966,7 +966,8 @@ open class ProductionScheduleService( | |||||
| savedItem.refScheduleId = detailedScheduleObj.id; | savedItem.refScheduleId = detailedScheduleObj.id; | ||||
| savedItem.approverId = null; | savedItem.approverId = null; | ||||
| savedItem.estCloseBal = detailedScheduleObj.outputQty; | savedItem.estCloseBal = detailedScheduleObj.outputQty; | ||||
| savedItem.prodQty = detailedScheduleObj.outputQty | |||||
| // prodQty = total production = batchQty (outputQty per batch) * batchNeed | |||||
| savedItem.prodQty = detailedScheduleObj.outputQty * detailedScheduleObj.batchNeed.toInt().coerceAtLeast(0) | |||||
| savedItem.type = "detailed" | savedItem.type = "detailed" | ||||
| savedItem.assignDate = LocalDateTime.now().dayOfMonth.toLong(); | savedItem.assignDate = LocalDateTime.now().dayOfMonth.toLong(); | ||||
| savedItem.weightingRef = detailedScheduleObj.needQty | savedItem.weightingRef = detailedScheduleObj.needQty | ||||