use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class MockServer method defineRoutes.
private Router defineRoutes() {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.route(HttpMethod.POST, resourcesPath(INVOICES)).handler(ctx -> handlePostEntry(ctx, Invoice.class, INVOICES));
router.route(HttpMethod.POST, resourcesPath(INVOICE_LINES)).handler(ctx -> handlePostEntry(ctx, InvoiceLine.class, INVOICE_LINES));
router.route(HttpMethod.POST, resourceByValuePath(VOUCHER_NUMBER_START)).handler(this::handlePostVoucherStartValue);
router.route(HttpMethod.POST, resourcesPath(VOUCHERS_STORAGE)).handler(ctx -> handlePostEntry(ctx, Voucher.class, VOUCHERS_STORAGE));
router.route(HttpMethod.POST, resourcesPath(VOUCHER_LINES)).handler(ctx -> handlePostEntry(ctx, VoucherLine.class, VOUCHER_LINES));
router.route(HttpMethod.POST, "/invoice-storage/invoices/:id/documents").handler(this::handlePostInvoiceDocument);
router.route(HttpMethod.POST, resourcesPath(BATCH_VOUCHER_EXPORT_CONFIGS)).handler(ctx -> handlePostEntry(ctx, ExportConfig.class, BATCH_VOUCHER_EXPORT_CONFIGS));
router.route(HttpMethod.POST, "/batch-voucher-storage/export-configurations/:id/credentials").handler(this::handlePostCredentials);
router.route(HttpMethod.POST, resourcesPath(INVOICE_TRANSACTION_SUMMARIES)).handler(this::handlePostInvoiceSummary);
router.route(HttpMethod.POST, resourcesPath(BATCH_GROUPS)).handler(ctx -> handlePost(ctx, BatchGroup.class, BATCH_GROUPS, false));
router.route(HttpMethod.POST, resourcesPath(FINANCE_PAYMENTS)).handler(ctx -> handlePostEntry(ctx, Transaction.class, FINANCE_PAYMENTS));
router.route(HttpMethod.POST, resourcesPath(FINANCE_CREDITS)).handler(ctx -> handlePostEntry(ctx, Transaction.class, FINANCE_CREDITS));
router.route(HttpMethod.POST, resourcesPath(BATCH_VOUCHER_EXPORTS_STORAGE)).handler(ctx -> handlePost(ctx, BatchVoucherExport.class, BATCH_VOUCHER_EXPORTS_STORAGE, false));
router.route(HttpMethod.POST, resourcesPath(FINANCE_PENDING_PAYMENTS)).handler(this::handlePostPendingPayment);
router.route(HttpMethod.POST, resourcesPath(ORDER_INVOICE_RELATIONSHIP)).handler(this::handlePostOrderInvoiceRelations);
router.route(HttpMethod.GET, resourcesPath(INVOICES)).handler(this::handleGetInvoices);
router.route(HttpMethod.GET, resourcesPath(INVOICE_LINES)).handler(this::handleGetInvoiceLines);
router.route(HttpMethod.GET, resourceByIdPath(INVOICES)).handler(this::handleGetInvoiceById);
router.route(HttpMethod.GET, resourcesPath(FOLIO_INVOICE_NUMBER)).handler(this::handleGetFolioInvoiceNumber);
router.route(HttpMethod.GET, resourceByIdPath(INVOICE_LINES)).handler(this::handleGetInvoiceLineById);
router.route(HttpMethod.GET, resourcesPath(INVOICE_LINE_NUMBER)).handler(this::handleGetInvoiceLineNumber);
router.route(HttpMethod.GET, resourceByIdPath(VOUCHER_LINES)).handler(this::handleGetVoucherLineById);
router.route(HttpMethod.GET, resourceByIdPath(VOUCHERS_STORAGE)).handler(this::handleGetVoucherById);
router.route(HttpMethod.GET, resourceByIdPath(COMPOSITE_ORDER)).handler(this::handleGetOrderById);
router.route(HttpMethod.GET, resourceByIdPath(ORDER_LINES)).handler(this::handleGetPoLineById);
router.route(HttpMethod.GET, resourcesPath(ORDER_INVOICE_RELATIONSHIP)).handler(this::handleGetOrderInvoiceRelations);
router.route(HttpMethod.GET, resourcesPath(VOUCHER_NUMBER_START)).handler(this::handleGetSequence);
router.route(HttpMethod.GET, resourcesPath(VOUCHERS_STORAGE)).handler(this::handleGetVouchers);
router.route(HttpMethod.GET, resourcesPath(VOUCHER_LINES)).handler(this::handleGetVoucherLines);
router.route(HttpMethod.GET, resourcesPath(VOUCHER_NUMBER_STORAGE)).handler(this::handleGetVoucherNumber);
router.route(HttpMethod.GET, resourcesPath(FUNDS)).handler(this::handleGetFundRecords);
router.route(HttpMethod.GET, resourcesPath(BUDGETS)).handler(this::handleGetBudgetRecords);
router.route(HttpMethod.GET, resourcesPath(LEDGERS)).handler(this::handleGetLedgerRecords);
router.route(HttpMethod.GET, resourceByIdPath(LEDGERS)).handler(this::handleGetLedgerRecordsById);
router.route(HttpMethod.GET, "/configurations/entries").handler(this::handleConfigurationModuleResponse);
router.route(HttpMethod.GET, "/invoice-storage/invoices/:id/documents").handler(this::handleGetInvoiceDocuments);
router.route(HttpMethod.GET, "/invoice-storage/invoices/:id/documents/:documentId").handler(this::handleGetInvoiceDocumentById);
router.route(HttpMethod.GET, resourcesPath(ACQUISITIONS_MEMBERSHIPS)).handler(this::handleGetAcquisitionsMemberships);
router.route(HttpMethod.GET, resourcesPath(ACQUISITIONS_UNITS)).handler(this::handleGetAcquisitionsUnits);
router.route(HttpMethod.GET, resourcesPath(BATCH_VOUCHER_EXPORT_CONFIGS)).handler(this::handleGetBatchVoucherExportConfigs);
router.route(HttpMethod.GET, "/batch-voucher-storage/export-configurations/:id/credentials").handler(this::handleGetBatchVoucherExportConfigCredentials);
router.route(HttpMethod.GET, resourceByIdPath(BATCH_VOUCHER_EXPORT_CONFIGS)).handler(this::handleGetBatchVoucherExportConfigById);
router.route(HttpMethod.GET, resourcesPath(BATCH_GROUPS)).handler(this::handleGetBatchGroups);
router.route(HttpMethod.GET, resourceByIdPath(BATCH_GROUPS)).handler(this::handleGetBatchGroupById);
router.route(HttpMethod.GET, resourceByIdPath(BATCH_VOUCHER_STORAGE)).handler(this::handleGetBatchVoucherById);
router.route(HttpMethod.GET, resourcesPath(FINANCE_TRANSACTIONS)).handler(this::handleGetFinanceTransactions);
router.route(HttpMethod.GET, "/finance/ledgers/:id/current-fiscal-year").handler(this::handleGetCurrentFiscalYearByLedgerId);
router.route(HttpMethod.GET, resourcesPath(BATCH_VOUCHER_EXPORTS_STORAGE)).handler(this::handleGetBatchVoucherExports);
router.route(HttpMethod.GET, resourceByIdPath(BATCH_VOUCHER_EXPORTS_STORAGE)).handler(this::handleGetBatchVoucherExportsById);
router.get("/organizations-storage/organizations").handler(this::handleGetAccessProviders);
router.get("/organizations-storage/organizations/:id").handler(this::handleGetVendorById);
router.route(HttpMethod.GET, resourceByIdPath(EXPENSE_CLASSES_URL)).handler(this::handleExpenseClassesById);
router.route(HttpMethod.GET, resourcesPath(EXPENSE_CLASSES_URL)).handler(this::handleExpenseClasses);
router.route(HttpMethod.GET, resourcesPath(BUDGET_EXPENSE_CLASSES)).handler(this::handleGetBudgetExpenseClass);
router.route(HttpMethod.GET, resourcesPath(FINANCE_EXCHANGE_RATE)).handler(this::handleGetRateOfExchange);
router.route(HttpMethod.GET, resourceByIdPath(FISCAL_YEARS)).handler(this::handleFiscalYearById);
router.route(HttpMethod.GET, resourcesPath(FISCAL_YEARS)).handler(this::handleFiscalYear);
router.route(HttpMethod.GET, resourceByIdPath(FUNDS)).handler(this::handleFundById);
router.route(HttpMethod.GET, "/finance/funds/:id/budget").handler(this::handleGetBudgetByFundId);
router.route(HttpMethod.GET, "/data-import-profiles/jobProfileSnapshots/:id").handler(this::handleGetJobProfileSnapshotById);
router.route(HttpMethod.DELETE, resourceByIdPath(INVOICES)).handler(ctx -> handleDeleteRequest(ctx, INVOICES));
router.route(HttpMethod.DELETE, resourceByIdPath(INVOICE_LINES)).handler(ctx -> handleDeleteRequest(ctx, INVOICE_LINES));
router.route(HttpMethod.DELETE, resourceByIdPath(VOUCHER_LINES)).handler(ctx -> handleDeleteRequest(ctx, VOUCHER_LINES));
router.route(HttpMethod.DELETE, "/invoice-storage/invoices/:id/documents/:documentId").handler(ctx -> handleDeleteRequest(ctx, INVOICE_DOCUMENTS));
router.route(HttpMethod.DELETE, resourceByIdPath(BATCH_VOUCHER_EXPORT_CONFIGS)).handler(ctx -> handleDeleteRequest(ctx, BATCH_VOUCHER_EXPORT_CONFIGS));
router.route(HttpMethod.DELETE, resourceByIdPath(BATCH_GROUPS)).handler(ctx -> handleDeleteRequest(ctx, BATCH_GROUPS));
router.route(HttpMethod.DELETE, resourceByIdPath(BATCH_VOUCHER_EXPORTS_STORAGE)).handler(ctx -> handleDeleteRequest(ctx, BATCH_VOUCHER_EXPORTS_STORAGE));
router.route(HttpMethod.PUT, resourceByIdPath(INVOICES)).handler(ctx -> handlePutGenericSubObj(ctx, INVOICES));
router.route(HttpMethod.PUT, resourceByIdPath(INVOICE_LINES)).handler(ctx -> handlePutGenericSubObj(ctx, INVOICE_LINES));
router.route(HttpMethod.PUT, resourceByIdPath(VOUCHERS_STORAGE)).handler(ctx -> handlePutGenericSubObj(ctx, VOUCHERS_STORAGE));
router.route(HttpMethod.PUT, resourceByIdPath(VOUCHER_LINES)).handler(ctx -> handlePutGenericSubObj(ctx, VOUCHER_LINES));
router.route(HttpMethod.PUT, resourceByIdPath(ORDER_LINES)).handler(ctx -> handlePutGenericSubObj(ctx, ResourcePathResolver.ORDER_LINES));
router.route(HttpMethod.PUT, resourceByIdPath(BATCH_VOUCHER_EXPORT_CONFIGS)).handler(ctx -> handlePutGenericSubObj(ctx, ResourcePathResolver.BATCH_VOUCHER_EXPORT_CONFIGS));
router.route(HttpMethod.PUT, "/batch-voucher-storage/export-configurations/:id/credentials").handler(ctx -> handlePutGenericSubObj(ctx, BATCH_VOUCHER_EXPORT_CONFIGS_CREDENTIALS));
router.route(HttpMethod.PUT, resourceByIdPath(BATCH_GROUPS)).handler(ctx -> handlePutGenericSubObj(ctx, BATCH_GROUPS));
router.route(HttpMethod.PUT, resourceByIdPath(BATCH_VOUCHER_EXPORTS_STORAGE)).handler(ctx -> handlePutGenericSubObj(ctx, BATCH_VOUCHER_EXPORTS_STORAGE));
return router;
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class InvoiceLinesRetrieveServiceTest method positiveGetInvoiceLinesByChunksTest.
@Test
public void positiveGetInvoiceLinesByChunksTest() throws IOException, ExecutionException, InterruptedException {
RestClient restClient = new RestClient();
InvoiceLinesRetrieveService service = new InvoiceLinesRetrieveService(new InvoiceLineService(restClient));
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
CompletableFuture<List<InvoiceLineCollection>> future = service.getInvoiceLineByChunks(vouchers, new RequestContext(context, okapiHeaders));
List<InvoiceLineCollection> lineCollections = future.get();
Assertions.assertEquals(3, lineCollections.get(0).getInvoiceLines().size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class InvoiceRetrieveServiceTest method positiveGetInvoicesByChunksTest.
@Test
public void positiveGetInvoicesByChunksTest() throws IOException, ExecutionException, InterruptedException {
InvoiceService invoiceService = new BaseInvoiceService(new RestClient(), invoiceLineService, orderService);
InvoiceRetrieveService service = new InvoiceRetrieveService(invoiceService);
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
CompletableFuture<List<InvoiceCollection>> future = service.getInvoicesByChunks(vouchers, new RequestContext(context, okapiHeaders));
List<InvoiceCollection> lineCollections = future.get();
Assertions.assertEquals(3, lineCollections.get(0).getInvoices().size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class VoucherLinesRetrieveServiceTest method positiveTest.
@Test
public void positiveTest() throws IOException, ExecutionException, InterruptedException {
VoucherLinesRetrieveService service = new VoucherLinesRetrieveService(okapiHeaders, context, "en");
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
CompletableFuture<List<VoucherLineCollection>> future = service.getVoucherLinesByChunks(vouchers);
List<VoucherLineCollection> lineCollections = future.get();
Assertions.assertEquals(3, lineCollections.get(0).getVoucherLines().size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class InvoicesApiTest method testTransitionFromOpenToApprovedWithMixedTypesFundDistributionsAndWithoutLockTotal.
@Test
void testTransitionFromOpenToApprovedWithMixedTypesFundDistributionsAndWithoutLockTotal() {
logger.info("=== Test transition invoice to Approved ===");
Invoice reqData = getMockAsJson(OPEN_INVOICE_SAMPLE_PATH).mapTo(Invoice.class);
String id = reqData.getId();
InvoiceLine invoiceLine = getMinimalContentInvoiceLine(id);
invoiceLine.setSubTotal(100d);
invoiceLine.setId(UUID.randomUUID().toString());
FundDistribution percentageDistribution = new FundDistribution().withFundId(EXISTING_FUND_ID).withCode(null).withDistributionType(FundDistribution.DistributionType.PERCENTAGE).withValue(50d);
FundDistribution amountDistribution = new FundDistribution().withFundId(EXISTING_FUND_ID).withDistributionType(AMOUNT).withValue(50d);
invoiceLine.getFundDistributions().addAll(Arrays.asList(percentageDistribution, amountDistribution));
addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine));
reqData.setStatus(Invoice.Status.APPROVED);
String jsonBody = JsonObject.mapFrom(reqData).encode();
Headers headers = prepareHeaders(X_OKAPI_URL, X_OKAPI_TENANT, X_OKAPI_TOKEN, X_OKAPI_USER_ID);
verifyPut(String.format(INVOICE_ID_PATH, id), jsonBody, headers, "", 204);
// Verify that expected number of external calls made
assertThat(getInvoiceRetrievals(), hasSize(1));
assertThat(getInvoiceLineSearches(), hasSize(1));
Invoice updatedInvoice = serverRqRs.get(INVOICES, HttpMethod.PUT).get(0).mapTo(Invoice.class);
List<JsonObject> vouchersCreated = serverRqRs.get(VOUCHERS_STORAGE, HttpMethod.POST);
assertThat(vouchersCreated, notNullValue());
assertThat(vouchersCreated, hasSize(1));
Voucher voucherCreated = vouchersCreated.get(0).mapTo(Voucher.class);
assertThat(voucherCreated.getVoucherNumber(), equalTo(TEST_PREFIX + VOUCHER_NUMBER_VALUE));
assertThat(voucherCreated.getSystemCurrency(), equalTo(DEFAULT_SYSTEM_CURRENCY));
List<JsonObject> fundsSearches = serverRqRs.get(FUNDS, HttpMethod.GET);
List<Fund> funds = fundsSearches.get(0).mapTo(FundCollection.class).getFunds();
verifyTransitionToApproved(voucherCreated, Collections.singletonList(invoiceLine), updatedInvoice, getExpectedVoucherLinesQuantity(funds));
checkVoucherAcqUnitIdsList(voucherCreated, reqData);
}
Aggregations