|
|
|
@@ -25,7 +25,7 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long |
|
|
|
* - Recomputes [InventoryLotLine.status] in SQL (same rules as [InventoryLotLineService.deriveInventoryLotLineStatus]). |
|
|
|
* - Bumps version in SQL so no stale JPA save is needed on this row afterward. |
|
|
|
*/ |
|
|
|
/* |
|
|
|
|
|
|
|
@Modifying(clearAutomatically = true, flushAutomatically = true) |
|
|
|
@Transactional |
|
|
|
@Query( |
|
|
|
@@ -52,7 +52,7 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long |
|
|
|
@Param("delta") delta: BigDecimal, |
|
|
|
@Param("expectedVersion") expectedVersion: Int, |
|
|
|
): Int |
|
|
|
*/ |
|
|
|
|
|
|
|
fun findByIdAndDeletedIsFalse(id: Serializable): InventoryLotLine; |
|
|
|
|
|
|
|
fun findInventoryLotLineInfoByInventoryLotItemIdIn(ids: List<Serializable>): List<InventoryLotLineInfo> |
|
|
|
@@ -172,15 +172,30 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long |
|
|
|
""") |
|
|
|
fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Long |
|
|
|
|
|
|
|
@EntityGraph( |
|
|
|
type = EntityGraph.EntityGraphType.FETCH, |
|
|
|
attributePaths = ["inventoryLot", "inventoryLot.item", "warehouse"] |
|
|
|
) |
|
|
|
@Query(""" |
|
|
|
SELECT ill FROM InventoryLotLine ill |
|
|
|
JOIN ill.inventoryLot il |
|
|
|
JOIN il.item i |
|
|
|
WHERE il.expiryDate < :today |
|
|
|
AND coalesce(ill.inQty, 0) <> coalesce(ill.outQty, 0) |
|
|
|
AND ill.deleted = false |
|
|
|
AND (:expiryDate IS NULL OR il.expiryDate = :expiryDate) |
|
|
|
AND (:itemCode IS NULL OR LOWER(i.code) LIKE LOWER(CONCAT('%', :itemCode, '%'))) |
|
|
|
AND (:itemName IS NULL OR LOWER(i.name) LIKE LOWER(CONCAT('%', :itemName, '%'))) |
|
|
|
AND coalesce(ill.inQty, 0) <> coalesce(ill.outQty, 0) |
|
|
|
AND ill.deleted = false |
|
|
|
AND il.deleted = false |
|
|
|
AND i.deleted = false |
|
|
|
ORDER BY il.expiryDate ASC |
|
|
|
""") |
|
|
|
fun findExpiredItems(@Param("today") today: LocalDate): List<InventoryLotLine> |
|
|
|
fun findExpiredItems( |
|
|
|
@Param("today") today: LocalDate, |
|
|
|
@Param("expiryDate") expiryDate: LocalDate?, |
|
|
|
@Param("itemCode") itemCode: String?, |
|
|
|
@Param("itemName") itemName: String?, |
|
|
|
): List<InventoryLotLine> |
|
|
|
|
|
|
|
/** |
|
|
|
* Same business key as transfer merge target lookup; restricted to [status] (e.g. AVAILABLE). |
|
|
|
|