Search in sources :

Example 46 with DefaultInvoice

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);
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) LocalDate(org.joda.time.LocalDate) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 47 with DefaultInvoice

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);
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) LocalDate(org.joda.time.LocalDate) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 48 with DefaultInvoice

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);
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) InvoiceModelDao(org.killbill.billing.invoice.dao.InvoiceModelDao) LocalDate(org.joda.time.LocalDate) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) Test(org.testng.annotations.Test)

Example 49 with DefaultInvoice

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);
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) LocalDate(org.joda.time.LocalDate) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 50 with DefaultInvoice

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);
}
Also used : InvoicePayment(org.killbill.billing.invoice.api.InvoicePayment) DefaultInvoicePayment(org.killbill.billing.invoice.model.DefaultInvoicePayment) Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) RecurringInvoiceItem(org.killbill.billing.invoice.model.RecurringInvoiceItem) UUID(java.util.UUID) LocalDate(org.joda.time.LocalDate) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) DefaultInvoicePayment(org.killbill.billing.invoice.model.DefaultInvoicePayment) Test(org.testng.annotations.Test)

Aggregations

DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)65 Invoice (org.killbill.billing.invoice.api.Invoice)61 LocalDate (org.joda.time.LocalDate)54 Test (org.testng.annotations.Test)51 UUID (java.util.UUID)46 BigDecimal (java.math.BigDecimal)43 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)39 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)37 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)32 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)27 ItemAdjInvoiceItem (org.killbill.billing.invoice.model.ItemAdjInvoiceItem)24 MockBillingEventSet (org.killbill.billing.invoice.MockBillingEventSet)17 BillingEventSet (org.killbill.billing.junction.BillingEventSet)17 LinkedList (java.util.LinkedList)16 SubscriptionFutureNotificationDates (org.killbill.billing.invoice.generator.InvoiceWithMetadata.SubscriptionFutureNotificationDates)16 MockPlan (org.killbill.billing.catalog.MockPlan)15 MockPlanPhase (org.killbill.billing.catalog.MockPlanPhase)15 Plan (org.killbill.billing.catalog.api.Plan)15 BillingEvent (org.killbill.billing.junction.BillingEvent)15 PlanPhase (org.killbill.billing.catalog.api.PlanPhase)14