|
@@ -130,19 +130,21 @@ open class StockInLineService( |
|
|
@Transactional |
|
|
@Transactional |
|
|
fun saveInventoryLotLineWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): InventoryLotLine { |
|
|
fun saveInventoryLotLineWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): InventoryLotLine { |
|
|
val inventoryLotLine = InventoryLotLine() |
|
|
val inventoryLotLine = InventoryLotLine() |
|
|
println(request.warehouseId!!) |
|
|
|
|
|
val warehouse = warehouseRepository.findById(request.warehouseId!!).orElseThrow() |
|
|
val warehouse = warehouseRepository.findById(request.warehouseId!!).orElseThrow() |
|
|
val baseItemUom = itemUomRespository.findBaseUnitByItemIdAndBaseUnitIsTrueAndDeletedIsFalse( |
|
|
|
|
|
|
|
|
val stockItemUom = itemUomRespository.findBaseUnitByItemIdAndStockUnitIsTrueAndDeletedIsFalse( |
|
|
itemId = request.itemId |
|
|
itemId = request.itemId |
|
|
) |
|
|
) |
|
|
println(stockInLine.purchaseOrderLine!!.uom!!.id!!) |
|
|
|
|
|
println(request.itemId) |
|
|
|
|
|
|
|
|
val convertedBaseQty = if (stockItemUom != null) { |
|
|
|
|
|
request.acceptedQty * stockItemUom.ratioN!! / stockItemUom.ratioD!! |
|
|
|
|
|
} else { |
|
|
|
|
|
request.acceptedQty |
|
|
|
|
|
} |
|
|
inventoryLotLine.apply { |
|
|
inventoryLotLine.apply { |
|
|
this.inventoryLot = stockInLine.inventoryLot |
|
|
this.inventoryLot = stockInLine.inventoryLot |
|
|
this.warehouse = warehouse |
|
|
this.warehouse = warehouse |
|
|
this.inQty = request.acceptedQty |
|
|
|
|
|
|
|
|
this.inQty = convertedBaseQty |
|
|
this.status = "available" |
|
|
this.status = "available" |
|
|
this.baseUom = baseItemUom |
|
|
|
|
|
|
|
|
this.stockUom = stockItemUom |
|
|
} |
|
|
} |
|
|
val savedInventoryLotLine = inventoryLotLineRepository.saveAndFlush(inventoryLotLine) |
|
|
val savedInventoryLotLine = inventoryLotLineRepository.saveAndFlush(inventoryLotLine) |
|
|
return savedInventoryLotLine |
|
|
return savedInventoryLotLine |
|
|