fix: check released bookings only for active loading allocations

This commit is contained in:
2026-09-16 11:50:30 +08:00
parent 35c6c6ec03
commit de29e639e4
3 changed files with 46 additions and 1 deletions
@@ -4,7 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** SQL-backed hard gate for every loading plan linked to an inbound. */
/** SQL-backed hard gate for loading plans with an active allocation to the inbound. */
@Mapper
public interface LoadingCompletionGateMapper {
@Select("""
@@ -16,6 +16,10 @@ public interface LoadingCompletionGateMapper {
FROM fl_preload_loading_plan_link l
JOIN fl_loading_plan p ON p.id=l.loading_plan_id
WHERE l.tenant_id=#{tenantId} AND l.inbound_id=#{inboundId}
AND EXISTS (
SELECT 1 FROM fl_loading_plan_item i
WHERE i.loading_plan_id=l.loading_plan_id AND i.account_id=l.tenant_id
AND i.inbound_id=l.inbound_id AND i.deleted=0 AND i.package_count>0)
""")
GateSnapshot snapshot(@Param("tenantId") long tenantId, @Param("inboundId") long inboundId);