use of org.killbill.billing.invoice.model.DefaultInvoice in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testFormattedAmountUSAndBRL.
@Test(groups = "fast")
public void testFormattedAmountUSAndBRL() throws Exception {
final FixedPriceInvoiceItem fixedItem = new FixedPriceInvoiceItem(UUID.randomUUID(), UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), new LocalDate(), new BigDecimal("2635.14"), Currency.BRL);
final Invoice invoice = new DefaultInvoice(UUID.randomUUID(), new LocalDate(), new LocalDate(), Currency.BRL);
invoice.addInvoiceItem(fixedItem);
checkOutput(invoice, "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedChargedAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedPaidAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedBalance}}</strong></td>\n" + "</tr>", "<tr>\n" + " <td class=\"amount\"><strong>R$2,635.14</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>R$0.00</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>R$2,635.14</strong></td>\n" + "</tr>", Locale.US);
}
use of org.killbill.billing.invoice.model.DefaultInvoice in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testFormattedAmountFranceAndEUR.
@Test(groups = "fast")
public void testFormattedAmountFranceAndEUR() throws Exception {
final FixedPriceInvoiceItem fixedItemEUR = new FixedPriceInvoiceItem(UUID.randomUUID(), UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), new LocalDate(), new BigDecimal("1499.95"), Currency.EUR);
final Invoice invoiceEUR = new DefaultInvoice(UUID.randomUUID(), new LocalDate(), new LocalDate(), Currency.EUR);
invoiceEUR.addInvoiceItem(fixedItemEUR);
checkOutput(invoiceEUR, "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedChargedAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedPaidAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedBalance}}</strong></td>\n" + "</tr>", "<tr>\n" + " <td class=\"amount\"><strong>1 499,95 €</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>0,00 €</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>1 499,95 €</strong></td>\n" + "</tr>", Locale.FRANCE);
}
use of org.killbill.billing.invoice.model.DefaultInvoice 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);
}
use of org.killbill.billing.invoice.model.DefaultInvoice in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testFormattedAmountFranceAndJPY.
@Test(groups = "fast")
public void testFormattedAmountFranceAndJPY() throws Exception {
final FixedPriceInvoiceItem fixedItem = new FixedPriceInvoiceItem(UUID.randomUUID(), UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), new LocalDate(), new BigDecimal("1500.00"), Currency.JPY);
final Invoice invoice = new DefaultInvoice(UUID.randomUUID(), new LocalDate(), new LocalDate(), Currency.JPY);
invoice.addInvoiceItem(fixedItem);
checkOutput(invoice, "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedChargedAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedPaidAmount}}</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>{{invoice.formattedBalance}}</strong></td>\n" + "</tr>", "<tr>\n" + " <td class=\"amount\"><strong>1 500 ¥</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>0 ¥</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>1 500 ¥</strong></td>\n" + "</tr>", Locale.FRANCE);
}
use of org.killbill.billing.invoice.model.DefaultInvoice in project killbill by killbill.
the class TestInvoiceDao method testAccountBalance.
@Test(groups = "slow")
public void testAccountBalance() throws EntityPersistenceException {
final UUID accountId = account.getId();
final UUID bundleId = UUID.randomUUID();
final LocalDate targetDate1 = new LocalDate(2011, 10, 6);
final Invoice invoice1 = new DefaultInvoice(accountId, clock.getUTCToday(), targetDate1, Currency.USD);
invoiceUtil.createInvoice(invoice1, context);
final LocalDate startDate = new LocalDate(2011, 3, 1);
final LocalDate endDate = startDate.plusMonths(1);
final BigDecimal rate1 = new BigDecimal("17.0");
final BigDecimal rate2 = new BigDecimal("42.0");
final RecurringInvoiceItem item1 = new RecurringInvoiceItem(invoice1.getId(), accountId, bundleId, UUID.randomUUID(), "test plan", "test phase A", startDate, endDate, rate1, rate1, Currency.USD);
invoiceUtil.createInvoiceItem(item1, context);
final RecurringInvoiceItem item2 = new RecurringInvoiceItem(invoice1.getId(), accountId, bundleId, UUID.randomUUID(), "test plan", "test phase B", startDate, endDate, rate2, rate2, Currency.USD);
invoiceUtil.createInvoiceItem(item2, context);
final BigDecimal payment1 = new BigDecimal("48.0");
final InvoicePayment payment = new DefaultInvoicePayment(InvoicePaymentType.ATTEMPT, UUID.randomUUID(), invoice1.getId(), new DateTime(), payment1, Currency.USD, Currency.USD, null, true);
invoiceUtil.createPayment(payment, context);
final BigDecimal balance = invoiceDao.getAccountBalance(accountId, context);
assertEquals(balance.compareTo(rate1.add(rate2).subtract(payment1)), 0);
}
Aggregations