fix: count distinct SKU codes across shared pallet inbounds

This commit is contained in:
2026-09-16 10:18:56 +08:00
parent c099b19176
commit a4c659f4c6
3 changed files with 23 additions and 2 deletions
@@ -26,6 +26,26 @@ class DropshipPalletizationServiceTest {
private final DropshipPalletizationService service=new DropshipPalletizationService();
DropshipPalletizationServiceTest(){ ReflectionTestUtils.setField(service,"mapper",mapper); ReflectionTestUtils.setField(service,"documentNumbers",numbers); when(mapper.labelSkus(anyLong(),anyLong())).thenAnswer(call -> java.util.List.of(labelSku())); when(mapper.cartonSkus(anyLong())).thenAnswer(call -> java.util.List.of(cartonSku())); }
@Test void sharedPalletCountsDistinctSkuCodesWithoutMergingInboundDetails(){
when(mapper.inboundCode(1L,30L)).thenReturn("IN-1");
when(mapper.palletsByInbound(1L,30L)).thenReturn(java.util.List.of(pallet()));
CartonRow first=carton(),second=carton(); second.setId(61L); second.setInboundId(31L); second.setBoxCode("BOX-2");
CartonSkuRow sameSku=cartonSku(); sameSku.setInboundDetailId(41L);
CartonSkuRow differentSku=cartonSku(); differentSku.setInboundDetailId(42L); differentSku.setSkuCode("SKU-2");
when(mapper.cartons(20L)).thenReturn(java.util.List.of(first,second));
when(mapper.cartonSkus(61L)).thenReturn(java.util.List.of(sameSku));
var shared=service.inboundPallets(1L,30L).get(0);
assertThat(shared.cartonCount()).isEqualTo(2);
assertThat(shared.skuCount()).isEqualTo(1);
assertThat(shared.items()).hasSize(2);
when(mapper.cartonSkus(61L)).thenReturn(java.util.List.of(sameSku,differentSku));
assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isEqualTo(2);
when(mapper.cartons(20L)).thenReturn(java.util.List.of(first));
assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isEqualTo(1);
when(mapper.cartons(20L)).thenReturn(java.util.List.of());
assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isZero();
}
@Test void reviewCreatesExpectedNumberOfPrintablePalletCodes(){
InboundOrderEntity inbound=dropshipInbound(); when(mapper.insertTask(anyLong(),eq(1L),eq(30L),eq(100L),eq(8))).thenReturn(1);
when(numbers.next("DP")).thenReturn("DP-260911-0001","DP-260911-0002");