费用提交
This commit is contained in:
+3
-28
@@ -7,8 +7,6 @@ import com.baiyue.lastleg.procurement.entity.*;
|
||||
import com.baiyue.lastleg.procurement.mapper.*;
|
||||
import com.baiyue.lastleg.procurement.repository.ProcurementWorkflowRepository;
|
||||
import com.baiyue.lastleg.service.LastlegDocumentNumberGenerator;
|
||||
import com.baiyue.lastleg.financefee.service.OverseasFeeSourceService;
|
||||
import com.baiyue.lastleg.financefee.entity.OverseasFeeSource;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
@@ -33,7 +31,6 @@ class ProcurementWorkflowPersistenceTest {
|
||||
OverseasProcurementFileMapper files;
|
||||
OverseasProcurementStatusHistoryMapper histories;
|
||||
ProcurementWorkflowRepository repository;
|
||||
OverseasFeeSourceService fees;
|
||||
|
||||
@BeforeEach void setup() throws Exception {
|
||||
var ds=new DriverManagerDataSource("jdbc:h2:mem:"+UUID.randomUUID()+";MODE=MySQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1","sa","");
|
||||
@@ -49,9 +46,7 @@ class ProcurementWorkflowPersistenceTest {
|
||||
histories=session.getMapper(OverseasProcurementStatusHistoryMapper.class);
|
||||
repository=new ProcurementWorkflowRepository(session.getMapper(ProcurementWorkflowMapper.class),orders,files);
|
||||
var numbers=mock(LastlegDocumentNumberGenerator.class);var sequence=new AtomicInteger();when(numbers.next("CK")).thenAnswer(i->"CK-"+sequence.incrementAndGet());
|
||||
fees=mock(OverseasFeeSourceService.class);
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(List.of(fee("ACTIVE","APPROVED")));
|
||||
service=new ProcurementWorkflowService(repository,numbers,new ObjectMapper().findAndRegisterModules(),fees);
|
||||
service=new ProcurementWorkflowService(repository,numbers,new ObjectMapper().findAndRegisterModules());
|
||||
var order=new OverseasProcurementOrder();order.setId(11L);order.setCustomerId("9");order.setOrderNo("CG-1");order.setProductName("采购商品");order.setPurchaseCategory("");order.setPurchaseQuantity(10L);order.setCurrency("USD");order.setStatus("RECEIVING");order.setVersion(0L);order.setInboundQuantity(0L);order.setContactName("buyer");order.setContactPhone("123456789");order.setIdempotencyKey("create");order.setRequestHash("0".repeat(64));orders.insert(order);
|
||||
file(101L,11L,"9","image/jpeg");file(102L,11L,"9","application/pdf");file(103L,12L,"10","image/jpeg");file(104L,11L,"9","image/png");
|
||||
}
|
||||
@@ -131,34 +126,14 @@ class ProcurementWorkflowPersistenceTest {
|
||||
assertThat(service.read("9","CG-1").stockQuantity()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test void outboundRequiresCurrentReviewedReceivablesAndRejectedAttemptsLeaveNoInventoryChanges() {
|
||||
@Test void outboundDoesNotRequireFeeDetailsOrApproval() {
|
||||
tx.execute(s->service.receive("9","CG-1","7",new Receipt(0,"r",10,List.of(101L))));
|
||||
tx.execute(s->service.requestConfirmation("9","CG-1","7",new Command(1,"ask")));
|
||||
tx.execute(s->service.confirm("9","CG-1","8",new Command(2,"ok")));
|
||||
var request=new Outbound(3,"out",3,"TRACK");
|
||||
for(var rows:List.of(List.<OverseasFeeSource>of(),List.of(fee("VOIDED","APPROVED")))) {
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(rows);
|
||||
assertThatThrownBy(()->tx.execute(s->service.outbound("9","CG-1","7",request))).hasMessageContaining("请先添加费用明细");
|
||||
}
|
||||
var payable=fee("ACTIVE","APPROVED");payable.setDirection("PAYABLE");
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(List.of(payable));
|
||||
assertThatThrownBy(()->tx.execute(s->service.outbound("9","CG-1","7",request))).hasMessageContaining("请先添加费用明细");
|
||||
for(String review:List.of("PENDING","REJECTED")) {
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(List.of(fee("ACTIVE","APPROVED"),fee("ACTIVE",review)));
|
||||
assertThatThrownBy(()->tx.execute(s->service.outbound("9","CG-1","7",request))).hasMessageContaining("尚未全部审核通过");
|
||||
}
|
||||
assertThat(service.read("9","CG-1").version()).isEqualTo(3);
|
||||
assertThat(service.read("9","CG-1").reservedQuantity()).isZero();
|
||||
assertThat(service.read("9","CG-1").outbounds()).isEmpty();
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(List.of(fee("ACTIVE","APPROVED"),fee("VOIDED","REJECTED")));
|
||||
var result=tx.execute(s->service.outbound("9","CG-1","7",request));
|
||||
assertThat(result.reservedQuantity()).isEqualTo(3);
|
||||
when(fees.listForBusiness("9","OVERSEAS_PROCUREMENT",11L)).thenReturn(List.of());
|
||||
assertThat(tx.execute(s->service.outbound("9","CG-1","7",request)).version()).isEqualTo(4);
|
||||
}
|
||||
|
||||
private OverseasFeeSource fee(String status,String review) {
|
||||
var fee=new OverseasFeeSource();fee.setDirection("RECEIVABLE");fee.setSourceStatus(status);fee.setReviewStatus(review);return fee;
|
||||
assertThat(result.outbounds()).hasSize(1);
|
||||
}
|
||||
|
||||
private void file(long id,long orderId,String customer,String type) {
|
||||
|
||||
Reference in New Issue
Block a user