Search in sources :

Example 1 with INVOICES

use of org.folio.invoices.utils.ResourcePathResolver.INVOICES in project mod-invoice by folio-org.

the class InvoiceHelper method getInvoices.

/**
 * Gets list of invoice
 *
 * @param limit Limit the number of elements returned in the response
 * @param offset Skip over a number of elements by specifying an offset value for the query
 * @param query A query expressed as a CQL string using valid searchable fields
 * @return completable future with {@link InvoiceCollection} on success or an exception if processing fails
 */
public CompletableFuture<InvoiceCollection> getInvoices(int limit, int offset, String query) {
    CompletableFuture<InvoiceCollection> future = new FolioVertxCompletableFuture<>(ctx);
    RequestContext requestContext = new RequestContext(ctx, okapiHeaders);
    try {
        buildGetInvoicesQuery(query).thenCompose(getInvoicesQuery -> invoiceService.getInvoices(getInvoicesQuery, offset, limit, requestContext)).thenCompose(invoiceCollection -> invoiceService.updateInvoicesTotals(invoiceCollection, requestContext).thenAccept(v -> {
            logger.info("Successfully retrieved invoices: {}", invoiceCollection);
            future.complete(invoiceCollection);
        })).exceptionally(t -> {
            logger.error("Error getting invoices", t);
            future.completeExceptionally(t);
            return null;
        });
    } catch (Exception e) {
        future.completeExceptionally(e);
    }
    return future;
}
Also used : INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) FolioVertxCompletableFuture.completedFuture(org.folio.completablefuture.FolioVertxCompletableFuture.completedFuture) ORG_IS_NOT_VENDOR(org.folio.invoices.utils.ErrorCodes.ORG_IS_NOT_VENDOR) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) InvoiceWorkflowDataHolder(org.folio.models.InvoiceWorkflowDataHolder) StringUtils(org.apache.commons.lang3.StringUtils) Context(io.vertx.core.Context) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) HttpException(org.folio.invoices.rest.exceptions.HttpException) InvoiceService(org.folio.services.invoice.InvoiceService) ExpenseClass(org.folio.rest.acq.model.finance.ExpenseClass) Voucher(org.folio.rest.jaxrs.model.Voucher) AdjustmentsService(org.folio.services.adjusment.AdjustmentsService) VoucherCommandService(org.folio.services.voucher.VoucherCommandService) Collectors.toMap(java.util.stream.Collectors.toMap) Pair(org.apache.commons.lang3.tuple.Pair) InvoicePaymentService(org.folio.services.invoice.InvoicePaymentService) HelperUtils.isPostApproval(org.folio.invoices.utils.HelperUtils.isPostApproval) Map(java.util.Map) ListUtils(org.apache.commons.collections4.ListUtils) InvoiceWorkflowDataHolderBuilder(org.folio.InvoiceWorkflowDataHolderBuilder) CurrentFiscalYearService(org.folio.services.finance.fiscalyear.CurrentFiscalYearService) JsonObject(io.vertx.core.json.JsonObject) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) UserPermissionsUtil.verifyUserHasManagePermission(org.folio.utils.UserPermissionsUtil.verifyUserHasManagePermission) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ExpenseClassRetrieveService(org.folio.services.finance.expence.ExpenseClassRetrieveService) BudgetExpenseClassService(org.folio.services.finance.budget.BudgetExpenseClassService) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) VendorRetrieveService(org.folio.services.VendorRetrieveService) Collection(java.util.Collection) InvoiceValidator(org.folio.services.validator.InvoiceValidator) Money(org.javamoney.moneta.Money) VOUCHER_NUMBER_PREFIX_CONFIG_QUERY(org.folio.services.voucher.VoucherCommandService.VOUCHER_NUMBER_PREFIX_CONFIG_QUERY) ConversionQuery(javax.money.convert.ConversionQuery) FOLIO_INVOICE_NUMBER(org.folio.invoices.utils.ResourcePathResolver.FOLIO_INVOICE_NUMBER) InvoiceRestrictionsUtil(org.folio.invoices.utils.InvoiceRestrictionsUtil) HelperUtils.getHttpClient(org.folio.invoices.utils.HelperUtils.getHttpClient) Fund(org.folio.rest.acq.model.finance.Fund) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) SequenceNumber(org.folio.rest.jaxrs.model.SequenceNumber) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) UPDATE(org.folio.invoices.utils.ProtectedOperationType.UPDATE) UserPermissionsUtil.verifyUserHasAssignPermission(org.folio.utils.UserPermissionsUtil.verifyUserHasAssignPermission) HelperUtils.getFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getFundDistributionAmount) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) ExchangeRateProvider(javax.money.convert.ExchangeRateProvider) PendingPaymentWorkflowService(org.folio.services.finance.transaction.PendingPaymentWorkflowService) InvoiceCancelService(org.folio.services.invoice.InvoiceCancelService) Organization(org.folio.rest.acq.model.Organization) Adjustment(org.folio.rest.jaxrs.model.Adjustment) Monetary.getDefaultRounding(javax.money.Monetary.getDefaultRounding) Optional(java.util.Optional) FundExtNoExpenseClassExtNoPair(org.folio.models.FundExtNoExpenseClassExtNoPair) Parameter(org.folio.rest.jaxrs.model.Parameter) Objects.nonNull(java.util.Objects.nonNull) MonetaryAmount(javax.money.MonetaryAmount) Invoice(org.folio.rest.jaxrs.model.Invoice) HelperUtils(org.folio.invoices.utils.HelperUtils) EncumbranceService(org.folio.services.finance.transaction.EncumbranceService) CurrencyConversion(javax.money.convert.CurrencyConversion) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HelperUtils.combineCqlExpressions(org.folio.invoices.utils.HelperUtils.combineCqlExpressions) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture) Transaction(org.folio.rest.acq.model.finance.Transaction) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) FundService(org.folio.services.finance.FundService) SpringContextUtil(org.folio.spring.SpringContextUtil) HelperUtils.getAdjustmentFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getAdjustmentFundDistributionAmount) CompletableFuture.allOf(java.util.concurrent.CompletableFuture.allOf) RequestContext(org.folio.rest.core.models.RequestContext) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) ORG_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.ORG_NOT_FOUND) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) ResourcePathResolver.resourcesPath(org.folio.invoices.utils.ResourcePathResolver.resourcesPath) VoucherRetrieveService(org.folio.services.voucher.VoucherRetrieveService) Vertx(io.vertx.core.Vertx) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) Error(org.folio.rest.jaxrs.model.Error) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) INVALID_INVOICE_TRANSITION_ON_PAID_STATUS(org.folio.invoices.utils.ErrorCodes.INVALID_INVOICE_TRANSITION_ON_PAID_STATUS) HelperUtils.calculateVoucherLineAmount(org.folio.invoices.utils.HelperUtils.calculateVoucherLineAmount) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) ConfigurationService(org.folio.services.configuration.ConfigurationService) ProtectedOperationType(org.folio.invoices.utils.ProtectedOperationType) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) RequestContext(org.folio.rest.core.models.RequestContext) HttpException(org.folio.invoices.rest.exceptions.HttpException) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture)

Example 2 with INVOICES

use of org.folio.invoices.utils.ResourcePathResolver.INVOICES in project mod-invoice by folio-org.

the class InvoicesApiTest method testUpdateValidInvoiceTransitionToPaidReleaseEncumbranceTrue.

