feat(firstleg): expose loading item tax mode

This commit is contained in:
2026-09-08 17:07:06 +08:00
parent 40fe0ba0e1
commit 78a73a1b0e
7 changed files with 74 additions and 4 deletions
@@ -16,6 +16,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import java.lang.reflect.Method;
import java.lang.reflect.RecordComponent;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import jakarta.validation.constraints.NotNull;
@@ -145,9 +146,15 @@ class LoadingListControllerContractTest {
.doesNotContainKey("internalContainerNo");
assertThat(properties(schemas, "ConfirmedSummary"))
.containsKeys("planId", "containerBookingId", "loadingListNo");
assertThat(properties(schemas, "LoadingItem")).containsKeys(
"itemId", "accountId", "inboundId", "inboundDetailId", "skuCode",
Map<String, Object> loadingItem = properties(schemas, "LoadingItem");
assertThat(loadingItem).containsKeys(
"itemId", "accountId", "customsTaxMode", "taxRefundFlag", "inboundId", "inboundDetailId", "skuCode",
"destinationWarehouse", "productQuantity", "frozenAt");
assertThat(stringMap(loadingItem.get("customsTaxMode")))
.containsEntry("nullable", true)
.containsEntry("enum", List.of("TAX_REFUND", "BUY_DECLARATION"));
assertThat(stringMap(loadingItem.get("taxRefundFlag")))
.containsEntry("nullable", true);
assertThat(properties(schemas, "OperationHistory")).containsKeys(
"historyId", "itemId", "operationId", "actionType", "fromStatus", "toStatus",
"beforeSnapshot", "afterSnapshot", "operatorId", "occurredAt");
@@ -59,6 +59,11 @@ class LoadingListQueryMapperContractTest {
String items = sql("selectItems", Select.class);
assertThat(items)
.contains("i.order_id", "i.order_no", "b.container_no")
.contains("inbound.tax_mode AS customs_tax_mode")
.contains("WHEN 'TAX_REFUND' THEN TRUE")
.contains("WHEN 'BUY_DECLARATION' THEN FALSE")
.contains("ELSE NULL")
.doesNotContain("fl_customs_container_document", "fl_customs_container_document_link")
.contains("b.record_status='ACTIVE'")
.contains("NULLIF(i.pallet_count,0)")
.contains("fl_inbound_weight_result weight")
@@ -5,6 +5,7 @@ import com.baiyue.firstleg.dto.LoadingListDtos.ConfirmedQuery;
import com.baiyue.firstleg.dto.LoadingListDtos.PreloadQuery;
import com.baiyue.firstleg.mapper.LoadingListQueryMapper;
import com.baiyue.firstleg.mapper.LoadingListQueryMapper.AggregateRow;
import com.baiyue.firstleg.mapper.LoadingListQueryMapper.ItemRow;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -96,4 +97,47 @@ class LoadingListRepositoryTest {
var confirmed = repository.preloadDetail(row).summary().readiness();
assertThat(confirmed.readyForPda()).isTrue();
}
@Test
void mapsFrozenCustomsTaxFactsPerInboundAcrossCustomers() {
AggregateRow aggregate = new AggregateRow();
aggregate.setPlanId(41L);
aggregate.setContainerBookingId(61L);
aggregate.setPlanNo("LP-41");
aggregate.setPlanStatus("COMPLETED");
aggregate.setVersion(3);
ItemRow refund = item(101L, 11L, 201L, "IN-REFUND", "TAX_REFUND", true);
ItemRow declaration = item(102L, 12L, 202L, "IN-BUY", "BUY_DECLARATION", false);
ItemRow unknown = item(103L, 12L, 203L, "IN-UNKNOWN", null, null);
when(mapper.selectItems(41L)).thenReturn(List.of(refund, declaration, unknown));
when(mapper.selectHistories(41L)).thenReturn(List.of());
var items = repository.confirmedDetail(aggregate).items();
assertThat(items).extracting(value -> value.inboundCode(), value -> value.accountId(),
value -> value.customsTaxMode(), value -> value.taxRefundFlag())
.containsExactly(
org.assertj.core.groups.Tuple.tuple("IN-REFUND", 11L, "TAX_REFUND", true),
org.assertj.core.groups.Tuple.tuple("IN-BUY", 12L, "BUY_DECLARATION", false),
org.assertj.core.groups.Tuple.tuple("IN-UNKNOWN", 12L, null, null));
}
private static ItemRow item(long itemId, long accountId, long inboundId, String inboundCode,
String customsTaxMode, Boolean taxRefundFlag) {
ItemRow row = new ItemRow();
row.setItemId(itemId);
row.setAccountId(accountId);
row.setCustomerName("customer-" + accountId);
row.setCustomsTaxMode(customsTaxMode);
row.setTaxRefundFlag(taxRefundFlag);
row.setOrderId(300L + inboundId);
row.setOrderNo("ORDER-" + inboundId);
row.setInboundId(inboundId);
row.setInboundDetailId(400L + inboundId);
row.setInboundCode(inboundCode);
row.setPackageCount(1);
row.setLoadSequence(1);
row.setItemVersion(0);
return row;
}
}