fix(lastleg): resolve transfer storage rent by inbound association

This commit is contained in:
2026-10-26 19:58:07 +08:00
parent 3e0d8d6c88
commit 00616d5930
4 changed files with 24 additions and 2 deletions
@@ -56,6 +56,21 @@ class StorageRentSourceResolverTest {
assertThat(plan.allocations().get(0).quantity()).isEqualByComparingTo("4");assertThat(plan.amount()).isEqualByComparingTo("0.96");
}
/** 转运尾程单与入库单不同号仍能预校验;错入库关联和缺失关联必须拒绝。 */
@Test void transferUsesItsInboundAssociationInsteadOfTailOrderIdentity(){
item.setOrderId(171L);item.setSourceBusinessType("WAREHOUSE_TRANSFER");item.setSourceBusinessNo("ZY-1");
var source=new StorageRentBusinessSource();source.setId(81L);source.setBusinessNo("ZY-1");
source.setLastlegOrderId(171L);source.setInboundOrderId(91L);
when(repository.transfer("101","ZY-1")).thenReturn(source);
var plan=service.resolve("9",request,at);
assertThat(plan.owner().businessNo()).isEqualTo("ZY-1");assertThat(plan.owner().orderId()).isEqualTo(171L);
assertThat(plan.allocations()).hasSize(1);assertThat(plan.allocations().get(0).quantity()).isEqualByComparingTo("4");
source.setInboundOrderId(92L);
assertThatThrownBy(()->service.resolve("9",request,at)).hasMessageContaining("业务单据关联的入库订单");
source.setInboundOrderId(null);
assertThatThrownBy(()->service.resolve("9",request,at)).hasMessageContaining("缺少原入库关联");
}
/** 当前客户覆盖默认价;同一预占消费保存价,余货下次预占读新价且库龄不变。 */
@Test void currentCustomerPricingAndSavedSnapshotKeepOriginalAge(){
var first=customPricing("USD",1,"2","5");when(pricing.current("101")).thenReturn(first);