Search in sources :

Example 1 with BatchedVoucherType

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

the class BatchedVoucherModelConverterTest method testShouldSuccessConvertJSONModelToXMLModelIfDatesAreNull.

@Test
public void testShouldSuccessConvertJSONModelToXMLModelIfDatesAreNull() throws IOException {
    String contents = new String(Files.readAllBytes(JSON_BATCH_VOUCHER_PATH));
    BatchVoucher json = new JsonObject(contents).mapTo(BatchVoucher.class);
    BatchedVoucher batchedVoucher = json.getBatchedVouchers().get(0);
    batchedVoucher.setDisbursementDate(null);
    BatchedVoucherType batchedVoucherType = converter.convert(batchedVoucher);
    assertNotNull(batchedVoucherType);
    checkEquals(batchedVoucherType, batchedVoucher);
}
Also used : BatchVoucher(org.folio.rest.jaxrs.model.BatchVoucher) JsonObject(io.vertx.core.json.JsonObject) BatchedVoucher(org.folio.rest.jaxrs.model.BatchedVoucher) BatchedVoucherType(org.folio.rest.jaxrs.model.jaxb.BatchedVoucherType) Test(org.junit.jupiter.api.Test)

Example 2 with BatchedVoucherType

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

the class BatchedVoucherModelConverterTest method testShouldConvertJSONModelToXMLModel.

@Test
public void testShouldConvertJSONModelToXMLModel() throws IOException {
    String contents = new String(Files.readAllBytes(JSON_BATCH_VOUCHER_PATH));
    BatchVoucher json = new JsonObject(contents).mapTo(BatchVoucher.class);
    BatchedVoucher batchedVoucher = json.getBatchedVouchers().get(0);
    BatchedVoucherType batchedVoucherType = converter.convert(batchedVoucher);
    assertNotNull(batchedVoucherType);
    assertEquals(1, batchedVoucher.getAdjustments().size());
    checkEquals(batchedVoucherType, batchedVoucher);
}
Also used : BatchVoucher(org.folio.rest.jaxrs.model.BatchVoucher) JsonObject(io.vertx.core.json.JsonObject) BatchedVoucher(org.folio.rest.jaxrs.model.BatchedVoucher) BatchedVoucherType(org.folio.rest.jaxrs.model.jaxb.BatchedVoucherType) Test(org.junit.jupiter.api.Test)

Example 3 with BatchedVoucherType

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

the class BatchedVoucherModelConverter method convert.

@Override
public BatchedVoucherType convert(BatchedVoucher batchedVoucher) {
    BatchedVoucherType batchedVoucherType = new BatchedVoucherType();
    batchedVoucherType.setVoucherNumber(batchedVoucher.getVoucherNumber());
    batchedVoucherType.setAccountingCode(batchedVoucher.getAccountingCode());
    Optional.ofNullable(batchedVoucher.getAccountNo()).ifPresent(batchedVoucherType::setAccountNo);
    batchedVoucherType.setAmount(BigDecimal.valueOf(batchedVoucher.getAmount()));
    batchedVoucherType.setDisbursementNumber(batchedVoucher.getDisbursementNumber());
    if (batchedVoucher.getDisbursementDate() != null) {
        batchedVoucherType.setDisbursementDate(JAXBUtil.convertOldJavaDate(batchedVoucher.getDisbursementDate()));
    }
    batchedVoucherType.setDisbursementAmount(BigDecimal.valueOf(batchedVoucher.getAmount()));
    Optional.ofNullable(batchedVoucher.getEnclosureNeeded()).ifPresentOrElse(batchedVoucherType::setEnclosureNeeded, () -> batchedVoucherType.setEnclosureNeeded(false));
    batchedVoucherType.setExchangeRate(BigDecimal.valueOf(batchedVoucher.getExchangeRate()));
    batchedVoucherType.setInvoiceCurrency(batchedVoucher.getInvoiceCurrency());
    batchedVoucherType.setFolioInvoiceNo(batchedVoucher.getFolioInvoiceNo());
    batchedVoucherType.setInvoiceCurrency(batchedVoucher.getInvoiceCurrency());
    batchedVoucherType.setSystemCurrency(batchedVoucher.getSystemCurrency());
    batchedVoucherType.setType(PaymentAccountType.fromValue(batchedVoucher.getType().toString()));
    batchedVoucherType.setVendorInvoiceNo(batchedVoucher.getVendorInvoiceNo());
    batchedVoucherType.setVendorName(batchedVoucher.getVendorName());
    batchedVoucherType.setVendorAddress(convertVendorAddress(batchedVoucher.getVendorAddress()));
    if (batchedVoucher.getVoucherDate() != null) {
        batchedVoucherType.setVoucherDate(JAXBUtil.convertOldJavaDate(batchedVoucher.getVoucherDate()));
    }
    if (batchedVoucher.getInvoiceDate() != null) {
        batchedVoucherType.setInvoiceDate(JAXBUtil.convertOldJavaDate(batchedVoucher.getInvoiceDate()));
    }
    batchedVoucherType.setInvoiceTerms(batchedVoucher.getInvoiceTerms());
    batchedVoucherType.setInvoiceNote(batchedVoucher.getInvoiceNote());
    batchedVoucherType.setStatus(batchedVoucher.getStatus().toString());
    BatchedVoucherType.BatchedVoucherLines batchedVoucherLines = convertBatchedVoucherLines(batchedVoucher);
    batchedVoucherType.withBatchedVoucherLines(batchedVoucherLines);
    BatchedVoucherType.Adjustments adjustments = convertAdjustmentsLines(batchedVoucher);
    batchedVoucherType.withAdjustments(adjustments);
    return batchedVoucherType;
}
Also used : BatchedVoucherType(org.folio.rest.jaxrs.model.jaxb.BatchedVoucherType)

Aggregations

BatchedVoucherType (org.folio.rest.jaxrs.model.jaxb.BatchedVoucherType)3 JsonObject (io.vertx.core.json.JsonObject)2 BatchVoucher (org.folio.rest.jaxrs.model.BatchVoucher)2 BatchedVoucher (org.folio.rest.jaxrs.model.BatchedVoucher)2 Test (org.junit.jupiter.api.Test)2