Search in sources :

Example 16 with InvoiceLine

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

the class InvoiceLinesApiTest method testGetInvoicingInvoiceLinesByIdUpdateTotal.

@Test
public void testGetInvoicingInvoiceLinesByIdUpdateTotal() {
    logger.info("=== Test 200 when correct calculated invoice line total is returned without waiting to update in storage ===");
    final InvoiceLine resp = verifySuccessGetById(INVOICE_LINE_OUTDATED_TOTAL, true, true);
    Double expectedTotal = 4.62;
    assertThat(resp.getTotal(), equalTo(expectedTotal));
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Test(org.junit.jupiter.api.Test)

Example 17 with InvoiceLine

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

the class InvoiceLinesApiTest method testAddInvoiceLineToApprovedInvoice.

@Test
public void testAddInvoiceLineToApprovedInvoice() {
    logger.info("=== Test create invoice line for approved invoice ===");
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    reqData.setInvoiceId(APPROVED_INVOICE_ID);
    String body = JsonObject.mapFrom(reqData).encodePrettily();
    final Errors errors = verifyPostResponse(INVOICE_LINES_PATH, body, prepareHeaders(X_OKAPI_TENANT), APPLICATION_JSON, 500).as(Errors.class);
    assertThat(errors, notNullValue());
    assertThat(errors.getErrors(), hasSize(1));
    Error error = errors.getErrors().get(0);
    assertThat(error.getMessage(), is(PROHIBITED_INVOICE_LINE_CREATION.getDescription()));
    assertThat(error.getCode(), is(PROHIBITED_INVOICE_LINE_CREATION.getCode()));
}
Also used : Errors(org.folio.rest.jaxrs.model.Errors) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Error(org.folio.rest.jaxrs.model.Error) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 18 with InvoiceLine

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

the class InvoiceLinesApiTest method checkInvoiceLineUpdateUpdatesInvoicePoNumbers.

@Test
public void checkInvoiceLineUpdateUpdatesInvoicePoNumbers() {
    logger.info("=== Check an invoice line update triggers the update of the invoice's poNumbers field ===");
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_PO_NUMBER_PATH).mapTo(InvoiceLine.class);
    invoiceLine.setInvoiceId(OPEN_INVOICE_ID);
    addMockEntry(INVOICE_LINES, invoiceLine);
    verifyPut(INVOICE_LINE_WITH_PO_NUMBER, JsonObject.mapFrom(invoiceLine), "", 204);
    List<JsonObject> objects = serverRqRs.get(INVOICES, HttpMethod.PUT);
    assertThat(objects, notNullValue());
    Invoice updatedInvoice = objects.get(0).mapTo(Invoice.class);
    List<String> poNumbers = updatedInvoice.getPoNumbers();
    // that invoice already had a poNumber, it gets another one
    assertThat(poNumbers, hasSize(2));
    assertThat(poNumbers.get(1), equalTo("AB268758XYZ"));
}
Also used : Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) JsonObject(io.vertx.core.json.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 19 with InvoiceLine

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

the class InvoiceLinesApiTest method testPostInvoicingInvoiceLinesWithInvoiceLineNumberGenerationFail.

@Test
public void testPostInvoicingInvoiceLinesWithInvoiceLineNumberGenerationFail() {
    logger.info("=== Test create invoice with error from storage on invoiceLineNo generation  ===");
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    reqData.setInvoiceId(REVIEWED_INVOICE_ID);
    String body = JsonObject.mapFrom(reqData).encodePrettily();
    verifyPostResponse(INVOICE_LINES_PATH, body, prepareHeaders(INVOICE_LINE_NUMBER_ERROR_X_OKAPI_TENANT), APPLICATION_JSON, 500);
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 20 with InvoiceLine

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

the class InvoiceLinesApiTest method testPostInvoicingInvoiceLinesWithRelationshipTotal.

@Test
public void testPostInvoicingInvoiceLinesWithRelationshipTotal() {
    logger.info("=== Test Post Invoice Lines to use only In addition To RelationToTotal ===");
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_ADJUSTMENTS_SAMPLE_PATH).mapTo(InvoiceLine.class);
    // set adjustment realtion to Included In
    reqData.getAdjustments().get(0).setRelationToTotal(Adjustment.RelationToTotal.INCLUDED_IN);
    String jsonBody = JsonObject.mapFrom(reqData).encode();
    InvoiceLine invoiceLine = verifyPostResponse(INVOICE_LINES_PATH, jsonBody, prepareHeaders(X_OKAPI_TENANT), APPLICATION_JSON, 201).as(InvoiceLine.class);
    double expectedAdjustmentsTotal = 5d;
    double expectedTotal = 25.02d;
    assertThat(invoiceLine.getAdjustmentsTotal(), equalTo(expectedAdjustmentsTotal));
    assertThat(invoiceLine.getTotal(), equalTo(expectedTotal));
    compareRecordWithSentToStorage(invoiceLine);
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Aggregations

InvoiceLine (org.folio.rest.jaxrs.model.InvoiceLine)120 Test (org.junit.jupiter.api.Test)88 Invoice (org.folio.rest.jaxrs.model.Invoice)83 Matchers.containsString (org.hamcrest.Matchers.containsString)58 Adjustment (org.folio.rest.jaxrs.model.Adjustment)45 JsonObject (io.vertx.core.json.JsonObject)39 Errors (org.folio.rest.jaxrs.model.Errors)36 Headers (io.restassured.http.Headers)34 Error (org.folio.rest.jaxrs.model.Error)30 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)26 ArrayList (java.util.ArrayList)25 InvoiceLineCollection (org.folio.rest.jaxrs.model.InvoiceLineCollection)25 List (java.util.List)24 RequestContext (org.folio.rest.core.models.RequestContext)22 Collections (java.util.Collections)21 Fund (org.folio.rest.acq.model.finance.Fund)20 Voucher (org.folio.rest.jaxrs.model.Voucher)20 Vertx (io.vertx.core.Vertx)19 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17