| @@ -24,7 +24,7 @@ open class JobOrderBomMaterialService( | |||||
| open fun createJobOrderBomMaterialRequests(joId: Long): List<CreateJobOrderBomMaterialRequest> { | open fun createJobOrderBomMaterialRequests(joId: Long): List<CreateJobOrderBomMaterialRequest> { | ||||
| val zero = BigDecimal.ZERO | val zero = BigDecimal.ZERO | ||||
| val jo = jobOrderRepository.findById(joId).getOrNull() ?: throw NoSuchElementException() | val jo = jobOrderRepository.findById(joId).getOrNull() ?: throw NoSuchElementException() | ||||
| val proportion = (jo.reqQty ?: zero).divide(jo.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val proportion = BigDecimal.ONE //(jo.reqQty ?: zero).divide(jo.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val jobmRequests = jo.bom?.bomMaterials?.map { bm -> | val jobmRequests = jo.bom?.bomMaterials?.map { bm -> | ||||
| val salesUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | val salesUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | ||||
| @@ -14,7 +14,8 @@ interface ProductionScheduleLineRepository : AbstractRepository<ProductionSchedu | |||||
| with prod_prop as ( | with prod_prop as ( | ||||
| select | select | ||||
| psl.id as pslId, | psl.id as pslId, | ||||
| round(coalesce(psl.prodQty, 0) / coalesce(b.outputQty, 1), 5) as proportion | |||||
| -- round(coalesce(psl.prodQty, 0) / coalesce(b.outputQty, 1), 5) as proportion | |||||
| 1 as proportion | |||||
| from production_schedule_line psl | from production_schedule_line psl | ||||
| left join bom b on b.itemId = psl.itemId | left join bom b on b.itemId = psl.itemId | ||||
| where psl.id = :id and b.id is not null | where psl.id = :id and b.id is not null | ||||
| @@ -117,7 +117,8 @@ interface ProductionScheduleRepository : AbstractRepository<ProductionSchedule, | |||||
| with prod_prop as ( | with prod_prop as ( | ||||
| select | select | ||||
| psl.id as pslId, | psl.id as pslId, | ||||
| round(coalesce(psl.prodQty, 0) / coalesce(b.outputQty, 1), 5) as proportion | |||||
| -- round(coalesce(psl.prodQty, 0) / coalesce(b.outputQty, 1), 5) as proportion | |||||
| 1 as proportion | |||||
| from production_schedule ps | from production_schedule ps | ||||
| left join production_schedule_line psl on psl.prodScheduleId = ps.id | left join production_schedule_line psl on psl.prodScheduleId = ps.id | ||||
| left join bom b on b.itemId = psl.itemId | left join bom b on b.itemId = psl.itemId | ||||
| @@ -143,7 +143,7 @@ open class ProductionScheduleService( | |||||
| // BigDecimal.ONE | // BigDecimal.ONE | ||||
| // } | // } | ||||
| val proportion = BigDecimal(line.prodQty).divide(bm.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val proportion = BigDecimal.ONE // BigDecimal(line.prodQty).divide(bm.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val demandQty = bm.qty?.times(proportion) ?: zero | val demandQty = bm.qty?.times(proportion) ?: zero | ||||
| val saleUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | val saleUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | ||||
| @@ -230,7 +230,7 @@ open class ProductionScheduleService( | |||||
| // BigDecimal.ONE | // BigDecimal.ONE | ||||
| // } | // } | ||||
| val proportion = BigDecimal(line.prodQty).divide(bm.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val proportion = BigDecimal.ONE //BigDecimal(line.prodQty).divide(bm.bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val demandQty = bm.qty?.times(proportion) ?: zero | val demandQty = bm.qty?.times(proportion) ?: zero | ||||
| val saleUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | val saleUnit = bm.item?.id?.let { itemUomService.findSalesUnitByItemId(it) } | ||||
| @@ -363,7 +363,7 @@ open class ProductionScheduleService( | |||||
| val prodScheduleLine = request.id.let { productionScheduleLineRepository.findById(it).getOrNull() } ?: throw NoSuchElementException() | val prodScheduleLine = request.id.let { productionScheduleLineRepository.findById(it).getOrNull() } ?: throw NoSuchElementException() | ||||
| val bom = prodScheduleLine.item.id?.let { bomService.findByItemId(it) } | val bom = prodScheduleLine.item.id?.let { bomService.findByItemId(it) } | ||||
| val approver = SecurityUtils.getUser().getOrNull() | val approver = SecurityUtils.getUser().getOrNull() | ||||
| val proportion = request.demandQty.divide(bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val proportion = BigDecimal.ONE // request.demandQty.divide(bom?.outputQty ?: BigDecimal.ONE, 5, RoundingMode.HALF_UP) | |||||
| val isSameQty = request.demandQty.equals(prodScheduleLine.prodQty) | val isSameQty = request.demandQty.equals(prodScheduleLine.prodQty) | ||||
| // Update Prod Schedule Type | // Update Prod Schedule Type | ||||
| @@ -445,7 +445,7 @@ open class PickOrderService( | |||||
| val salesUnit = inventoryLotLine?.inventoryLot?.item?.id?.let { _itemId -> | val salesUnit = inventoryLotLine?.inventoryLot?.item?.id?.let { _itemId -> | ||||
| itemUomService.findSalesUnitByItemId(_itemId) | itemUomService.findSalesUnitByItemId(_itemId) | ||||
| } | } | ||||
| val ratio = (salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one) | |||||
| val ratio = BigDecimal.ONE //(salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one) | |||||
| val remainingQty = (inventoryLotLine?.inQty ?: zero) | val remainingQty = (inventoryLotLine?.inQty ?: zero) | ||||
| .minus(inventoryLotLine?.outQty ?: zero) | .minus(inventoryLotLine?.outQty ?: zero) | ||||
| @@ -373,7 +373,7 @@ open class StockInLineService( | |||||
| val purchaseItemUom = itemUomRespository.findByItemIdAndPurchaseUnitIsTrueAndDeletedIsFalse(request.itemId) | val purchaseItemUom = itemUomRespository.findByItemIdAndPurchaseUnitIsTrueAndDeletedIsFalse(request.itemId) | ||||
| val stockItemUom = itemUomRespository.findByItemIdAndStockUnitIsTrueAndDeletedIsFalse(request.itemId) | val stockItemUom = itemUomRespository.findByItemIdAndStockUnitIsTrueAndDeletedIsFalse(request.itemId) | ||||
| val ratio = if (stockItemUom != null && purchaseItemUom != null) { | val ratio = if (stockItemUom != null && purchaseItemUom != null) { | ||||
| (purchaseItemUom.ratioN!! / purchaseItemUom.ratioD!!) / (stockItemUom.ratioN!! / stockItemUom.ratioD!!) | |||||
| BigDecimal.ONE // (purchaseItemUom.ratioN!! / purchaseItemUom.ratioD!!) / (stockItemUom.ratioN!! / stockItemUom.ratioD!!) | |||||
| } else { | } else { | ||||
| BigDecimal.ONE | BigDecimal.ONE | ||||
| } | } | ||||
| @@ -142,7 +142,7 @@ fun handleQc(stockOutLine: StockOutLine, request: UpdateStockOutLineRequest): Li | |||||
| val one = BigDecimal.ONE | val one = BigDecimal.ONE | ||||
| val targetLotLine = inventoryLotLineRepository.findById(request.inventoryLotLineId!!).orElseThrow() | val targetLotLine = inventoryLotLineRepository.findById(request.inventoryLotLineId!!).orElseThrow() | ||||
| val salesUnit = inventoryLotLine?.inventoryLot?.item?.id?.let {_itemId -> itemUomRespository.findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(_itemId) } | val salesUnit = inventoryLotLine?.inventoryLot?.item?.id?.let {_itemId -> itemUomRespository.findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(_itemId) } | ||||
| val ratio = (salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one).toDouble() | |||||
| val ratio = 1.0 //(salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one).toDouble() | |||||
| val targetLotLineEntry = targetLotLine.apply { | val targetLotLineEntry = targetLotLine.apply { | ||||
| this.outQty = (this.outQty?: BigDecimal.ZERO) + (request.qty.div(ratio)).toBigDecimal() | this.outQty = (this.outQty?: BigDecimal.ZERO) + (request.qty.div(ratio)).toBigDecimal() | ||||