Search in sources :

Example 1 with InvoiceHelper

use of org.folio.rest.impl.InvoiceHelper in project mod-invoice by folio-org.

the class CreateInvoiceEventHandler method saveInvoice.

private CompletableFuture<Invoice> saveInvoice(DataImportEventPayload dataImportEventPayload, Map<String, String> okapiHeaders) {
    Invoice invoiceToSave = Json.decodeValue(dataImportEventPayload.getContext().get(INVOICE.value()), Invoice.class);
    invoiceToSave.setSource(Invoice.Source.EDI);
    InvoiceHelper invoiceHelper = new InvoiceHelper(okapiHeaders, Vertx.currentContext(), DEFAULT_LANG);
    return invoiceHelper.createInvoice(invoiceToSave).whenComplete((invoice, throwable) -> {
        if (throwable == null) {
            dataImportEventPayload.getContext().put(INVOICE.value(), Json.encode(invoice));
            return;
        }
        logger.error("Error during creation invoice in the storage", throwable);
    });
}
Also used : Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceHelper(org.folio.rest.impl.InvoiceHelper)

Aggregations

InvoiceHelper (org.folio.rest.impl.InvoiceHelper)1 Invoice (org.folio.rest.jaxrs.model.Invoice)1