fix(delivery): use frozen relabel destination in SKU details
This commit is contained in:
+2
-1
@@ -1483,7 +1483,8 @@ public class DeliveryTransferService {
|
||||
// Match receipt cargo semantics: stable first SKU carries the physical box once, never per piece.
|
||||
for (var line : returnCartonItems.listCarton(carton.getId())) {
|
||||
cargo.add(new DeliveryResponses.DeliverySku(item.getInboundCode(), delivery.getCustomerName(),
|
||||
carton.getDestinationWarehouseCode(), delivery.getDeliveryAddress(), null, null,
|
||||
relabelCarton ? item.getDestinationWarehouseCode() : carton.getDestinationWarehouseCode(),
|
||||
delivery.getDeliveryAddress(), null, null,
|
||||
line.getSkuCode(), line.getProductNameZh(), !relabelCarton || firstSku ? 1 : 0,
|
||||
relabelCarton && firstSku ? item.getGrossWeightKg() : null,
|
||||
relabelCarton && firstSku ? item.getVolumeCbm() : null, line.getQuantity()));
|
||||
|
||||
+8
-1
@@ -295,6 +295,7 @@ class DeliveryTransferServiceTest {
|
||||
outbound.setOverseasWarehouseId("WH-1"); outbound.setOutboundType("RETURN_OUTBOUND");
|
||||
OutboundPalletItem item = new OutboundPalletItem(); item.setCartonMarks("RC-1");
|
||||
ReturnInventoryCarton carton = returnCarton("RC-1", null); carton.setId(901L);
|
||||
item.setDestinationWarehouseCode("OTHER-SNAPSHOT"); carton.setDestinationWarehouseCode("ORIGINAL-RETURN");
|
||||
ReturnInventoryCartonItem line = new ReturnInventoryCartonItem();
|
||||
line.setSkuCode("SKU-A"); line.setProductNameZh("测试品"); line.setQuantity(3L);
|
||||
when(deliveryOrders.findByNo("TENANT-A", "DL-501")).thenReturn(delivery);
|
||||
@@ -309,6 +310,7 @@ class DeliveryTransferServiceTest {
|
||||
assertEquals("SKU-A", detail.skus().get(0).skuCode());
|
||||
assertEquals(3L, detail.skus().get(0).productQuantity());
|
||||
assertEquals(1, detail.skus().get(0).packageCount());
|
||||
assertEquals("ORIGINAL-RETURN", detail.skus().get(0).destinationWarehouseCode());
|
||||
}
|
||||
|
||||
@org.junit.jupiter.params.ParameterizedTest
|
||||
@@ -321,14 +323,17 @@ class DeliveryTransferServiceTest {
|
||||
delivery.setStatus("WAIT_DELIVERY");
|
||||
OutboundOrder outbound = outbound(301L, null, null, "OUT-301", "relabel-1"); outbound.setOutboundType("RELABEL_OUTBOUND");
|
||||
OutboundPalletItem item = new OutboundPalletItem(); item.setCartonMarks("RC-1"); item.setDestinationWarehouseCode("ABE4");
|
||||
OutboundPalletItem otherDestination = new OutboundPalletItem();
|
||||
otherDestination.setCartonMarks("RC-OTHER"); otherDestination.setDestinationWarehouseCode("ONT8");
|
||||
if (measured) { item.setGrossWeightKg(BigDecimal.ONE); item.setVolumeCbm(new BigDecimal("0.008")); }
|
||||
ReturnInventoryCarton carton = returnCarton("RC-1", null); carton.setId(901L);
|
||||
carton.setWeight(new BigDecimal("99")); // Reading the current carton must not replace the frozen outbound measurement.
|
||||
carton.setDestinationWarehouseCode(measured ? "CHANGED-AFTER-OUTBOUND" : null);
|
||||
var first = new ReturnInventoryCartonItem(); first.setSkuCode("SKU-A"); first.setQuantity(3L);
|
||||
var second = new ReturnInventoryCartonItem(); second.setSkuCode("SKU-B"); second.setQuantity(2L);
|
||||
when(deliveryOrders.findByNo("TENANT-A", "DL-501")).thenReturn(delivery);
|
||||
when(outboundOrders.selectById(301L)).thenReturn(outbound);
|
||||
when(outboundPallets.findByOutbound("TENANT-A", 301L)).thenReturn(List.of(item));
|
||||
when(outboundPallets.findByOutbound("TENANT-A", 301L)).thenReturn(List.of(item, otherDestination));
|
||||
when(returnCartons.findCustomerMark("TENANT-A", "RC-1")).thenReturn(carton);
|
||||
when(returnCartonItems.listCarton(901L)).thenReturn(List.of(first, second));
|
||||
|
||||
@@ -336,6 +341,8 @@ class DeliveryTransferServiceTest {
|
||||
|
||||
assertEquals("客户快照", detail.order().customerName()); assertEquals("仓库快照", detail.order().overseasWarehouseName());
|
||||
assertEquals(2, detail.skus().size()); assertEquals(1, detail.skus().stream().mapToInt(row -> row.packageCount()).sum());
|
||||
assertTrue(detail.skus().stream().allMatch(row -> "ABE4".equals(row.destinationWarehouseCode())));
|
||||
verify(returnCartons, never()).findCustomerMark("TENANT-A", "RC-OTHER");
|
||||
assertEquals(5L, detail.skus().stream().mapToLong(row -> row.productQuantity()).sum());
|
||||
assertEquals(measured ? BigDecimal.ONE : null, detail.skus().get(0).weightKg());
|
||||
assertEquals(measured ? new BigDecimal("0.008") : null, detail.skus().get(0).volumeCbm());
|
||||
|
||||
Reference in New Issue
Block a user