Search in sources :

Example 16 with Adjustment

use of org.folio.rest.jaxrs.model.Adjustment in project mod-invoice by folio-org.

the class InvoicesProratedAdjustmentsTest method testUpdateInvoiceWithTwoLinesAddingAdjustmentByLines.

@ParameterizedTest
@ValueSource(strings = { "AMOUNT", "PERCENTAGE" })
public void testUpdateInvoiceWithTwoLinesAddingAdjustmentByLines(Adjustment.Type type) {
    logger.info("=== Updating invoice with two lines adding adjustment by lines ===");
    // Prepare data "from storage"
    Invoice invoice = getMockAsJson(OPEN_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withId(randomUUID().toString());
    invoice.getAdjustments().clear();
    addMockEntry(INVOICES, invoice);
    InvoiceLine invoiceLine1 = getMockInvoiceLine(invoice.getId()).withSubTotal(5d).withInvoiceLineNumber("n-1");
    addMockEntry(INVOICE_LINES, invoiceLine1);
    InvoiceLine invoiceLine2 = getMockInvoiceLine(invoice.getId()).withSubTotal(15d).withInvoiceLineNumber("n-2");
    addMockEntry(INVOICE_LINES, invoiceLine2);
    // Prepare request body
    Invoice invoiceBody = copyObject(invoice);
    invoiceBody.getAdjustments().add(createAdjustment(BY_LINE, type, 9.30d));
    // Send update request
    verifyPut(String.format(INVOICE_ID_PATH, invoice.getId()), invoiceBody, "", 204);
    // Verification
    assertThat(getInvoiceUpdates(), hasSize(1));
    assertThat(getInvoiceLineUpdates(), hasSize(2));
    Invoice invoiceToStorage = getInvoiceUpdates().get(0).mapTo(Invoice.class);
    assertThat(invoiceToStorage.getAdjustments(), hasSize(1));
    Adjustment invoiceAdjustment = invoiceToStorage.getAdjustments().get(0);
    assertThat(invoiceAdjustment.getId(), not(isEmptyOrNullString()));
    /*
     * Total invoice adjustment value is sum of invoice line adjustments and depends on type:
     * "Amount" - this is the same as prorated adjustment value i.e. 9.30$
     * "Percentage" - (20 * 9.30) / 100
     */
    assertThat(invoiceToStorage.getAdjustmentsTotal(), is(type == AMOUNT ? 9.30d : 1.86d));
    // Adjustment value is invoice prorated adjustment's value divided by number of lines but adjustment total amount is calculated based on subTotal
    double expectedAdjValue = (type == AMOUNT) ? 4.65d : 0.93;
    getInvoiceLineUpdates().stream().map(json -> json.mapTo(InvoiceLine.class)).forEach(line -> {
        assertThat(line.getAdjustments(), hasSize(1));
        Adjustment adj = line.getAdjustments().get(0);
        verifyInvoiceLineAdjustmentCommon(invoiceAdjustment, adj);
        assertThat(adj.getValue(), is(expectedAdjValue));
        assertThat(line.getAdjustmentsTotal(), is(expectedAdjValue));
    });
}
Also used : INVOICES(org.folio.invoices.utils.ResourcePathResolver.INVOICES) CsvSource(org.junit.jupiter.params.provider.CsvSource) NOT_PRORATED(org.folio.rest.jaxrs.model.Adjustment.Prorate.NOT_PRORATED) Date(java.util.Date) Matchers.not(org.hamcrest.Matchers.not) BY_LINE(org.folio.rest.jaxrs.model.Adjustment.Prorate.BY_LINE) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) OPEN_INVOICE_SAMPLE_PATH(org.folio.rest.impl.InvoicesApiTest.OPEN_INVOICE_SAMPLE_PATH) PERCENTAGE(org.folio.rest.jaxrs.model.Adjustment.Type.PERCENTAGE) ArrayList(java.util.ArrayList) Matchers.nullValue(org.hamcrest.Matchers.nullValue) MockServer.getInvoiceLineUpdates(org.folio.rest.impl.MockServer.getInvoiceLineUpdates) BY_AMOUNT(org.folio.rest.jaxrs.model.Adjustment.Prorate.BY_AMOUNT) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Metadata(org.folio.rest.jaxrs.model.Metadata) AMOUNT(org.folio.rest.jaxrs.model.Adjustment.Type.AMOUNT) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) ValueSource(org.junit.jupiter.params.provider.ValueSource) Matchers.empty(org.hamcrest.Matchers.empty) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) INVOICE_LINES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_LINES) INVOICE_ID_PATH(org.folio.rest.impl.InvoicesApiTest.INVOICE_ID_PATH) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) Test(org.junit.jupiter.api.Test) UUID.randomUUID(java.util.UUID.randomUUID) BY_QUANTITY(org.folio.rest.jaxrs.model.Adjustment.Prorate.BY_QUANTITY) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MockServer.getInvoiceUpdates(org.folio.rest.impl.MockServer.getInvoiceUpdates) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Adjustment(org.folio.rest.jaxrs.model.Adjustment) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) Invoice(org.folio.rest.jaxrs.model.Invoice) Invoice(org.folio.rest.jaxrs.model.Invoice) Adjustment(org.folio.rest.jaxrs.model.Adjustment) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with Adjustment

