fix: carry partial dropship measurements to outbound
This commit is contained in:
+42
-1
@@ -491,6 +491,40 @@ class DeliveryTransferServiceTest {
|
||||
assertEquals(2, order.getValue().getPackageCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oneClickOutboundAllocatesLoadedMetricsBySelectedPackages() {
|
||||
DropshipOutboundCandidate candidate = dropshipCandidate(901L, 1001L, "WH-1", "DP-SPLIT", "SKU-1", 4L);
|
||||
candidate.setSourcePackageCount(4L);
|
||||
candidate.setSourceGrossWeightKg(new BigDecimal("40.000"));
|
||||
candidate.setSourceVolumeWeightKg(new BigDecimal("80.000"));
|
||||
candidate.setSourceVolumeCbm(new BigDecimal("4.0000"));
|
||||
when(dropshipProfiles.lockOutboundCandidate("TENANT-A", 901L, "SKU-1")).thenReturn(candidate);
|
||||
when(dropshipCartons.lockAvailablePhysical("TENANT-A", 1001L, 2L))
|
||||
.thenReturn(List.of(new DropshipCarton(), new DropshipCarton()));
|
||||
InventoryPosition position = new InventoryPosition();
|
||||
position.setId(901L); position.setCustomerId("TENANT-A"); position.setBalanceId(801L);
|
||||
position.setOverseasWarehouseId("WH-1"); position.setPalletId(501L); position.setPalletNo("DP-SPLIT");
|
||||
InventoryBalance balance = new InventoryBalance();
|
||||
balance.setId(801L); balance.setCustomerId("TENANT-A"); balance.setInboundCode("IN-SPLIT");
|
||||
when(inventoryPositions.selectById(901L)).thenReturn(position);
|
||||
when(inventoryBalances.selectById(801L)).thenReturn(balance);
|
||||
|
||||
service.createOneClick("TENANT-A", "U-1", new DeliveryRequests.OneClickOutbound("recipient", List.of(
|
||||
new DeliveryRequests.OneClickItem(901L, 2L, "SKU-1")), null, "split-metrics"));
|
||||
|
||||
ArgumentCaptor<OutboundPalletItem> item = ArgumentCaptor.forClass(OutboundPalletItem.class);
|
||||
verify(outboundPallets).insert(item.capture());
|
||||
assertEquals(new BigDecimal("20.000"), item.getValue().getGrossWeightKg());
|
||||
assertEquals(new BigDecimal("40.000"), item.getValue().getVolumeWeightKg());
|
||||
assertEquals(new BigDecimal("2.0000"), item.getValue().getVolumeCbm());
|
||||
ArgumentCaptor<OutboundOrder> order = ArgumentCaptor.forClass(OutboundOrder.class);
|
||||
verify(outboundOrders).updateById(order.capture());
|
||||
assertEquals(2, order.getValue().getPackageCount());
|
||||
assertEquals(new BigDecimal("20.000"), order.getValue().getGrossWeightKg());
|
||||
assertEquals(new BigDecimal("40.000"), order.getValue().getVolumeWeightKg());
|
||||
assertEquals(new BigDecimal("2.0000"), order.getValue().getVolumeCbm());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oneClickOutboundRejectsSummarySkuWithoutAvailableDropshipCartons() {
|
||||
var generator = org.mockito.Mockito.mock(LastlegOrderNoGenerator.class);
|
||||
@@ -563,6 +597,9 @@ class DeliveryTransferServiceTest {
|
||||
assertEquals("DS-A002", result.get(0).palletNo());
|
||||
assertEquals("SKU-1", result.get(0).skuCode());
|
||||
assertEquals(3L, result.get(0).availablePackages());
|
||||
assertEquals(new BigDecimal("30.000"), result.get(0).grossWeightKg());
|
||||
assertEquals(new BigDecimal("60.000"), result.get(0).volumeWeightKg());
|
||||
assertEquals(new BigDecimal("3.0000"), result.get(0).volumeCbm());
|
||||
verify(dropshipProfiles).listOutboundCandidates("TENANT-A", "WH-1");
|
||||
verify(inventoryPositions, never()).selectById(any());
|
||||
}
|
||||
@@ -981,7 +1018,11 @@ class DeliveryTransferServiceTest {
|
||||
DropshipOutboundCandidate value = new DropshipOutboundCandidate();
|
||||
value.setInventoryPositionId(positionId); value.setProfileId(profileId); value.setWarehousePalletId(501L);
|
||||
value.setOverseasWarehouseId(warehouseId); value.setPalletNo(palletNo); value.setSkuCode(sku);
|
||||
value.setAvailablePackages(packages); return value;
|
||||
value.setAvailablePackages(packages); value.setSourcePackageCount(packages);
|
||||
value.setSourceGrossWeightKg(BigDecimal.valueOf(packages * 10L));
|
||||
value.setSourceVolumeWeightKg(BigDecimal.valueOf(packages * 20L));
|
||||
value.setSourceVolumeCbm(BigDecimal.valueOf(packages));
|
||||
return value;
|
||||
}
|
||||
|
||||
private static DropshipCartonSku cartonSku(String sku, long quantity) {
|
||||
|
||||
Reference in New Issue
Block a user