@Test
void testUpdateValidInvoiceTransitionToPaidReleaseEncumbranceTrue() {
    logger.info("=== Test transition invoice to paid and releaseEncumbrance true for all invoice lines ===");
    List<InvoiceLine> invoiceLines = new ArrayList<>();
    List<CompositePoLine> poLines = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        invoiceLines.add(getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class));
        poLines.add(getMockAsJson(String.format("%s%s.json", PO_LINE_MOCK_DATA_PATH, EXISTENT_PO_LINE_ID)).mapTo(CompositePoLine.class));
    }
    Invoice reqData = getMockAsJson(APPROVED_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withStatus(Invoice.Status.PAID);
    String id = reqData.getId();
    for (int i = 0; i < 3; i++) {
        InvoiceLine invoiceLine = invoiceLines.get(i);
        invoiceLine.setId(UUID.randomUUID().toString());
        invoiceLine.setInvoiceId(reqData.getId());
        String poLineId = UUID.randomUUID().toString();
        invoiceLine.setPoLineId(poLineId);
        poLines.get(i).setId(poLineId);
    }
    invoiceLines.forEach(line -> addMockEntry(INVOICE_LINES, JsonObject.mapFrom(line)));
    poLines.forEach(line -> addMockEntry(ORDER_LINES, JsonObject.mapFrom(line)));
    prepareMockVoucher(id);
    verifyPut(String.format(INVOICE_ID_PATH, id), JsonObject.mapFrom(reqData), "", 204);
    assertThat(getRqRsEntries(HttpMethod.PUT, INVOICES).get(0).getString(STATUS), is(Invoice.Status.PAID.value()));
    assertThat(getRqRsEntries(HttpMethod.GET, INVOICE_LINES), hasSize(1));
    assertThat(getRqRsEntries(HttpMethod.GET, INVOICE_LINES).get(0).mapTo(InvoiceLineCollection.class).getTotalRecords(), equalTo(3));
    assertThat(getRqRsEntries(HttpMethod.PUT, ORDER_LINES), hasSize(3));
    getRqRsEntries(HttpMethod.PUT, ORDER_LINES).stream().map(entries -> entries.mapTo(CompositePoLine.class)).forEach(compositePoLine -> assertThat(compositePoLine.getPaymentStatus(), equalTo(CompositePoLine.PaymentStatus.FULLY_PAID)));
    assertThatVoucherPaid();
    List<JsonObject> invoiceLinesUpdates = serverRqRs.get(INVOICE_LINES, HttpMethod.PUT);
    List<InvoiceLine> lines = invoiceLinesUpdates.stream().map(entry -> entry.mapTo(InvoiceLine.class)).collect(toList());
    assertThat(lines, everyItem(hasProperty("invoiceLineStatus", is(InvoiceLine.InvoiceLineStatus.PAID))));
    assertThat(getRqRsEntries(HttpMethod.GET, FINANCE_TRANSACTIONS), hasSize(2));
    assertThat(getRqRsEntries(HttpMethod.POST, FINANCE_PAYMENTS), hasSize(5));
    assertThat(getRqRsEntries(HttpMethod.POST, FINANCE_CREDITS), hasSize(0));
    checkCreditsPayments(reqData, invoiceLines);
}
Also used : ORDER_LINES(org.folio.invoices.utils.ResourcePathResolver.ORDER_LINES) Arrays(java.util.Arrays) HelperUtils.getNoAcqUnitCQL(org.folio.invoices.utils.HelperUtils.getNoAcqUnitCQL) VOUCHERS_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHERS_STORAGE) PROTECTED_AND_MODIFIED_FIELDS(org.folio.rest.impl.InvoicesImpl.PROTECTED_AND_MODIFIED_FIELDS) Disabled(org.junit.jupiter.api.Disabled) StringUtils(org.apache.commons.lang3.StringUtils) INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH) MockServer.getInvoiceLineSearches(org.folio.rest.impl.MockServer.getInvoiceLineSearches) BigDecimal(java.math.BigDecimal) Voucher(org.folio.rest.jaxrs.model.Voucher) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary) Is.is(org.hamcrest.core.Is.is) JsonObject(io.vertx.core.json.JsonObject) VOUCHERS_LIST_PATH(org.folio.rest.impl.VouchersApiTest.VOUCHERS_LIST_PATH) Errors(org.folio.rest.jaxrs.model.Errors) Budget(org.folio.rest.acq.model.finance.Budget) Awaitility.await(org.awaitility.Awaitility.await) Status(org.folio.rest.jaxrs.model.Invoice.Status) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) ACQUISITIONS_UNIT_IDS(org.folio.rest.impl.ProtectionHelper.ACQUISITIONS_UNIT_IDS) FOLIO_INVOICE_NUMBER(org.folio.invoices.utils.ResourcePathResolver.FOLIO_INVOICE_NUMBER) Ledger(org.folio.rest.acq.model.finance.Ledger) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Fund(org.folio.rest.acq.model.finance.Fund) FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.FUND_DISTRIBUTIONS_NOT_PRESENT) VOUCHER_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.VOUCHER_UPDATE_FAILURE) FINANCE_TRANSACTIONS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_TRANSACTIONS) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) HelperUtils.calculateVoucherAmount(org.folio.invoices.utils.HelperUtils.calculateVoucherAmount) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Adjustment(org.folio.rest.jaxrs.model.Adjustment) PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) FISCAL_YEAR_ID(org.folio.rest.impl.MockServer.FISCAL_YEAR_ID) Invoice(org.folio.rest.jaxrs.model.Invoice) BUDGETS(org.folio.invoices.utils.ResourcePathResolver.BUDGETS) HelperUtils.convertToDoubleWithRounding(org.folio.invoices.utils.HelperUtils.convertToDoubleWithRounding) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) BUDGET_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.BUDGET_NOT_FOUND) Transaction(org.folio.rest.acq.model.finance.Transaction) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) HelperUtils.getAdjustmentFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getAdjustmentFundDistributionAmount) MAX_IDS_FOR_GET_RQ(org.folio.rest.RestConstants.MAX_IDS_FOR_GET_RQ) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) HelperUtils.calculateInvoiceLineTotals(org.folio.invoices.utils.HelperUtils.calculateInvoiceLineTotals) MockServer.getInvoiceRetrievals(org.folio.rest.impl.MockServer.getInvoiceRetrievals) FINANCE_CREDITS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_CREDITS) InvoiceProtectedFields(org.folio.invoices.utils.InvoiceProtectedFields) Matchers.hasSize(org.hamcrest.Matchers.hasSize) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Monetary(javax.money.Monetary) FUND_CANNOT_BE_PAID(org.folio.invoices.utils.ErrorCodes.FUND_CANNOT_BE_PAID) NO_INVOICE_LINES_ERROR_MSG(org.folio.services.validator.InvoiceValidator.NO_INVOICE_LINES_ERROR_MSG) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) VoucherLineCollection(org.folio.rest.acq.model.VoucherLineCollection) HasProperty(org.hamcrest.beans.HasProperty) CURRENT_FISCAL_YEAR(org.folio.rest.impl.MockServer.CURRENT_FISCAL_YEAR) AMOUNT(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.AMOUNT) VOUCHER_NUMBER_PREFIX_NOT_ALPHA(org.folio.invoices.utils.ErrorCodes.VOUCHER_NUMBER_PREFIX_NOT_ALPHA) MockServer.getInvoiceSearches(org.folio.rest.impl.MockServer.getInvoiceSearches) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) ACCOUNTING_CODE_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ACCOUNTING_CODE_NOT_PRESENT) MockServer.serverRqRs(org.folio.rest.impl.MockServer.serverRqRs) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) FUNDS_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.FUNDS_NOT_FOUND) LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) GENERIC_ERROR_CODE(org.folio.invoices.utils.ErrorCodes.GENERIC_ERROR_CODE) INVALID_PREFIX_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVALID_PREFIX_CONFIG_X_OKAPI_TENANT) FINANCE_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PAYMENTS) ConversionQueryBuilder(javax.money.convert.ConversionQueryBuilder) INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) VOUCHER_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.VOUCHER_NOT_FOUND) TEST_PREFIX(org.folio.rest.impl.MockServer.TEST_PREFIX) PO_LINE_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.PO_LINE_UPDATE_FAILURE) Date(java.util.Date) CurrencyUnit(javax.money.CurrencyUnit) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) HttpStatus(org.apache.http.HttpStatus) INVOICE_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_TRANSACTION_SUMMARIES) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) ERROR_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_CONFIG_X_OKAPI_TENANT) Collectors.toMap(java.util.stream.Collectors.toMap) Matchers.everyItem(org.hamcrest.Matchers.everyItem) LEDGERS(org.folio.invoices.utils.ResourcePathResolver.LEDGERS) INVOICE_NUMBER_ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVOICE_NUMBER_ERROR_X_OKAPI_TENANT) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) IsNot.not(org.hamcrest.core.IsNot.not) RoundingMode(java.math.RoundingMode) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.NON_EXIST_CONFIG_X_OKAPI_TENANT) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Collections.emptyList(java.util.Collections.emptyList) INVOICE_LINES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_LINES) Prorate(org.folio.rest.jaxrs.model.Adjustment.Prorate) Money(org.javamoney.moneta.Money) PERCENTAGE(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.PERCENTAGE) ConversionQuery(javax.money.convert.ConversionQuery) BudgetStatus(org.folio.rest.acq.model.finance.Budget.BudgetStatus) UUID(java.util.UUID) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) CANNOT_PAY_INVOICE_WITHOUT_APPROVAL(org.folio.invoices.utils.ErrorCodes.CANNOT_PAY_INVOICE_WITHOUT_APPROVAL) Collectors(java.util.stream.Collectors) LOCK_AND_CALCULATED_TOTAL_MISMATCH(org.folio.invoices.utils.ErrorCodes.LOCK_AND_CALCULATED_TOTAL_MISMATCH) PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT) INVOICE_LINES_LIST_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINES_LIST_PATH) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) DEFAULT_SYSTEM_CURRENCY(org.folio.rest.impl.AbstractHelper.DEFAULT_SYSTEM_CURRENCY) HelperUtils.getFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getFundDistributionAmount) List(java.util.List) FUNDS(org.folio.invoices.utils.ResourcePathResolver.FUNDS) MockServer.getRqRsEntries(org.folio.rest.impl.MockServer.getRqRsEntries) AcquisitionsUnitMembershipCollection(org.folio.rest.acq.model.units.AcquisitionsUnitMembershipCollection) FINANCE_PENDING_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PENDING_PAYMENTS) ExchangeRateProvider(javax.money.convert.ExchangeRateProvider) Optional(java.util.Optional) ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT) MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) MockServer.getAcqUnitsSearches(org.folio.rest.impl.MockServer.getAcqUnitsSearches) HashMap(java.util.HashMap) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) Function(java.util.function.Function) PROHIBITED_FIELD_CHANGING(org.folio.invoices.utils.ErrorCodes.PROHIBITED_FIELD_CHANGING) Type(org.folio.rest.jaxrs.model.Adjustment.Type) VOUCHER_LINES(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_LINES) RATE_KEY(org.folio.services.exchange.ExchangeRateProviderResolver.RATE_KEY) RequestContext(org.folio.rest.core.models.RequestContext) INVOICE(org.folio.invoices.utils.HelperUtils.INVOICE) MockServer.getAcqMembershipsSearches(org.folio.rest.impl.MockServer.getAcqMembershipsSearches) PENDING_PAYMENT_ERROR(org.folio.invoices.utils.ErrorCodes.PENDING_PAYMENT_ERROR) PO_LINE_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.PO_LINE_NOT_FOUND) Matchers.empty(org.hamcrest.Matchers.empty) Matchers(org.hamcrest.Matchers) MockServer.getInvoiceCreations(org.folio.rest.impl.MockServer.getInvoiceCreations) ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_X_OKAPI_TENANT) Error(org.folio.rest.jaxrs.model.Error) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) INVALID_INVOICE_TRANSITION_ON_PAID_STATUS(org.folio.invoices.utils.ErrorCodes.INVALID_INVOICE_TRANSITION_ON_PAID_STATUS) MockServer.getInvoiceUpdates(org.folio.rest.impl.MockServer.getInvoiceUpdates) VOUCHER_NUMBER_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_NUMBER_STORAGE) Response(io.restassured.response.Response) HttpMethod(io.vertx.core.http.HttpMethod) FundCollection(org.folio.rest.acq.model.finance.FundCollection) EXTERNAL_ACCOUNT_NUMBER_IS_MISSING(org.folio.invoices.utils.ErrorCodes.EXTERNAL_ACCOUNT_NUMBER_IS_MISSING) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ArrayList(java.util.ArrayList) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 3 with INVOICES

