|
|
|
@@ -13,7 +13,8 @@ import org.slf4j.Logger |
|
|
|
import org.slf4j.LoggerFactory |
|
|
|
import com.ffii.fpsms.modules.master.entity.ItemsRepository |
|
|
|
import com.ffii.fpsms.modules.stock.entity.Inventory |
|
|
|
import com.ffii.fpsms.modules.stock.entity.InventoryRepository |
|
|
|
import com.ffii.fpsms.modules.stock.entity.InventoryLotLine |
|
|
|
import com.ffii.fpsms.modules.stock.service.InventoryBucketResolver |
|
|
|
|
|
|
|
@Service |
|
|
|
open class ItemUomService( |
|
|
|
@@ -22,7 +23,7 @@ open class ItemUomService( |
|
|
|
val itemUomRespository: ItemUomRespository, |
|
|
|
val currencyService: CurrencyService, |
|
|
|
val itemsRepository: ItemsRepository, |
|
|
|
private val inventoryRepository: InventoryRepository, |
|
|
|
private val inventoryBucketResolver: InventoryBucketResolver, |
|
|
|
) { |
|
|
|
val logger = org.slf4j.LoggerFactory.getLogger(this::class.java) |
|
|
|
|
|
|
|
@@ -84,16 +85,7 @@ open class ItemUomService( |
|
|
|
), |
|
|
|
) |
|
|
|
open fun findInventoryForItemBaseUom(itemId: Long): Inventory? { |
|
|
|
val stockUnitUomId = findStockUnitByItemId(itemId)?.uom?.id |
|
|
|
if (stockUnitUomId != null) { |
|
|
|
inventoryRepository.findByItemIdAndStockUomIdAndDeletedIsFalse(itemId, stockUnitUomId)?.let { |
|
|
|
return it |
|
|
|
} |
|
|
|
inventoryRepository.findFirstByItemIdAndStockUomIdAndDeletedIsFalseOrderByIdAsc(itemId, stockUnitUomId) |
|
|
|
?.let { return it } |
|
|
|
} |
|
|
|
// Last resort only while stockUomId is still null on old rows (pre data patch). |
|
|
|
return inventoryRepository.findFirstByItemIdAndDeletedIsFalseOrderByIdAsc(itemId) |
|
|
|
return inventoryBucketResolver.findInventoryBucket(itemId, null as InventoryLotLine?) |
|
|
|
} |
|
|
|
|
|
|
|
open fun findPickingUnitByItemId(itemId: Long): ItemUom? { |
|
|
|
|