use of org.folio.rest.jaxrs.model.Adjustment in project mod-invoice by folio-org.

the class InvoicesProratedAdjustmentsTest method testUpdateInvoiceWithThreeLinesAddingAmountAdjustmentByAmountWithMissedPenny.

@Test
public void testUpdateInvoiceWithThreeLinesAddingAmountAdjustmentByAmountWithMissedPenny() {
    logger.info("=== Updating invoice with zero subTotal and three lines (mixed subTotals) adding adjustment by amount, missing one \"penny\" ===");
    // Prepare data "from storage"
    Invoice invoice = getMockAsJson(OPEN_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withId(randomUUID().toString());
    invoice.getAdjustments().clear();
    addMockEntry(INVOICES, invoice);
    InvoiceLine invoiceLine1 = getMockInvoiceLine(invoice.getId()).withSubTotal(50d).withInvoiceLineNumber("n-1");
    addMockEntry(INVOICE_LINES, invoiceLine1);
    InvoiceLine invoiceLine2 = getMockInvoiceLine(invoice.getId()).withSubTotal(15d).withInvoiceLineNumber("n-2");
    addMockEntry(INVOICE_LINES, invoiceLine2);
    InvoiceLine invoiceLine3 = getMockInvoiceLine(invoice.getId()).withSubTotal(-5d).withInvoiceLineNumber("n-3");
    addMockEntry(INVOICE_LINES, invoiceLine3);
    // Prepare request body
    Invoice invoiceBody = copyObject(invoice);
    invoiceBody.getAdjustments().add(createAdjustment(BY_AMOUNT, AMOUNT, 5d));
    // Send update request
    verifyPut(String.format(INVOICE_ID_PATH, invoice.getId()), invoiceBody, "", 204);
    // Verification
    assertThat(getInvoiceUpdates(), hasSize(1));
    assertThat(getInvoiceLineUpdates(), hasSize(3));
    Invoice invoiceToStorage = getInvoiceUpdates().get(0).mapTo(Invoice.class);
    assertThat(invoiceToStorage.getAdjustments(), hasSize(1));
    // Prorated adj value + non prorated adj of first line
    assertThat(invoiceToStorage.getAdjustmentsTotal(), is(5d));
    Adjustment invoiceAdjustment = invoiceToStorage.getAdjustments().get(0);
    assertThat(invoiceAdjustment.getId(), not(isEmptyOrNullString()));
    // 5 * 50 / 70 = 3,57(1428571428571‬)
    verifyAdjustmentValue(invoiceLine1.getId(), 3.57d);
    // 5 * 15 / 70 = 1,07(1428571428571‬)
    verifyAdjustmentValue(invoiceLine2.getId(), 1.07d);
    // 5 * 5 / 70 = 0,35(7142857142857) + 0.01
    verifyAdjustmentValue(invoiceLine3.getId(), 0.36d);
}
Also used : Invoice(org.folio.rest.jaxrs.model.Invoice) Adjustment(org.folio.rest.jaxrs.model.Adjustment) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with Adjustment

use of org.folio.rest.jaxrs.model.Adjustment in project mod-invoice by folio-org.

the class InvoicesProratedAdjustmentsTest method testUpdateInvoiceWithOneLineMakingAdjustmentNotProrated.

@ParameterizedTest
@CsvSource({ "BY_AMOUNT, AMOUNT", "BY_AMOUNT, PERCENTAGE", "BY_LINE, AMOUNT", "BY_LINE, PERCENTAGE", "BY_QUANTITY, AMOUNT", "BY_QUANTITY, PERCENTAGE" })
public void testUpdateInvoiceWithOneLineMakingAdjustmentNotProrated(Adjustment.Prorate prorate, Adjustment.Type type) {
    logger.info("=== Updating invoice with one line and one prorated adjustment - making adjustment \"Not prorated\" ===");
    // Prepare data "from storage"
    Invoice invoice = getMockAsJson(OPEN_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withId(randomUUID().toString());
    final double adjValue = 15d;
    Adjustment adjustment = createAdjustment(prorate, type, adjValue).withId(randomUUID().toString());
    invoice.setAdjustments(Collections.singletonList(adjustment));
    addMockEntry(INVOICES, invoice);
    InvoiceLine invoiceLine = getMockInvoiceLine(invoice.getId()).withSubTotal(25d).withAdjustments(Collections.singletonList(copyObject(adjustment).withAdjustmentId(adjustment.getId()).withId(null)));
    addMockEntry(INVOICE_LINES, invoiceLine);
    // Send update request making adjustment "Not prorated"
    Invoice body = copyObject(invoice);
    body.getAdjustments().get(0).setProrate(NOT_PRORATED);
    verifyPut(String.format(INVOICE_ID_PATH, invoice.getId()), body, "", 204);
    // Verification
    assertThat(getInvoiceUpdates(), hasSize(1));
    assertThat(getInvoiceLineUpdates(), hasSize(1));
    /*
     * Calculated adjustment value depends of type:
     * "Amount" - this is the same as adjustment value
     * "Percentage" - this is the percentage of subTotal i.e. 15% of 25$ = 3.75$
     */
    double expectedAdjTotal = (type == AMOUNT) ? adjValue : 3.75d;
    Invoice invoiceToStorage = getInvoiceUpdates().get(0).mapTo(Invoice.class);
    assertThat(invoiceToStorage.getAdjustments(), hasSize(1));
    assertThat(invoiceToStorage.getAdjustmentsTotal(), is(expectedAdjTotal));
    Adjustment invoiceAdjustment = invoiceToStorage.getAdjustments().get(0);
    assertThat(invoiceAdjustment.getId(), not(isEmptyOrNullString()));
    // Adjustments should be deleted
    InvoiceLine lineToStorage = getInvoiceLineUpdates().get(0).mapTo(InvoiceLine.class);
    assertThat(lineToStorage.getAdjustments(), empty());
    assertThat(lineToStorage.getAdjustmentsTotal(), is(0d));
}
Also used : Invoice(org.folio.rest.jaxrs.model.Invoice) Adjustment(org.folio.rest.jaxrs.model.Adjustment) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with Adjustment

use of org.folio.rest.jaxrs.model.Adjustment in project mod-invoice by folio-org.

the class BudgetExpenseClassTest method shouldThrowExceptionWithBudgetExpenseClassNotFoundCodeWhenCheckExpenseClassesWithoutExpenseClasses.

@Test
void shouldThrowExceptionWithBudgetExpenseClassNotFoundCodeWhenCheckExpenseClassesWithoutExpenseClasses() {
    String notAssignedExpenseClassId = UUID.randomUUID().toString();
    String activeExpenseClassId = UUID.randomUUID().toString();
    FundDistribution fundDistributionWithActiveExpenseClass = new FundDistribution().withFundId(UUID.randomUUID().toString()).withExpenseClassId(activeExpenseClassId);
    FundDistribution fundDistributionWithNotAssignedExpenseClass = new FundDistribution().withFundId(UUID.randomUUID().toString()).withExpenseClassId(notAssignedExpenseClassId);
    FundDistribution fundDistributionWithoutExpenseClass = new FundDistribution().withFundId(UUID.randomUUID().toString());
    InvoiceLine invoiceLine = new InvoiceLine().withFundDistributions(Arrays.asList(fundDistributionWithActiveExpenseClass, fundDistributionWithoutExpenseClass));
    List<InvoiceLine> invoiceLines = Collections.singletonList(invoiceLine);
    Adjustment adjustment = new Adjustment().withFundDistributions(Collections.singletonList(fundDistributionWithNotAssignedExpenseClass));
    Invoice invoice = new Invoice().withAdjustments(Collections.singletonList(adjustment));
    BudgetExpenseClass active = new BudgetExpenseClass().withBudgetId(UUID.randomUUID().toString()).withExpenseClassId(activeExpenseClassId).withStatus(BudgetExpenseClass.Status.ACTIVE).withId(UUID.randomUUID().toString());
    Fund noExpenseClassFund = new Fund().withCode("no expense class fund");
    ExpenseClass notAssignedExpenseClass = new ExpenseClass().withName("not assigned class");
    List<InvoiceWorkflowDataHolder> holders = new ArrayList<>();
    InvoiceWorkflowDataHolder holder1 = new InvoiceWorkflowDataHolder().withInvoice(invoice).withInvoiceLine(invoiceLine).withFundDistribution(fundDistributionWithActiveExpenseClass).withBudget(new Budget().withFundId(UUID.randomUUID().toString())).withExpenseClass(new ExpenseClass().withId(activeExpenseClassId));
    InvoiceWorkflowDataHolder holder2 = new InvoiceWorkflowDataHolder().withInvoice(invoice).withInvoiceLine(invoiceLine).withBudget(new Budget().withFundId(UUID.randomUUID().toString())).withFundDistribution(fundDistributionWithoutExpenseClass);
    InvoiceWorkflowDataHolder holder3 = new InvoiceWorkflowDataHolder().withInvoice(invoice).withAdjustment(adjustment).withFundDistribution(fundDistributionWithNotAssignedExpenseClass).withExpenseClass(notAssignedExpenseClass).withBudget(new Budget().withFundId(UUID.randomUUID().toString())).withFund(noExpenseClassFund);
    holders.add(holder1);
    holders.add(holder2);
    holders.add(holder3);
    when(restClient.get(any(RequestEntry.class), any(), any())).thenAnswer(invocation -> {
        RequestEntry requestEntry = invocation.getArgument(0);
        List<BudgetExpenseClass> budgetExpenseClasses = requestEntry.buildEndpoint().contains(notAssignedExpenseClassId) ? Collections.emptyList() : Collections.singletonList(active);
        return CompletableFuture.completedFuture(new BudgetExpenseClassCollection().withBudgetExpenseClasses(budgetExpenseClasses).withTotalRecords(1));
    });
    when(requestContext.getContext()).thenReturn(Vertx.vertx().getOrCreateContext());
    CompletableFuture<List<InvoiceWorkflowDataHolder>> future = budgetExpenseClassService.checkExpenseClasses(holders, requestContext);
    ExecutionException executionException = assertThrows(ExecutionException.class, future::get);
    assertThat(executionException.getCause(), instanceOf(HttpException.class));
    HttpException exception = (HttpException) executionException.getCause();
    assertEquals(400, exception.getCode());
    Errors errors = exception.getErrors();
    Error error = errors.getErrors().get(0);
    assertEquals(BUDGET_EXPENSE_CLASS_NOT_FOUND.getCode(), error.getCode());
    String expenseClassNameFromError = error.getParameters().stream().filter(parameter -> parameter.getKey().equals(EXPENSE_CLASS_NAME)).findFirst().get().getValue();
    assertEquals(notAssignedExpenseClass.getName(), expenseClassNameFromError);
    String fundCodeFromError = error.getParameters().stream().filter(parameter -> parameter.getKey().equals(FUND_CODE)).findFirst().get().getValue();
    assertEquals(noExpenseClassFund.getCode(), fundCodeFromError);
}
Also used : ExpenseClass(org.folio.rest.acq.model.finance.ExpenseClass) BudgetExpenseClass(org.folio.rest.acq.model.finance.BudgetExpenseClass) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) RestClient(org.folio.rest.core.RestClient) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Mock(org.mockito.Mock) CompletableFuture(java.util.concurrent.CompletableFuture) InvoiceWorkflowDataHolder(org.folio.models.InvoiceWorkflowDataHolder) ArrayList(java.util.ArrayList) HttpException(org.folio.invoices.rest.exceptions.HttpException) MockitoAnnotations(org.mockito.MockitoAnnotations) ExpenseClass(org.folio.rest.acq.model.finance.ExpenseClass) FUND_CODE(org.folio.services.finance.budget.BudgetExpenseClassService.FUND_CODE) BudgetExpenseClass(org.folio.rest.acq.model.finance.BudgetExpenseClass) RequestContext(org.folio.rest.core.models.RequestContext) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Errors(org.folio.rest.jaxrs.model.Errors) Budget(org.folio.rest.acq.model.finance.Budget) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) INACTIVE_EXPENSE_CLASS(org.folio.invoices.utils.ErrorCodes.INACTIVE_EXPENSE_CLASS) BudgetExpenseClassService(org.folio.services.finance.budget.BudgetExpenseClassService) Vertx(io.vertx.core.Vertx) RequestEntry(org.folio.rest.core.models.RequestEntry) Mockito.when(org.mockito.Mockito.when) UUID(java.util.UUID) Fund(org.folio.rest.acq.model.finance.Fund) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) Error(org.folio.rest.jaxrs.model.Error) List(java.util.List) BudgetExpenseClassCollection(org.folio.rest.acq.model.finance.BudgetExpenseClassCollection) EXPENSE_CLASS_NAME(org.folio.services.finance.budget.BudgetExpenseClassService.EXPENSE_CLASS_NAME) Adjustment(org.folio.rest.jaxrs.model.Adjustment) BUDGET_EXPENSE_CLASS_NOT_FOUND(org.folio.invoices.utils.ErrorCodes.BUDGET_EXPENSE_CLASS_NOT_FOUND) Collections(java.util.Collections) Invoice(org.folio.rest.jaxrs.model.Invoice) Invoice(org.folio.rest.jaxrs.model.Invoice) Adjustment(org.folio.rest.jaxrs.model.Adjustment) BudgetExpenseClass(org.folio.rest.acq.model.finance.BudgetExpenseClass) Fund(org.folio.rest.acq.model.finance.Fund) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ArrayList(java.util.ArrayList) Error(org.folio.rest.jaxrs.model.Error) RequestEntry(org.folio.rest.core.models.RequestEntry) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Errors(org.folio.rest.jaxrs.model.Errors) InvoiceWorkflowDataHolder(org.folio.models.InvoiceWorkflowDataHolder) Budget(org.folio.rest.acq.model.finance.Budget) ArrayList(java.util.ArrayList) List(java.util.List) HttpException(org.folio.invoices.rest.exceptions.HttpException) ExecutionException(java.util.concurrent.ExecutionException) BudgetExpenseClassCollection(org.folio.rest.acq.model.finance.BudgetExpenseClassCollection) Test(org.junit.jupiter.api.Test)

