diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/SuggestedPickLotService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/SuggestedPickLotService.kt index 6ff09f9..f8f5611 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/SuggestedPickLotService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/SuggestedPickLotService.kt @@ -84,20 +84,26 @@ open class SuggestedPickLotService( pols.forEach { line -> val salesUnit = line.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } val lotLines = availableInventoryLotLines[line.item?.id].orEmpty() - var remainingQty = (line.qty ?: zero).multiply((salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one)) + val ratio = (salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one) + var remainingQty = (line.qty ?: zero).multiply(ratio) + println("remaining1 $remainingQty") val updatedLotLines = mutableListOf() lotLines.forEachIndexed { index, lotLine -> if (remainingQty <= zero) return@forEachIndexed + println("calculateRemainingQtyForInfo(lotLine) ${calculateRemainingQtyForInfo(lotLine)}") val availableQty = calculateRemainingQtyForInfo(lotLine) + .multiply(ratio) .minus(holdQtyMap[lotLine.id] ?: zero) + println("holdQtyMap[lotLine.id] ?: zero ${holdQtyMap[lotLine.id] ?: zero}") if (availableQty <= zero) { updatedLotLines += lotLine return@forEachIndexed } + println("$index : ${lotLine.id}") val inventoryLotLine = lotLine.id?.let { inventoryLotLineService.findById(it).getOrNull() } val originalHoldQty = inventoryLotLine?.holdQty @@ -115,6 +121,7 @@ open class SuggestedPickLotService( } // if still have remainingQty + println("remaining2 $remainingQty") if (remainingQty > zero) { suggestedList += SuggestedPickLot().apply { type = SuggestedPickLotType.PICK_ORDER