费用提交

This commit is contained in:
2026-10-26 13:41:43 +08:00
parent 0fe1d10566
commit 761fe3686e
171 changed files with 8750 additions and 386 deletions
@@ -48,22 +48,22 @@ class DispatchDeliveryFeesTest {
}
/** 无引用时不强制Finance可用,已有外接约定组禁止新增派送应收。 */
@Test void ordinaryNeedsPositiveFeeAndExternalQuoteDoesNotWaiveOtherCargo() {
@Test void ordinaryAllowsLaterManualFeeAndOldReceivableInputIsRejected() {
var row=cargo(1,"101","ONT8",51,2);var group=grouping.groups(context(List.of(row),false)).get(0);
var input=input(group,List.of(),List.of());
assertNull(service.coverage(group,input,"OP",ordinary()));verifyNoInteractions(finance);
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.validate(group,input,null,ordinary()));
service.validate(group,input(group,List.of(),List.of(fee("RECEIVABLE"))),null,ordinary());
service.validate(group,input,null,ordinary());
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.validate(group,input(group,List.of(),List.of(fee("RECEIVABLE"))),null,ordinary()));
var quote=new FleetBookingFreight.Quote("BOOK-1",1,"INC-1","IN-1","客户101","FBA:ONT8","USD",BigDecimal.ZERO,BigDecimal.ONE,"单",BigDecimal.ZERO);
var allExternal=new FleetBookingFreight.Preview("freight",false,List.of(quote),List.of());
service.validate(group,input,null,allExternal);
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.validate(group,input(group,List.of(),List.of(fee("RECEIVABLE"))),null,allExternal));
var mixed=grouping.groups(context(List.of(row,cargo(2,"101","ONT8",51,3)),false)).get(0);
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.validate(mixed,input(mixed,List.of(),List.of()),null,allExternal));
service.validate(mixed,input(mixed,List.of(),List.of()),null,allExternal);
}
/** 正数报价发布到自己的客户目的地,零约定仅保存商业操作不造零费用。 */
@Test void zeroAgreementRecordsFactAndPositiveFeeUsesOwnDelivery() {
@Test void zeroAndPositiveQuotesKeepFactsWithoutGeneratingReceivables() {
var row=cargo(1,"101","ONT8",51,2);var context=context(List.of(row),false);var group=grouping.groups(context).get(0);
var delivery=new DeliveryOrder();delivery.setId(81L);delivery.setDeliveryNo("DL-101");delivery.setCustomerId("101");delivery.setOverseasWarehouseId("1001");
var zero=new FleetBookingFreight.Quote("BOOK-ZERO",1,"INC-1","IN-1","客户101","FBA:ONT8","USD",BigDecimal.ZERO,BigDecimal.ONE,"单",BigDecimal.ZERO);
@@ -71,9 +71,7 @@ class DispatchDeliveryFeesTest {
verify(repository).operation(any());verifyNoInteractions(sources);
var positive=new FleetBookingFreight.Quote("BOOK-POSITIVE",1,"INC-1","IN-1","客户101","FBA:ONT8","USD",BigDecimal.TEN,BigDecimal.ONE,"单",BigDecimal.TEN);
service.publish(context,group,input(group,List.of(),List.of()),delivery,null,new FleetBookingFreight.Preview("freight",false,List.of(positive),List.of()),"OP","ARR-1");
var saved=ArgumentCaptor.forClass(OverseasFeeSourceDtos.SaveRequest.class);verify(sources).publishApproved(eq("OP"),anyString(),saved.capture());
assertEquals("101",saved.getValue().customerId());assertEquals(81L,saved.getValue().businessId());assertEquals("DL-101",saved.getValue().businessNo());
assertEquals(BigDecimal.TEN,saved.getValue().amount());
verify(repository,times(2)).operation(any()); verifyNoInteractions(sources);
}
/** 合托两票一笔原费只能覆盖对应来源,不得免掉另一票新增应收。 */
@@ -88,7 +86,7 @@ class DispatchDeliveryFeesTest {
var evidence=service.coverage(group,input,"OP",ordinary());
assertEquals(2,evidence.cargo().size());
verify(finance).sources("offline-test-token",new FinanceFeeCoverageClient.Query(101L,List.of(501L,502L)));
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.validate(group,input,evidence,ordinary()));
service.validate(group,input,evidence,ordinary());
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->service.coverage(group,
input(group,List.of(input.feeCoverage().get(0),input.feeCoverage().get(0)),List.of()),"OP",ordinary()));
}
@@ -102,7 +100,7 @@ class DispatchDeliveryFeesTest {
var group=grouping.groups(context).get(0);
var delivery=new DeliveryOrder();delivery.setId(81L);delivery.setDeliveryNo("DL-101");
delivery.setCustomerId("101");delivery.setOverseasWarehouseId("1001");
service.publish(context,group,input(group,List.of(),List.of(fee("RECEIVABLE"))),delivery,null,ordinary(),"OP","ARR-RELABEL");
service.publish(context,group,input(group,List.of(),List.of(fee("PAYABLE"))),delivery,null,ordinary(),"OP","ARR-RELABEL");
var saved=ArgumentCaptor.forClass(OverseasFeeSourceDtos.SaveRequest.class);
verify(sources).publishApproved(eq("OP"),anyString(),saved.capture());
assertEquals("DELIVERY_ORDER",saved.getValue().businessType());