use of org.folio.invoices.utils.ResourcePathResolver.INVOICES in project mod-invoice by folio-org.

the class InvoicesApiTest method testUpdateInvoiceTransitionToPaidPoLineIdNotSpecified.

@Test
void testUpdateInvoiceTransitionToPaidPoLineIdNotSpecified() {
    logger.info("=== Test transition invoice to paid, invoice line doesn't have poLineId ===");
    Invoice reqData = getMockAsJson(APPROVED_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withStatus(Invoice.Status.PAID);
    String id = reqData.getId();
    prepareMockVoucher(id);
    InvoiceLine invoiceLine1 = getMinimalContentInvoiceLine(id).withPoLineId(null);
    addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine1));
    InvoiceLine invoiceLine2 = getMinimalContentInvoiceLine(id).withPoLineId(null);
    addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine2));
    CompositePoLine poLine = getMockAsJson(String.format("%s%s.json", PO_LINE_MOCK_DATA_PATH, EXISTENT_PO_LINE_ID)).mapTo(CompositePoLine.class).withPaymentStatus(CompositePoLine.PaymentStatus.AWAITING_PAYMENT);
    addMockEntry(ORDER_LINES, JsonObject.mapFrom(poLine));
    InvoiceLine invoiceLine3 = getMinimalContentInvoiceLine(id).withPoLineId(poLine.getId());
    addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine3));
    String jsonBody = JsonObject.mapFrom(reqData).encode();
    verifyPut(String.format(INVOICE_ID_PATH, id), jsonBody, "", 204);
    assertThat(serverRqRs.get(INVOICES, HttpMethod.PUT).get(0).getString(STATUS), is(Invoice.Status.PAID.value()));
    final List<CompositePoLine> updatedPoLines = getRqRsEntries(HttpMethod.PUT, ORDER_LINES).stream().map(line -> line.mapTo(CompositePoLine.class)).collect(Collectors.toList());
    assertThat(updatedPoLines, hasSize(1));
    assertThatVoucherPaid();
}
Also used : ORDER_LINES(org.folio.invoices.utils.ResourcePathResolver.ORDER_LINES) Arrays(java.util.Arrays) HelperUtils.getNoAcqUnitCQL(org.folio.invoices.utils.HelperUtils.getNoAcqUnitCQL) VOUCHERS_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHERS_STORAGE) PROTECTED_AND_MODIFIED_FIELDS(org.folio.rest.impl.InvoicesImpl.PROTECTED_AND_MODIFIED_FIELDS) Disabled(org.junit.jupiter.api.Disabled) StringUtils(org.apache.commons.lang3.StringUtils) INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH) MockServer.getInvoiceLineSearches(org.folio.rest.impl.MockServer.getInvoiceLineSearches) BigDecimal(java.math.BigDecimal) Voucher(org.folio.rest.jaxrs.model.Voucher) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary) Is.is(org.hamcrest.core.Is.is) JsonObject(io.vertx.core.json.JsonObject) VOUCHERS_LIST_PATH(org.folio.rest.impl.VouchersApiTest.VOUCHERS_LIST_PATH) Errors(org.folio.rest.jaxrs.model.Errors) Budget(org.folio.rest.acq.model.finance.Budget) Awaitility.await(org.awaitility.Awaitility.await) Status(org.folio.rest.jaxrs.model.Invoice.Status) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) ACQUISITIONS_UNIT_IDS(org.folio.rest.impl.ProtectionHelper.ACQUISITIONS_UNIT_IDS) FOLIO_INVOICE_NUMBER(org.folio.invoices.utils.ResourcePathResolver.FOLIO_INVOICE_NUMBER) Ledger(org.folio.rest.acq.model.finance.Ledger) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Fund(org.folio.rest.acq.model.finance.Fund) FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.FUND_DISTRIBUTIONS_NOT_PRESENT) VOUCHER_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.VOUCHER_UPDATE_FAILURE) FINANCE_TRANSACTIONS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_TRANSACTIONS) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) HelperUtils.calculateVoucherAmount(org.folio.invoices.utils.HelperUtils.calculateVoucherAmount) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Adjustment(org.folio.rest.jaxrs.model.Adjustment) PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) FISCAL_YEAR_ID(org.folio.rest.impl.MockServer.FISCAL_YEAR_ID) Invoice(org.folio.rest.jaxrs.model.Invoice) BUDGETS(org.folio.invoices.utils.ResourcePathResolver.BUDGETS) HelperUtils.convertToDoubleWithRounding(org.folio.invoices.utils.HelperUtils.convertToDoubleWithRounding) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) BUDGET_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.BUDGET_NOT_FOUND) Transaction(org.folio.rest.acq.model.finance.Transaction) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) HelperUtils.getAdjustmentFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getAdjustmentFundDistributionAmount) MAX_IDS_FOR_GET_RQ(org.folio.rest.RestConstants.MAX_IDS_FOR_GET_RQ) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) HelperUtils.calculateInvoiceLineTotals(org.folio.invoices.utils.HelperUtils.calculateInvoiceLineTotals) MockServer.getInvoiceRetrievals(org.folio.rest.impl.MockServer.getInvoiceRetrievals) FINANCE_CREDITS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_CREDITS) InvoiceProtectedFields(org.folio.invoices.utils.InvoiceProtectedFields) Matchers.hasSize(org.hamcrest.Matchers.hasSize) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Monetary(javax.money.Monetary) FUND_CANNOT_BE_PAID(org.folio.invoices.utils.ErrorCodes.FUND_CANNOT_BE_PAID) NO_INVOICE_LINES_ERROR_MSG(org.folio.services.validator.InvoiceValidator.NO_INVOICE_LINES_ERROR_MSG) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) VoucherLineCollection(org.folio.rest.acq.model.VoucherLineCollection) HasProperty(org.hamcrest.beans.HasProperty) CURRENT_FISCAL_YEAR(org.folio.rest.impl.MockServer.CURRENT_FISCAL_YEAR) AMOUNT(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.AMOUNT) VOUCHER_NUMBER_PREFIX_NOT_ALPHA(org.folio.invoices.utils.ErrorCodes.VOUCHER_NUMBER_PREFIX_NOT_ALPHA) MockServer.getInvoiceSearches(org.folio.rest.impl.MockServer.getInvoiceSearches) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) ACCOUNTING_CODE_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ACCOUNTING_CODE_NOT_PRESENT) MockServer.serverRqRs(org.folio.rest.impl.MockServer.serverRqRs) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) FUNDS_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.FUNDS_NOT_FOUND) LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) GENERIC_ERROR_CODE(org.folio.invoices.utils.ErrorCodes.GENERIC_ERROR_CODE) INVALID_PREFIX_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVALID_PREFIX_CONFIG_X_OKAPI_TENANT) FINANCE_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PAYMENTS) ConversionQueryBuilder(javax.money.convert.ConversionQueryBuilder) INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) VOUCHER_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.VOUCHER_NOT_FOUND) TEST_PREFIX(org.folio.rest.impl.MockServer.TEST_PREFIX) PO_LINE_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.PO_LINE_UPDATE_FAILURE) Date(java.util.Date) CurrencyUnit(javax.money.CurrencyUnit) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) HttpStatus(org.apache.http.HttpStatus) INVOICE_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_TRANSACTION_SUMMARIES) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) ERROR_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_CONFIG_X_OKAPI_TENANT) Collectors.toMap(java.util.stream.Collectors.toMap) Matchers.everyItem(org.hamcrest.Matchers.everyItem) LEDGERS(org.folio.invoices.utils.ResourcePathResolver.LEDGERS) INVOICE_NUMBER_ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVOICE_NUMBER_ERROR_X_OKAPI_TENANT) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) IsNot.not(org.hamcrest.core.IsNot.not) RoundingMode(java.math.RoundingMode) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.NON_EXIST_CONFIG_X_OKAPI_TENANT) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Collections.emptyList(java.util.Collections.emptyList) INVOICE_LINES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_LINES) Prorate(org.folio.rest.jaxrs.model.Adjustment.Prorate) Money(org.javamoney.moneta.Money) PERCENTAGE(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.PERCENTAGE) ConversionQuery(javax.money.convert.ConversionQuery) BudgetStatus(org.folio.rest.acq.model.finance.Budget.BudgetStatus) UUID(java.util.UUID) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) CANNOT_PAY_INVOICE_WITHOUT_APPROVAL(org.folio.invoices.utils.ErrorCodes.CANNOT_PAY_INVOICE_WITHOUT_APPROVAL) Collectors(java.util.stream.Collectors) LOCK_AND_CALCULATED_TOTAL_MISMATCH(org.folio.invoices.utils.ErrorCodes.LOCK_AND_CALCULATED_TOTAL_MISMATCH) PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT) INVOICE_LINES_LIST_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINES_LIST_PATH) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) DEFAULT_SYSTEM_CURRENCY(org.folio.rest.impl.AbstractHelper.DEFAULT_SYSTEM_CURRENCY) HelperUtils.getFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getFundDistributionAmount) List(java.util.List) FUNDS(org.folio.invoices.utils.ResourcePathResolver.FUNDS) MockServer.getRqRsEntries(org.folio.rest.impl.MockServer.getRqRsEntries) AcquisitionsUnitMembershipCollection(org.folio.rest.acq.model.units.AcquisitionsUnitMembershipCollection) FINANCE_PENDING_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PENDING_PAYMENTS) ExchangeRateProvider(javax.money.convert.ExchangeRateProvider) Optional(java.util.Optional) ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT) MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) MockServer.getAcqUnitsSearches(org.folio.rest.impl.MockServer.getAcqUnitsSearches) HashMap(java.util.HashMap) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) Function(java.util.function.Function) PROHIBITED_FIELD_CHANGING(org.folio.invoices.utils.ErrorCodes.PROHIBITED_FIELD_CHANGING) Type(org.folio.rest.jaxrs.model.Adjustment.Type) VOUCHER_LINES(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_LINES) RATE_KEY(org.folio.services.exchange.ExchangeRateProviderResolver.RATE_KEY) RequestContext(org.folio.rest.core.models.RequestContext) INVOICE(org.folio.invoices.utils.HelperUtils.INVOICE) MockServer.getAcqMembershipsSearches(org.folio.rest.impl.MockServer.getAcqMembershipsSearches) PENDING_PAYMENT_ERROR(org.folio.invoices.utils.ErrorCodes.PENDING_PAYMENT_ERROR) PO_LINE_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.PO_LINE_NOT_FOUND) Matchers.empty(org.hamcrest.Matchers.empty) Matchers(org.hamcrest.Matchers) MockServer.getInvoiceCreations(org.folio.rest.impl.MockServer.getInvoiceCreations) ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_X_OKAPI_TENANT) Error(org.folio.rest.jaxrs.model.Error) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) INVALID_INVOICE_TRANSITION_ON_PAID_STATUS(org.folio.invoices.utils.ErrorCodes.INVALID_INVOICE_TRANSITION_ON_PAID_STATUS) MockServer.getInvoiceUpdates(org.folio.rest.impl.MockServer.getInvoiceUpdates) VOUCHER_NUMBER_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_NUMBER_STORAGE) Response(io.restassured.response.Response) HttpMethod(io.vertx.core.http.HttpMethod) FundCollection(org.folio.rest.acq.model.finance.FundCollection) EXTERNAL_ACCOUNT_NUMBER_IS_MISSING(org.folio.invoices.utils.ErrorCodes.EXTERNAL_ACCOUNT_NUMBER_IS_MISSING) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 4 with INVOICES

