|
|
|
@@ -144,7 +144,41 @@ open class PickExecutionIssueService( |
|
|
|
val missQty = request.missQty ?: BigDecimal.ZERO |
|
|
|
val badItemQty = request.badItemQty ?: BigDecimal.ZERO |
|
|
|
val badReason = request.badReason ?: "quantity_problem" |
|
|
|
|
|
|
|
val stockOutLines = stockOutLineRepository |
|
|
|
.findByPickOrderLineIdAndInventoryLotLineIdAndDeletedFalse( |
|
|
|
request.pickOrderLineId, |
|
|
|
request.lotId ?: 0L |
|
|
|
) |
|
|
|
|
|
|
|
val currentStatus = stockOutLines.firstOrNull()?.status ?: "" |
|
|
|
|
|
|
|
if (currentStatus.equals("pending", ignoreCase = true) |
|
|
|
&& actualPickQty > BigDecimal.ZERO |
|
|
|
&& missQty == BigDecimal.ZERO |
|
|
|
&& badItemQty == BigDecimal.ZERO |
|
|
|
) { |
|
|
|
return MessageResponse( |
|
|
|
id = null, |
|
|
|
name = "Invalid issue for pending stock out line", |
|
|
|
code = "ERROR", |
|
|
|
type = "pick_execution_issue", |
|
|
|
message = "Cannot submit only actual pick qty when stock out line is pending. Please rescan the lot or use normal pick flow.", |
|
|
|
errorPosition = null |
|
|
|
) |
|
|
|
} |
|
|
|
val lotRemainAvailable = bookQty // 当前 lot 剩余 |
|
|
|
val maxAllowed = requiredQty + lotRemainAvailable |
|
|
|
|
|
|
|
if (actualPickQty > maxAllowed) { |
|
|
|
return MessageResponse( |
|
|
|
id = null, |
|
|
|
name = "Actual pick qty too large", |
|
|
|
code = "ERROR", |
|
|
|
type = "pick_execution_issue", |
|
|
|
message = "Actual pick qty cannot exceed required qty plus lot remaining available.", |
|
|
|
errorPosition = null |
|
|
|
) |
|
|
|
} |
|
|
|
println("=== Quantity Summary ===") |
|
|
|
println(" Required Qty: $requiredQty") |
|
|
|
println(" Actual Pick Qty: $actualPickQty") |
|
|
|
|