|
|
|
@@ -1910,8 +1910,8 @@ open class PickOrderService( |
|
|
|
WHERE spl.pickOrderLineId = :pickOrderLineId |
|
|
|
""".trimIndent() |
|
|
|
|
|
|
|
println(" Executing SQL: $checkSql") |
|
|
|
println(" With parameters: pickOrderLineId = $pickOrderLineId") |
|
|
|
//println(" Executing SQL: $checkSql") |
|
|
|
// println(" With parameters: pickOrderLineId = $pickOrderLineId") |
|
|
|
|
|
|
|
val result = jdbcDao.queryForList(checkSql, mapOf("pickOrderLineId" to pickOrderLineId)) |
|
|
|
|
|
|
|
@@ -4456,9 +4456,25 @@ open fun getAllPickOrderLotsWithDetailsHierarchical(userId: Long): Map<String, A |
|
|
|
} |
|
|
|
|
|
|
|
val oldIll = spl.suggestedLotLine |
|
|
|
|
|
|
|
// Load stock out line (if provided) to decide "bind vs split" and compute pickedQty |
|
|
|
val existingSol = if (req.stockOutLineId != null && req.stockOutLineId > 0) { |
|
|
|
stockOutLIneRepository.findById(req.stockOutLineId).orElse(null) |
|
|
|
} else null |
|
|
|
val pickedQty = existingSol?.qty?.let { numToBigDecimal(it as? Number) } ?: zero |
|
|
|
|
|
|
|
// Allow switch to UNAVAILABLE lot, but do NOT move hold/onHold and do NOT alter SOL status. |
|
|
|
if (targetUnavailable) { |
|
|
|
// ✅ Release hold from old suggested lot first (prevents stranded holds when user scans unavailable/expired lot). |
|
|
|
// Release only the remaining qty if some qty has been picked already. |
|
|
|
val qtyToRelease = qtyToHold.subtract(pickedQty).coerceAtLeast(zero) |
|
|
|
if (qtyToRelease > zero && oldIll != null && oldIll.id != null && oldIll.id != newIll.id) { |
|
|
|
val oldHold = oldIll.holdQty ?: zero |
|
|
|
val newOldHold = oldHold.subtract(qtyToRelease).coerceAtLeast(zero) |
|
|
|
oldIll.holdQty = newOldHold |
|
|
|
inventoryLotLineRepository.save(oldIll) |
|
|
|
} |
|
|
|
|
|
|
|
spl.suggestedLotLine = newIll |
|
|
|
suggestPickLotRepository.saveAndFlush(spl) |
|
|
|
|
|
|
|
@@ -4481,12 +4497,7 @@ open fun getAllPickOrderLotsWithDetailsHierarchical(userId: Long): Map<String, A |
|
|
|
errorPosition = null |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
// Load stock out line (if provided) to decide "bind vs split" |
|
|
|
val existingSol = if (req.stockOutLineId != null && req.stockOutLineId > 0) { |
|
|
|
stockOutLIneRepository.findById(req.stockOutLineId).orElse(null) |
|
|
|
} else null |
|
|
|
val pickedQty = existingSol?.qty?.let { numToBigDecimal(it as? Number) } ?: zero |
|
|
|
|
|
|
|
|
|
|
|
// Switch lot rule: |
|
|
|
// - actual pick == 0: replace/bind (no new line) |
|
|
|
|