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