fix(lastleg): preserve mixed SKU balances when splitting return relabel stock
This commit is contained in:
+34
-1
@@ -102,7 +102,7 @@ class PdaPalletOperationServiceTest {
|
||||
when(relabelItems.selectList(any())).thenReturn(List.of(item));
|
||||
when(returnCartonItems.lockCarton(801L)).thenReturn(List.of(originalLine));
|
||||
when(returnCartonItems.updateById(any(ReturnInventoryCartonItem.class))).thenReturn(1);
|
||||
when(returnCartons.releasePartial(801L, "100", 600L, 70L)).thenReturn(1);
|
||||
when(returnCartons.releasePartial(801L, "100", 600L, 70L, 1)).thenReturn(1);
|
||||
when(returnCartons.insert(any(ReturnInventoryCarton.class))).thenReturn(1);
|
||||
when(returnCartonItems.insert(any(ReturnInventoryCartonItem.class))).thenReturn(1);
|
||||
when(returnBalances.adjustCartonQuantity("100", "88", "SKU-1", 1)).thenReturn(1);
|
||||
@@ -128,6 +128,39 @@ class PdaPalletOperationServiceTest {
|
||||
verifyNoInteractions(mapper);
|
||||
}
|
||||
|
||||
@Test void mixedSkuSplitMovesOnlySelectedSkuAndPreservesOtherSkuOnSource() {
|
||||
RelabelApplication app = new RelabelApplication(); app.setId(600L); app.setCustomerId("100");
|
||||
RelabelItem item = new RelabelItem(); item.setId(701L); item.setSkuCode("SKU-A");
|
||||
item.setReturnCartonId(801L); item.setDestinationFbaWarehouseCode("SCK8");
|
||||
ReturnInventoryCarton original = new ReturnInventoryCarton(); original.setId(801L);
|
||||
original.setCustomerId("100"); original.setOverseasWarehouseId("88"); original.setTotalQuantity(2L);
|
||||
original.setSourceReturnNo("RT-1"); original.setSourceBatchNo("RB-1,RB-2"); original.setPalletCode("OLD");
|
||||
ReturnInventoryCartonItem a = new ReturnInventoryCartonItem(); a.setId(901L); a.setSkuCode("SKU-A"); a.setQuantity(1L);
|
||||
ReturnInventoryCartonItem b = new ReturnInventoryCartonItem(); b.setId(902L); b.setSkuCode("SKU-B"); b.setQuantity(1L);
|
||||
when(relabelItems.selectList(any())).thenReturn(List.of(item));
|
||||
when(returnCartonItems.lockCarton(801L)).thenReturn(List.of(a, b));
|
||||
when(returnCartonItems.deleteById(901L)).thenReturn(1);
|
||||
when(returnCartons.releasePartial(801L, "100", 600L, 1L, 1)).thenReturn(1);
|
||||
when(returnCartons.insert(any(ReturnInventoryCarton.class))).thenReturn(1);
|
||||
when(returnCartonItems.insert(any(ReturnInventoryCartonItem.class))).thenReturn(1);
|
||||
when(returnBalances.adjustCartonQuantity("100", "88", "SKU-A", 0)).thenReturn(1);
|
||||
when(relabelItems.updateById(any(RelabelItem.class))).thenReturn(1);
|
||||
ReflectionTestUtils.invokeMethod(service, "splitReturnRelabelCarton", app, item, original,
|
||||
pallet(30L, "NEW", 88L, 0), 1L);
|
||||
assertEquals(1L, b.getQuantity());
|
||||
verify(returnCartonItems, never()).updateById(b);
|
||||
var moved = ArgumentCaptor.forClass(ReturnInventoryCartonItem.class);
|
||||
verify(returnCartonItems).insert(moved.capture());
|
||||
assertEquals("SKU-A", moved.getValue().getSkuCode());
|
||||
assertEquals(1L, moved.getValue().getQuantity());
|
||||
var target = ArgumentCaptor.forClass(ReturnInventoryCarton.class);
|
||||
verify(returnCartons).insert(target.capture());
|
||||
assertEquals("RT-1", target.getValue().getSourceReturnNo());
|
||||
assertEquals("RB-1,RB-2", target.getValue().getSourceBatchNo());
|
||||
assertEquals("NEW", target.getValue().getPalletCode());
|
||||
verify(returnBalances, never()).adjustCartonQuantity(eq("100"), eq("88"), eq("SKU-B"), anyLong());
|
||||
}
|
||||
|
||||
@Test void resolveReportsMissingOnSitePalletAsNotFound() {
|
||||
when(physical.resolve("MISSING")).thenReturn(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user