fix(firstleg): align measurement package validation
This commit is contained in:
+46
-1
@@ -376,6 +376,19 @@ class InboundMeasurementServiceTest {
|
||||
verify(orderCargoClient, times(1)).listForCartonLabels("internal-token", 1L, 80L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void detailFallsBackToCustomerNameWhenLegacyCompanyNameIsEmpty() {
|
||||
InboundOrderEntity inbound = inbound("MEASURING");
|
||||
inbound.setCustomerName("柏悦测试客户");
|
||||
inbound.setCompanyName(null);
|
||||
when(repository.findInbound(1L, 10L)).thenReturn(inbound);
|
||||
when(repository.listWeights(1L, 10L)).thenReturn(List.of());
|
||||
|
||||
InboundMeasurementResponses.Detail result = service.detail(1L, 10L);
|
||||
|
||||
assertThat(result.companyName()).isEqualTo("柏悦测试客户");
|
||||
}
|
||||
|
||||
@Test
|
||||
void detailRejectsCargoBatchWhoseOrderOwnershipDoesNotMatchInbound() {
|
||||
InboundOrderEntity inbound = inbound("MEASURE_PENDING");
|
||||
@@ -1167,7 +1180,39 @@ class InboundMeasurementServiceTest {
|
||||
assertThat(inbound.getPalletCount()).isEqualTo(1);
|
||||
assertThat(inbound.getActualVolumeCbm()).isEqualByComparingTo("1.2345");
|
||||
assertThat(inbound.getTotalPackageCount()).isEqualTo(3);
|
||||
verify(inbound, never()).setTotalPackageCount(any());
|
||||
verify(inbound).setTotalPackageCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitUsesLatestOrderDeclarationAndRefreshesStaleInboundPackageTotal() {
|
||||
InboundOrderEntity inbound = inbound("MEASURING");
|
||||
inbound.setTotalPackageCount(20);
|
||||
InboundMeasurementEntity measurement = new InboundMeasurementEntity();
|
||||
measurement.setId(30L);
|
||||
measurement.setStatus("DRAFT");
|
||||
measurement.setVersion(2);
|
||||
measurement.setTotalPackageCount(18);
|
||||
InboundMeasurementItemEntity item = new InboundMeasurementItemEntity();
|
||||
item.setPackageCount(18);
|
||||
InboundWeightResultEntity weight = weight(20L, "197.000", "KG", "CONFIRMED", 1);
|
||||
weight.setGrossWeightKg(new BigDecimal("197.000"));
|
||||
weight.setNetWeightKg(new BigDecimal("181.000"));
|
||||
when(repository.findInbound(1L, 10L)).thenReturn(inbound);
|
||||
when(repository.findMeasurement(1L, 10L, 30L)).thenReturn(measurement);
|
||||
when(repository.listItems(1L, 30L)).thenReturn(List.of(item));
|
||||
when(repository.listWeights(1L, 10L)).thenReturn(List.of(weight));
|
||||
when(repository.updateMeasurement(measurement)).thenReturn(true);
|
||||
when(repository.updateInbound(inbound)).thenReturn(true);
|
||||
when(orderCargoClient.listForCartonLabels("internal-token", 1L, 80L)).thenReturn(
|
||||
ApiResponse.success(List.of(new OrderCargoClient.CargoLabelBinding(
|
||||
80001L, 80L, 1, "测试货物", null, 18, new BigDecimal("60"),
|
||||
new BigDecimal("50"), new BigDecimal("50"), "SHIP-001"))));
|
||||
|
||||
service.submit(1L, 10L, 9L,
|
||||
new InboundMeasurementRequests.SubmitRequest(30L, 2));
|
||||
|
||||
assertThat(inbound.getTotalPackageCount()).isEqualTo(18);
|
||||
assertThat(inbound.getProcessStatus()).isEqualTo("MEASURE_PENDING");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user