use of org.folio.invoices.utils.ResourcePathResolver.INVOICES in project mod-invoice by folio-org.

the class InvoicesApiTest method testUpdateValidInvoiceTransitionToPaidReleaseEncumbranceFalse.

@Test
void testUpdateValidInvoiceTransitionToPaidReleaseEncumbranceFalse() {
    logger.info("=== Test transition invoice to paid and releaseEncumbrance false for all invoice lines ===");
    Invoice reqData = getMockAsJson(APPROVED_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withStatus(Invoice.Status.PAID);
    String id = reqData.getId();
    List<InvoiceLine> invoiceLines = new ArrayList<>();
    // Prepare invoice lines
    for (int i = 0; i < 3; i++) {
        InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
        invoiceLine.setId(UUID.randomUUID().toString());
        invoiceLine.setInvoiceId(id);
        invoiceLine.setPoLineId(EXISTENT_PO_LINE_ID);
        invoiceLine.setReleaseEncumbrance(false);
        invoiceLines.add(invoiceLine);
        addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine));
    }
    prepareMockVoucher(id);
    verifyPut(String.format(INVOICE_ID_PATH, id), JsonObject.mapFrom(reqData), "", 204);
    assertThat(serverRqRs.get(INVOICES, HttpMethod.PUT).get(0).getString(STATUS), is(Invoice.Status.PAID.value()));
    assertThat(serverRqRs.get(INVOICE_LINES, HttpMethod.GET), notNullValue());
    assertThat(serverRqRs.get(INVOICE_LINES, HttpMethod.GET).get(0).mapTo(InvoiceLineCollection.class).getTotalRecords(), equalTo(3));
    assertThat(serverRqRs.get(ORDER_LINES, HttpMethod.PUT), notNullValue());
    assertThat(serverRqRs.get(ORDER_LINES, HttpMethod.PUT), hasSize(1));
    assertThat(serverRqRs.get(ORDER_LINES, HttpMethod.PUT).get(0).mapTo(CompositePoLine.class).getPaymentStatus(), equalTo(CompositePoLine.PaymentStatus.PARTIALLY_PAID));
    List<JsonObject> invoiceLinesUpdates = serverRqRs.get(INVOICE_LINES, HttpMethod.PUT);
    List<InvoiceLine> lines = invoiceLinesUpdates.stream().map(entry -> entry.mapTo(InvoiceLine.class)).collect(toList());
    assertThat(lines, everyItem(hasProperty("invoiceLineStatus", is(InvoiceLine.InvoiceLineStatus.PAID))));
    checkCreditsPayments(reqData, invoiceLines);
}
Also used : ORDER_LINES(org.folio.invoices.utils.ResourcePathResolver.ORDER_LINES) Arrays(java.util.Arrays) HelperUtils.getNoAcqUnitCQL(org.folio.invoices.utils.HelperUtils.getNoAcqUnitCQL) VOUCHERS_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHERS_STORAGE) PROTECTED_AND_MODIFIED_FIELDS(org.folio.rest.impl.InvoicesImpl.PROTECTED_AND_MODIFIED_FIELDS) Disabled(org.junit.jupiter.api.Disabled) StringUtils(org.apache.commons.lang3.StringUtils) INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH) MockServer.getInvoiceLineSearches(org.folio.rest.impl.MockServer.getInvoiceLineSearches) BigDecimal(java.math.BigDecimal) Voucher(org.folio.rest.jaxrs.model.Voucher) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary) Is.is(org.hamcrest.core.Is.is) JsonObject(io.vertx.core.json.JsonObject) VOUCHERS_LIST_PATH(org.folio.rest.impl.VouchersApiTest.VOUCHERS_LIST_PATH) Errors(org.folio.rest.jaxrs.model.Errors) Budget(org.folio.rest.acq.model.finance.Budget) Awaitility.await(org.awaitility.Awaitility.await) Status(org.folio.rest.jaxrs.model.Invoice.Status) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) ACQUISITIONS_UNIT_IDS(org.folio.rest.impl.ProtectionHelper.ACQUISITIONS_UNIT_IDS) FOLIO_INVOICE_NUMBER(org.folio.invoices.utils.ResourcePathResolver.FOLIO_INVOICE_NUMBER) Ledger(org.folio.rest.acq.model.finance.Ledger) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Fund(org.folio.rest.acq.model.finance.Fund) FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.FUND_DISTRIBUTIONS_NOT_PRESENT) VOUCHER_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.VOUCHER_UPDATE_FAILURE) FINANCE_TRANSACTIONS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_TRANSACTIONS) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) HelperUtils.calculateVoucherAmount(org.folio.invoices.utils.HelperUtils.calculateVoucherAmount) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Adjustment(org.folio.rest.jaxrs.model.Adjustment) PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) FISCAL_YEAR_ID(org.folio.rest.impl.MockServer.FISCAL_YEAR_ID) Invoice(org.folio.rest.jaxrs.model.Invoice) BUDGETS(org.folio.invoices.utils.ResourcePathResolver.BUDGETS) HelperUtils.convertToDoubleWithRounding(org.folio.invoices.utils.HelperUtils.convertToDoubleWithRounding) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) BUDGET_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.BUDGET_NOT_FOUND) Transaction(org.folio.rest.acq.model.finance.Transaction) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) HelperUtils.getAdjustmentFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getAdjustmentFundDistributionAmount) MAX_IDS_FOR_GET_RQ(org.folio.rest.RestConstants.MAX_IDS_FOR_GET_RQ) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) HelperUtils.calculateInvoiceLineTotals(org.folio.invoices.utils.HelperUtils.calculateInvoiceLineTotals) MockServer.getInvoiceRetrievals(org.folio.rest.impl.MockServer.getInvoiceRetrievals) FINANCE_CREDITS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_CREDITS) InvoiceProtectedFields(org.folio.invoices.utils.InvoiceProtectedFields) Matchers.hasSize(org.hamcrest.Matchers.hasSize) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Monetary(javax.money.Monetary) FUND_CANNOT_BE_PAID(org.folio.invoices.utils.ErrorCodes.FUND_CANNOT_BE_PAID) NO_INVOICE_LINES_ERROR_MSG(org.folio.services.validator.InvoiceValidator.NO_INVOICE_LINES_ERROR_MSG) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) VoucherLineCollection(org.folio.rest.acq.model.VoucherLineCollection) HasProperty(org.hamcrest.beans.HasProperty) CURRENT_FISCAL_YEAR(org.folio.rest.impl.MockServer.CURRENT_FISCAL_YEAR) AMOUNT(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.AMOUNT) VOUCHER_NUMBER_PREFIX_NOT_ALPHA(org.folio.invoices.utils.ErrorCodes.VOUCHER_NUMBER_PREFIX_NOT_ALPHA) MockServer.getInvoiceSearches(org.folio.rest.impl.MockServer.getInvoiceSearches) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) ACCOUNTING_CODE_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ACCOUNTING_CODE_NOT_PRESENT) MockServer.serverRqRs(org.folio.rest.impl.MockServer.serverRqRs) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) FUNDS_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.FUNDS_NOT_FOUND) LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) GENERIC_ERROR_CODE(org.folio.invoices.utils.ErrorCodes.GENERIC_ERROR_CODE) INVALID_PREFIX_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVALID_PREFIX_CONFIG_X_OKAPI_TENANT) FINANCE_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PAYMENTS) ConversionQueryBuilder(javax.money.convert.ConversionQueryBuilder) INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) VOUCHER_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.VOUCHER_NOT_FOUND) TEST_PREFIX(org.folio.rest.impl.MockServer.TEST_PREFIX) PO_LINE_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.PO_LINE_UPDATE_FAILURE) Date(java.util.Date) CurrencyUnit(javax.money.CurrencyUnit) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) HttpStatus(org.apache.http.HttpStatus) INVOICE_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_TRANSACTION_SUMMARIES) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) ERROR_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_CONFIG_X_OKAPI_TENANT) Collectors.toMap(java.util.stream.Collectors.toMap) Matchers.everyItem(org.hamcrest.Matchers.everyItem) LEDGERS(org.folio.invoices.utils.ResourcePathResolver.LEDGERS) INVOICE_NUMBER_ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVOICE_NUMBER_ERROR_X_OKAPI_TENANT) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) IsNot.not(org.hamcrest.core.IsNot.not) RoundingMode(java.math.RoundingMode) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.NON_EXIST_CONFIG_X_OKAPI_TENANT) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Collections.emptyList(java.util.Collections.emptyList) INVOICE_LINES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_LINES) Prorate(org.folio.rest.jaxrs.model.Adjustment.Prorate) Money(org.javamoney.moneta.Money) PERCENTAGE(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.PERCENTAGE) ConversionQuery(javax.money.convert.ConversionQuery) BudgetStatus(org.folio.rest.acq.model.finance.Budget.BudgetStatus) UUID(java.util.UUID) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) CANNOT_PAY_INVOICE_WITHOUT_APPROVAL(org.folio.invoices.utils.ErrorCodes.CANNOT_PAY_INVOICE_WITHOUT_APPROVAL) Collectors(java.util.stream.Collectors) LOCK_AND_CALCULATED_TOTAL_MISMATCH(org.folio.invoices.utils.ErrorCodes.LOCK_AND_CALCULATED_TOTAL_MISMATCH) PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT) INVOICE_LINES_LIST_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINES_LIST_PATH) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) DEFAULT_SYSTEM_CURRENCY(org.folio.rest.impl.AbstractHelper.DEFAULT_SYSTEM_CURRENCY) HelperUtils.getFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getFundDistributionAmount) List(java.util.List) FUNDS(org.folio.invoices.utils.ResourcePathResolver.FUNDS) MockServer.getRqRsEntries(org.folio.rest.impl.MockServer.getRqRsEntries) AcquisitionsUnitMembershipCollection(org.folio.rest.acq.model.units.AcquisitionsUnitMembershipCollection) FINANCE_PENDING_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PENDING_PAYMENTS) ExchangeRateProvider(javax.money.convert.ExchangeRateProvider) Optional(java.util.Optional) ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT) MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) MockServer.getAcqUnitsSearches(org.folio.rest.impl.MockServer.getAcqUnitsSearches) HashMap(java.util.HashMap) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) Function(java.util.function.Function) PROHIBITED_FIELD_CHANGING(org.folio.invoices.utils.ErrorCodes.PROHIBITED_FIELD_CHANGING) Type(org.folio.rest.jaxrs.model.Adjustment.Type) VOUCHER_LINES(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_LINES) RATE_KEY(org.folio.services.exchange.ExchangeRateProviderResolver.RATE_KEY) RequestContext(org.folio.rest.core.models.RequestContext) INVOICE(org.folio.invoices.utils.HelperUtils.INVOICE) MockServer.getAcqMembershipsSearches(org.folio.rest.impl.MockServer.getAcqMembershipsSearches) PENDING_PAYMENT_ERROR(org.folio.invoices.utils.ErrorCodes.PENDING_PAYMENT_ERROR) PO_LINE_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.PO_LINE_NOT_FOUND) Matchers.empty(org.hamcrest.Matchers.empty) Matchers(org.hamcrest.Matchers) MockServer.getInvoiceCreations(org.folio.rest.impl.MockServer.getInvoiceCreations) ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_X_OKAPI_TENANT) Error(org.folio.rest.jaxrs.model.Error) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) INVALID_INVOICE_TRANSITION_ON_PAID_STATUS(org.folio.invoices.utils.ErrorCodes.INVALID_INVOICE_TRANSITION_ON_PAID_STATUS) MockServer.getInvoiceUpdates(org.folio.rest.impl.MockServer.getInvoiceUpdates) VOUCHER_NUMBER_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_NUMBER_STORAGE) Response(io.restassured.response.Response) HttpMethod(io.vertx.core.http.HttpMethod) FundCollection(org.folio.rest.acq.model.finance.FundCollection) EXTERNAL_ACCOUNT_NUMBER_IS_MISSING(org.folio.invoices.utils.ErrorCodes.EXTERNAL_ACCOUNT_NUMBER_IS_MISSING) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 5 with INVOICES

