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));
}
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()));
}
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"));
}
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);
}
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);
}
Aggregations