use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class TestInvoiceHelper method createInvoice.
public void createInvoice(final Invoice invoice, final InternalCallContext internalCallContext) throws EntityPersistenceException {
final InvoiceModelDao invoiceModelDao = new InvoiceModelDao(invoice);
final List<InvoiceItemModelDao> invoiceItemModelDaos = ImmutableList.<InvoiceItemModelDao>copyOf(Collections2.transform(invoice.getInvoiceItems(), new Function<InvoiceItem, InvoiceItemModelDao>() {
@Override
public InvoiceItemModelDao apply(final InvoiceItem input) {
return new InvoiceItemModelDao(input);
}
}));
invoiceSqlDao.create(invoiceModelDao, internalCallContext);
for (final InvoiceItem invoiceItem : invoice.getInvoiceItems()) {
createInvoiceItem(invoiceItem, internalCallContext);
}
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class TestDefaultInvoiceMigrationApi method createAndCheckMigrationInvoice.
private UUID createAndCheckMigrationInvoice(final UUID accountId) throws InvoiceApiException {
final InvoiceItem recurringItem = new RecurringInvoiceItem(null, accountId, null, null, "planName", "phaseName", new LocalDate(2016, 2, 1), new LocalDate(2016, 3, 1), MIGRATION_INVOICE_AMOUNT, MIGRATION_INVOICE_AMOUNT, MIGRATION_INVOICE_CURRENCY);
final UUID migrationInvoiceId = invoiceUserApi.createMigrationInvoice(accountId, date_migrated, ImmutableList.of(recurringItem), callContext);
Assert.assertNotNull(migrationInvoiceId);
//Double check it was created and values are correct
final InvoiceModelDao invoice = invoiceDao.getById(migrationInvoiceId, internalCallContext);
Assert.assertNotNull(invoice);
Assert.assertEquals(invoice.getAccountId(), accountId);
//temp to avoid tz test artifact
Assert.assertEquals(invoice.getTargetDate().compareTo(date_migrated), 0);
// Assert.assertEquals(invoice.getTargetDate(),now);
Assert.assertEquals(invoice.getInvoiceItems().size(), 1);
Assert.assertEquals(invoice.getInvoiceItems().get(0).getAmount().compareTo(MIGRATION_INVOICE_AMOUNT), 0);
Assert.assertEquals(invoice.getInvoiceItems().get(0).getType(), InvoiceItemType.RECURRING);
Assert.assertEquals(InvoiceModelDaoHelper.getBalance(invoice).compareTo(BigDecimal.ZERO), 0);
Assert.assertEquals(invoice.getCurrency(), MIGRATION_INVOICE_CURRENCY);
Assert.assertTrue(invoice.isMigrated());
return migrationInvoiceId;
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testProcessedCurrencyExists.
@Test(groups = "fast")
public void testProcessedCurrencyExists() throws Exception {
// Use InvoiceModelDao to build the invoice to be able to set the processedCurrency (No suitable CTOR for DefaultInvoice on purpose)
final InvoiceModelDao invoiceModelDao = new InvoiceModelDao(UUID.randomUUID(), new LocalDate(), new LocalDate(), Currency.BRL, false);
invoiceModelDao.setProcessedCurrency(Currency.USD);
final Invoice invoice = new DefaultInvoice(invoiceModelDao);
checkOutput(invoice, "{{#invoice.processedCurrency}}" + "<tr>\n" + " <td class=\"processedCurrency\"><strong>{{invoice.processedCurrency}}</strong></td>\n" + "</tr>\n" + "{{/invoice.processedCurrency}}", "<tr>\n" + " <td class=\"processedCurrency\"><strong>USD</strong></td>\n" + "</tr>\n", Locale.US);
}
Aggregations