use of org.folio.invoices.utils.ResourcePathResolver.INVOICES in project mod-invoice by folio-org.

the class InvoicesApiTest method verifyTransitionToApproved.

private void verifyTransitionToApproved(Voucher voucherCreated, List<InvoiceLine> invoiceLines, Invoice invoice, int createdVoucherLines) {
    List<JsonObject> invoiceLinesSearches = serverRqRs.get(INVOICE_LINES, HttpMethod.GET);
    List<JsonObject> invoiceLinesUpdates = serverRqRs.get(INVOICE_LINES, HttpMethod.PUT);
    List<JsonObject> voucherLinesCreated = serverRqRs.get(VOUCHER_LINES, HttpMethod.POST);
    List<JsonObject> fundsSearches = serverRqRs.get(FUNDS, HttpMethod.GET);
    List<JsonObject> invoiceUpdates = serverRqRs.get(INVOICES, HttpMethod.PUT);
    List<JsonObject> transactionSummariesCreated = serverRqRs.get(INVOICE_TRANSACTION_SUMMARIES, HttpMethod.POST);
    List<JsonObject> pendingPaymentCreated = Optional.ofNullable(serverRqRs.get(FINANCE_PENDING_PAYMENTS, HttpMethod.POST)).orElse(emptyList());
    assertThat(invoiceLinesSearches, notNullValue());
    assertThat(invoiceLinesUpdates, notNullValue());
    assertThat(fundsSearches, notNullValue());
    assertThat(voucherLinesCreated, notNullValue());
    assertThat(invoiceUpdates, notNullValue());
    assertThat(transactionSummariesCreated, notNullValue());
    assertThat(invoiceLinesSearches, hasSize(invoiceLines.size() / MAX_IDS_FOR_GET_RQ + 1));
    List<InvoiceLine> linesWithUpdatedStatus = invoiceLinesUpdates.stream().map(entries -> entries.mapTo(InvoiceLine.class)).filter(invoiceLine -> invoiceLine.getInvoiceLineStatus() == InvoiceLine.InvoiceLineStatus.APPROVED).collect(toList());
    assertThat(linesWithUpdatedStatus, hasSize(invoiceLines.size()));
    assertThat(voucherLinesCreated, hasSize(createdVoucherLines));
    InvoiceTransactionSummary transactionSummary = transactionSummariesCreated.get(0).mapTo(InvoiceTransactionSummary.class);
    Invoice invoiceUpdate = invoiceUpdates.get(0).mapTo(Invoice.class);
    List<VoucherLine> voucherLines = voucherLinesCreated.stream().map(json -> json.mapTo(VoucherLine.class)).collect(Collectors.toList());
    assertThat(Invoice.Status.APPROVED, equalTo(invoiceUpdate.getStatus()));
    assertThat(invoiceUpdate.getVoucherNumber(), equalTo(voucherCreated.getVoucherNumber()));
    assertThat(invoiceUpdate.getId(), equalTo(voucherCreated.getInvoiceId()));
    assertThat(invoiceUpdate.getCurrency(), equalTo(voucherCreated.getInvoiceCurrency()));
    // assertThat(HelperUtils.getInvoiceExchangeRateProvider().getExchangeRate(voucherCreated.getInvoiceCurrency(), voucherCreated.getSystemCurrency()).getFactor().doubleValue(), equalTo(voucherCreated.getExchangeRate()));
    assertThat(voucherCreated.getAccountingCode(), equalTo(invoiceUpdate.getAccountingCode()));
    assertThat(voucherCreated.getExportToAccounting(), is(false));
    assertThat(Voucher.Status.AWAITING_PAYMENT, equalTo(voucherCreated.getStatus()));
    assertThat(Voucher.Type.VOUCHER, equalTo(voucherCreated.getType()));
    int paymentCreditNumber = invoiceLines.stream().filter(invoiceLine -> invoiceLine.getTotal() >= 0).mapToInt(line -> line.getFundDistributions().size()).sum();
    paymentCreditNumber += invoice.getAdjustments().stream().mapToInt(adj -> adj.getFundDistributions().size()).sum();
    assertThat(pendingPaymentCreated, hasSize(paymentCreditNumber));
    List<Transaction> pendingPayments = pendingPaymentCreated.stream().map(entries -> entries.mapTo(Transaction.class)).collect(toList());
    assertThat(pendingPayments, Every.everyItem(hasProperty("sourceInvoiceId", is(invoice.getId()))));
    assertThat(transactionSummary.getNumPendingPayments(), is(paymentCreditNumber));
    assertThat(transactionSummary.getNumPaymentsCredits(), is(paymentCreditNumber));
    assertThat(calculateVoucherAmount(voucherCreated, voucherLines), equalTo(voucherCreated.getAmount()));
    assertThat(createdVoucherLines, equalTo(voucherLinesCreated.size()));
    invoiceLines.forEach(invoiceLine -> calculateInvoiceLineTotals(invoiceLine, invoiceUpdate));
    voucherLines.forEach(voucherLine -> {
        assertThat(voucherCreated.getId(), equalTo(voucherLine.getVoucherId()));
        assertThat(voucherLine.getFundDistributions(), allOf(Every.everyItem(hasProperty("distributionType", is(AMOUNT))), Every.everyItem(hasProperty("code"))));
        assertThat(calculateVoucherLineAmount(voucherLine.getFundDistributions(), voucherCreated), equalTo(voucherLine.getAmount()));
        assertThat(voucherLine.getFundDistributions().stream().filter(fundDistribution -> Objects.nonNull(fundDistribution.getInvoiceLineId())).map(FundDistribution::getInvoiceLineId).distinct().collect(Collectors.toList()), hasSize(voucherLine.getSourceIds().size()));
    });
}
Also used : ORDER_LINES(org.folio.invoices.utils.ResourcePathResolver.ORDER_LINES) Arrays(java.util.Arrays) HelperUtils.getNoAcqUnitCQL(org.folio.invoices.utils.HelperUtils.getNoAcqUnitCQL) VOUCHERS_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHERS_STORAGE) PROTECTED_AND_MODIFIED_FIELDS(org.folio.rest.impl.InvoicesImpl.PROTECTED_AND_MODIFIED_FIELDS) Disabled(org.junit.jupiter.api.Disabled) StringUtils(org.apache.commons.lang3.StringUtils) INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH) MockServer.getInvoiceLineSearches(org.folio.rest.impl.MockServer.getInvoiceLineSearches) BigDecimal(java.math.BigDecimal) Voucher(org.folio.rest.jaxrs.model.Voucher) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary) Is.is(org.hamcrest.core.Is.is) JsonObject(io.vertx.core.json.JsonObject) VOUCHERS_LIST_PATH(org.folio.rest.impl.VouchersApiTest.VOUCHERS_LIST_PATH) Errors(org.folio.rest.jaxrs.model.Errors) Budget(org.folio.rest.acq.model.finance.Budget) Awaitility.await(org.awaitility.Awaitility.await) Status(org.folio.rest.jaxrs.model.Invoice.Status) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) ACQUISITIONS_UNIT_IDS(org.folio.rest.impl.ProtectionHelper.ACQUISITIONS_UNIT_IDS) FOLIO_INVOICE_NUMBER(org.folio.invoices.utils.ResourcePathResolver.FOLIO_INVOICE_NUMBER) Ledger(org.folio.rest.acq.model.finance.Ledger) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Fund(org.folio.rest.acq.model.finance.Fund) FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.FUND_DISTRIBUTIONS_NOT_PRESENT) VOUCHER_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.VOUCHER_UPDATE_FAILURE) FINANCE_TRANSACTIONS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_TRANSACTIONS) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) HelperUtils.calculateVoucherAmount(org.folio.invoices.utils.HelperUtils.calculateVoucherAmount) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Adjustment(org.folio.rest.jaxrs.model.Adjustment) PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITH_NON_EXISTING_VALUE_X_OKAPI_TENANT) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) FISCAL_YEAR_ID(org.folio.rest.impl.MockServer.FISCAL_YEAR_ID) Invoice(org.folio.rest.jaxrs.model.Invoice) BUDGETS(org.folio.invoices.utils.ResourcePathResolver.BUDGETS) HelperUtils.convertToDoubleWithRounding(org.folio.invoices.utils.HelperUtils.convertToDoubleWithRounding) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) BUDGET_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.BUDGET_NOT_FOUND) Transaction(org.folio.rest.acq.model.finance.Transaction) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) HelperUtils.getAdjustmentFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getAdjustmentFundDistributionAmount) MAX_IDS_FOR_GET_RQ(org.folio.rest.RestConstants.MAX_IDS_FOR_GET_RQ) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) HelperUtils.calculateInvoiceLineTotals(org.folio.invoices.utils.HelperUtils.calculateInvoiceLineTotals) MockServer.getInvoiceRetrievals(org.folio.rest.impl.MockServer.getInvoiceRetrievals) FINANCE_CREDITS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_CREDITS) InvoiceProtectedFields(org.folio.invoices.utils.InvoiceProtectedFields) Matchers.hasSize(org.hamcrest.Matchers.hasSize) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Monetary(javax.money.Monetary) FUND_CANNOT_BE_PAID(org.folio.invoices.utils.ErrorCodes.FUND_CANNOT_BE_PAID) NO_INVOICE_LINES_ERROR_MSG(org.folio.services.validator.InvoiceValidator.NO_INVOICE_LINES_ERROR_MSG) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) VoucherLineCollection(org.folio.rest.acq.model.VoucherLineCollection) HasProperty(org.hamcrest.beans.HasProperty) CURRENT_FISCAL_YEAR(org.folio.rest.impl.MockServer.CURRENT_FISCAL_YEAR) AMOUNT(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.AMOUNT) VOUCHER_NUMBER_PREFIX_NOT_ALPHA(org.folio.invoices.utils.ErrorCodes.VOUCHER_NUMBER_PREFIX_NOT_ALPHA) MockServer.getInvoiceSearches(org.folio.rest.impl.MockServer.getInvoiceSearches) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) ACCOUNTING_CODE_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ACCOUNTING_CODE_NOT_PRESENT) MockServer.serverRqRs(org.folio.rest.impl.MockServer.serverRqRs) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) FUNDS_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.FUNDS_NOT_FOUND) LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH(org.folio.invoices.utils.ErrorCodes.LINE_FUND_DISTRIBUTIONS_SUMMARY_MISMATCH) GENERIC_ERROR_CODE(org.folio.invoices.utils.ErrorCodes.GENERIC_ERROR_CODE) INVALID_PREFIX_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVALID_PREFIX_CONFIG_X_OKAPI_TENANT) FINANCE_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PAYMENTS) ConversionQueryBuilder(javax.money.convert.ConversionQueryBuilder) INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) VOUCHER_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.VOUCHER_NOT_FOUND) TEST_PREFIX(org.folio.rest.impl.MockServer.TEST_PREFIX) PO_LINE_UPDATE_FAILURE(org.folio.invoices.utils.ErrorCodes.PO_LINE_UPDATE_FAILURE) Date(java.util.Date) CurrencyUnit(javax.money.CurrencyUnit) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) HttpStatus(org.apache.http.HttpStatus) INVOICE_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_TRANSACTION_SUMMARIES) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) ERROR_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_CONFIG_X_OKAPI_TENANT) Collectors.toMap(java.util.stream.Collectors.toMap) Matchers.everyItem(org.hamcrest.Matchers.everyItem) LEDGERS(org.folio.invoices.utils.ResourcePathResolver.LEDGERS) INVOICE_NUMBER_ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.INVOICE_NUMBER_ERROR_X_OKAPI_TENANT) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) IsNot.not(org.hamcrest.core.IsNot.not) RoundingMode(java.math.RoundingMode) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.NON_EXIST_CONFIG_X_OKAPI_TENANT) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Collections.emptyList(java.util.Collections.emptyList) INVOICE_LINES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_LINES) Prorate(org.folio.rest.jaxrs.model.Adjustment.Prorate) Money(org.javamoney.moneta.Money) PERCENTAGE(org.folio.rest.jaxrs.model.FundDistribution.DistributionType.PERCENTAGE) ConversionQuery(javax.money.convert.ConversionQuery) BudgetStatus(org.folio.rest.acq.model.finance.Budget.BudgetStatus) UUID(java.util.UUID) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) CANNOT_PAY_INVOICE_WITHOUT_APPROVAL(org.folio.invoices.utils.ErrorCodes.CANNOT_PAY_INVOICE_WITHOUT_APPROVAL) Collectors(java.util.stream.Collectors) LOCK_AND_CALCULATED_TOTAL_MISMATCH(org.folio.invoices.utils.ErrorCodes.LOCK_AND_CALCULATED_TOTAL_MISMATCH) PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.PREFIX_CONFIG_WITHOUT_VALUE_X_OKAPI_TENANT) INVOICE_LINES_LIST_PATH(org.folio.rest.impl.InvoiceLinesApiTest.INVOICE_LINES_LIST_PATH) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) DEFAULT_SYSTEM_CURRENCY(org.folio.rest.impl.AbstractHelper.DEFAULT_SYSTEM_CURRENCY) HelperUtils.getFundDistributionAmount(org.folio.invoices.utils.HelperUtils.getFundDistributionAmount) List(java.util.List) FUNDS(org.folio.invoices.utils.ResourcePathResolver.FUNDS) MockServer.getRqRsEntries(org.folio.rest.impl.MockServer.getRqRsEntries) AcquisitionsUnitMembershipCollection(org.folio.rest.acq.model.units.AcquisitionsUnitMembershipCollection) FINANCE_PENDING_PAYMENTS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_PENDING_PAYMENTS) ExchangeRateProvider(javax.money.convert.ExchangeRateProvider) Optional(java.util.Optional) ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT(org.folio.invoices.utils.ErrorCodes.ADJUSTMENT_FUND_DISTRIBUTIONS_NOT_PRESENT) MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) MockServer.getAcqUnitsSearches(org.folio.rest.impl.MockServer.getAcqUnitsSearches) HashMap(java.util.HashMap) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) Function(java.util.function.Function) PROHIBITED_FIELD_CHANGING(org.folio.invoices.utils.ErrorCodes.PROHIBITED_FIELD_CHANGING) Type(org.folio.rest.jaxrs.model.Adjustment.Type) VOUCHER_LINES(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_LINES) RATE_KEY(org.folio.services.exchange.ExchangeRateProviderResolver.RATE_KEY) RequestContext(org.folio.rest.core.models.RequestContext) INVOICE(org.folio.invoices.utils.HelperUtils.INVOICE) MockServer.getAcqMembershipsSearches(org.folio.rest.impl.MockServer.getAcqMembershipsSearches) PENDING_PAYMENT_ERROR(org.folio.invoices.utils.ErrorCodes.PENDING_PAYMENT_ERROR) PO_LINE_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.PO_LINE_NOT_FOUND) Matchers.empty(org.hamcrest.Matchers.empty) Matchers(org.hamcrest.Matchers) MockServer.getInvoiceCreations(org.folio.rest.impl.MockServer.getInvoiceCreations) ERROR_X_OKAPI_TENANT(org.folio.rest.impl.MockServer.ERROR_X_OKAPI_TENANT) Error(org.folio.rest.jaxrs.model.Error) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) INVALID_INVOICE_TRANSITION_ON_PAID_STATUS(org.folio.invoices.utils.ErrorCodes.INVALID_INVOICE_TRANSITION_ON_PAID_STATUS) MockServer.getInvoiceUpdates(org.folio.rest.impl.MockServer.getInvoiceUpdates) VOUCHER_NUMBER_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHER_NUMBER_STORAGE) Response(io.restassured.response.Response) HttpMethod(io.vertx.core.http.HttpMethod) FundCollection(org.folio.rest.acq.model.finance.FundCollection) EXTERNAL_ACCOUNT_NUMBER_IS_MISSING(org.folio.invoices.utils.ErrorCodes.EXTERNAL_ACCOUNT_NUMBER_IS_MISSING) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) VoucherLine(org.folio.rest.jaxrs.model.VoucherLine) Invoice(org.folio.rest.jaxrs.model.Invoice) Transaction(org.folio.rest.acq.model.finance.Transaction) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) JsonObject(io.vertx.core.json.JsonObject) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary)

Aggregations

Collections (java.util.Collections)10 Date (java.util.Date)10 List (java.util.List)10 UUID.randomUUID (java.util.UUID.randomUUID)10 Vertx (io.vertx.core.Vertx)9 JsonObject (io.vertx.core.json.JsonObject)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Map (java.util.Map)9 Objects (java.util.Objects)9 Optional (java.util.Optional)9 Function (java.util.function.Function)9 Collectors (java.util.stream.Collectors)9 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)9 Collectors.toList (java.util.stream.Collectors.toList)9 Collectors.toMap (java.util.stream.Collectors.toMap)9 Stream (java.util.stream.Stream)9 MonetaryAmount (javax.money.MonetaryAmount)9 ConversionQuery (javax.money.convert.ConversionQuery)9 CurrencyConversion (javax.money.convert.CurrencyConversion)9