fix: settle whole dropship pallets by sku

This commit is contained in:
2026-09-02 00:27:04 +08:00
parent 7e6c7a4b9d
commit fd9a070efc
3 changed files with 63 additions and 7 deletions
@@ -202,6 +202,35 @@ class PdaPickSettlementServiceTest {
&& request.remainingItems().isEmpty()));
}
@Test
void settlesWholeDropshipPalletWithSkuFactsInsteadOfAggregateMeasurementDetail() {
List<LoadingPickItemEntity> items = List.of(
item(11L, 21L, 31L, 41L, 1, 1, "PICKED"),
item(12L, 22L, 31L, 42L, 1, 1, "PICKED"),
item(13L, 23L, 31L, 43L, 1, 1, "PICKED"),
item(14L, 24L, 31L, 44L, 1, 1, "PICKED"));
resolved(items);
when(splits.lockParent(31L)).thenReturn(parent(4));
when(splits.fulfillmentType(10001L, 31L)).thenReturn("ONE_CLICK_DROPSHIP");
when(splits.lockLatestApprovedItemsForInbound(10001L, 31L))
.thenReturn(List.of(new MeasurementItemRow(51L, 61L, 41L, 4)));
when(allocations.lockConfirmed(10001L, 31L))
.thenReturn(List.of(allocation(1L, 1, 501L, 4)));
when(warehouse.settle(eq("internal-token"), any())).thenReturn(ApiResponse.success(
new WarehousePalletLocationClient.SettlementResult(List.of(released(91L, 501L)), List.of())));
writes(0, 4);
service.settle(1L, 9L, "operator");
verify(orderSplits).split(eq("internal-token"), eq(9L),
org.mockito.ArgumentMatchers.argThat(request -> request.lines().size() == 4
&& request.lines().stream().allMatch(line -> line.packageCount() == 1)
&& request.lines().stream().map(OrderFulfillmentSplitClient.QuantityLine::sourceDetailId)
.collect(java.util.stream.Collectors.toSet()).equals(java.util.Set.of(41L, 42L, 43L, 44L))));
verify(splits).updateMeasurementItemForLoaded(10001L, 51L, 4);
verify(splits).markSourceLoaded(10001L, 31L, 4, 9L, 3);
}
@Test
void onlyPureSkippedInboundRestoresCandidate() {
LoadingPickItemEntity item = item(12L, 22L, 32L, 42L, 8, 0, "SKIPPED");