Parcourir la source

stock TRF update

master
kelvin.yau il y a 9 heures
Parent
révision
7d517e0511
1 fichiers modifiés avec 1 ajouts et 27 suppressions
  1. +1
    -27
      src/main/java/com/ffii/fpsms/modules/stock/service/StockTransferRecordService.kt

+ 1
- 27
src/main/java/com/ffii/fpsms/modules/stock/service/StockTransferRecordService.kt Voir le fichier

@@ -94,14 +94,6 @@ open class StockTransferRecordService(
throw IllegalArgumentException("warehouseId is required for stock in")
}

// Step 4: Check if existing InventoryLotLine with same lot and warehouse exists
val existingInventoryLotLine = inventoryLotLineRepository.findByLotNoAndItemIdAndWarehouseId(
lotNo = lotNo,
itemId = itemId,
warehouseId = request.warehouseId
)

// Step 5: Map to StockInRequest
val stockInRequest = StockInRequest(
itemId = itemId,
itemNo = itemCode,
@@ -115,25 +107,7 @@ open class StockTransferRecordService(
warehouseId = request.warehouseId
)

return if (existingInventoryLotLine != null) {
// Update existing InventoryLotLine's inQty
existingInventoryLotLine.apply {
val currentInQty = this.inQty ?: BigDecimal.ZERO
this.inQty = currentInQty + request.transferredQty

// Update status if it was UNAVAILABLE and now has stock
if (this.status == InventoryLotLineStatus.UNAVAILABLE) {
this.status = InventoryLotLineStatus.AVAILABLE
}
}
inventoryLotLineRepository.saveAndFlush(existingInventoryLotLine)

// Create StockIn and StockInLine for record keeping, linking to existing InventoryLotLine
stockInLineService.createStockInForExistingInventoryLotLine(stockInRequest, existingInventoryLotLine)
} else {
// Normal flow: create new InventoryLotLine
stockInLineService.createStockIn(stockInRequest)
}
return stockInLineService.createStockIn(stockInRequest)
}

private fun createStockTransferRecord(


Chargement…
Annuler
Enregistrer