Example 20 with Adjustment

use of org.folio.rest.jaxrs.model.Adjustment in project mod-invoice by folio-org.

the class InvoicesApiTest method testPutInvoiceByIdChangeStatusToPayedActiveBudgetNotFound.

@Test
void testPutInvoiceByIdChangeStatusToPayedActiveBudgetNotFound() {
    logger.info("=== Test Put Invoice By Id, Current fiscal year not found ===");
    Invoice reqData = getMockAsJson(APPROVED_INVOICE_SAMPLE_PATH).mapTo(Invoice.class).withStatus(Invoice.Status.PAID);
    String id = reqData.getId();
    reqData.setStatus(Status.PAID);
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    invoiceLine.setId(UUID.randomUUID().toString());
    invoiceLine.setInvoiceId(reqData.getId());
    invoiceLine.getFundDistributions().get(0).withFundId(FUND_ID_WITH_NOT_ACTIVE_BUDGET);
    invoiceLine.getFundDistributions().forEach(fundDistribution -> {
        Fund fund = new Fund().withId(fundDistribution.getFundId()).withExternalAccountNo("externalNo").withLedgerId(EXISTING_LEDGER_ID);
        addMockEntry(FUNDS, fund);
    });
    reqData.getAdjustments().stream().flatMap(adjustment -> adjustment.getFundDistributions().stream()).map(FundDistribution::getFundId).distinct().forEach(fundId -> {
        Fund fund = new Fund().withId(fundId).withExternalAccountNo("externalNo").withLedgerId(EXISTING_LEDGER_ID);
        addMockEntry(FUNDS, fund);
    });
    addMockEntry(LEDGERS, JsonObject.mapFrom(new Ledger().withId(EXISTING_LEDGER_ID).withRestrictEncumbrance(true)));
    addMockEntry(INVOICE_LINES, JsonObject.mapFrom(invoiceLine));
    prepareMockVoucher(id);
    Errors errors = verifyPut(String.format(INVOICE_ID_PATH, id), JsonObject.mapFrom(reqData), APPLICATION_JSON, 404).as(Errors.class);
    assertThat(getRqRsEntries(HttpMethod.GET, INVOICE_LINES), hasSize(1));
    assertThat(getRqRsEntries(HttpMethod.GET, FINANCE_TRANSACTIONS), hasSize(0));
    assertThat(getRqRsEntries(HttpMethod.GET, FUNDS), hasSize(1));
    assertThat(getRqRsEntries(HttpMethod.POST, FINANCE_PAYMENTS), hasSize(0));
    assertThat(getRqRsEntries(HttpMethod.POST, FINANCE_CREDITS), hasSize(0));
    assertThat(errors.getErrors(), hasSize(1));
    Error error = errors.getErrors().get(0);
    assertThat(error.getCode(), equalTo(BUDGET_NOT_FOUND.getCode()));
}
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) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Errors(org.folio.rest.jaxrs.model.Errors) Invoice(org.folio.rest.jaxrs.model.Invoice) Fund(org.folio.rest.acq.model.finance.Fund) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Ledger(org.folio.rest.acq.model.finance.Ledger) Error(org.folio.rest.jaxrs.model.Error) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Aggregations

Adjustment (org.folio.rest.jaxrs.model.Adjustment)40 Invoice (org.folio.rest.jaxrs.model.Invoice)33 InvoiceLine (org.folio.rest.jaxrs.model.InvoiceLine)33 Test (org.junit.jupiter.api.Test)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 ArrayList (java.util.ArrayList)12 CsvSource (org.junit.jupiter.params.provider.CsvSource)10 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)7 JsonObject (io.vertx.core.json.JsonObject)6 Errors (org.folio.rest.jaxrs.model.Errors)6 List (java.util.List)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 Headers (io.restassured.http.Headers)4 Collections (java.util.Collections)4 Date (java.util.Date)4 MonetaryAmount (javax.money.MonetaryAmount)4 HttpException (org.folio.invoices.rest.exceptions.HttpException)4 RequestContext (org.folio.rest.core.models.RequestContext)4 Error (org.folio.rest.jaxrs.model.Error)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4