use of org.killbill.billing.invoice.model.FixedPriceInvoiceItem in project killbill by killbill.
the class TestContiguousIntervalCapacityInArrear method testComputeToBeBilledUsage.
@Test(groups = "fast")
public void testComputeToBeBilledUsage() throws Exception {
final LocalDate startDate = new LocalDate(2014, 03, 20);
final LocalDate endDate = new LocalDate(2014, 04, 20);
final DefaultUnit unit = new DefaultUnit().setName("unit");
final DefaultLimit limit = new DefaultLimit().setUnit(unit).setMax((double) 100);
final DefaultTier tier = createDefaultTierWithLimits(BigDecimal.TEN, limit);
final DefaultUsage usage = createCapacityInArrearUsage(usageName, BillingPeriod.MONTHLY, tier);
final LocalDate targetDate = startDate.plusDays(1);
final ContiguousIntervalUsageInArrear intervalCapacityInArrear = createContiguousIntervalCapacityInArrear(usage, ImmutableList.<RawUsageRecord>of(), targetDate, false, createMockBillingEvent(targetDate.toDateTimeAtStartOfDay(DateTimeZone.UTC), BillingPeriod.MONTHLY, Collections.<Usage>emptyList(), catalogEffectiveDate));
final List<InvoiceItem> existingUsage = Lists.newArrayList();
final UsageInvoiceItem ii1 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii1);
final UsageInvoiceItem ii2 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii2);
// Will be ignored as is starts one day earlier.
final UsageInvoiceItem ii3 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate.minusDays(1), endDate, BigDecimal.TEN, currency);
existingUsage.add(ii3);
// Will be ignored as it is for a different udsage section
final UsageInvoiceItem ii4 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, "other", null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii4);
// Will be ignored because non usage item
final FixedPriceInvoiceItem ii5 = new FixedPriceInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, startDate, BigDecimal.TEN, currency);
existingUsage.add(ii5);
final Iterable<InvoiceItem> billedItems = intervalCapacityInArrear.getBilledItems(startDate, endDate, existingUsage);
final BigDecimal result = intervalCapacityInArrear.computeBilledUsage(billedItems);
assertEquals(result.compareTo(BigDecimal.TEN.add(BigDecimal.TEN)), 0);
}
use of org.killbill.billing.invoice.model.FixedPriceInvoiceItem in project killbill by killbill.
the class TestContiguousIntervalConsumableInArrear method testComputeToBeBilledUsage.
@Test(groups = "fast")
public void testComputeToBeBilledUsage() throws Exception {
final LocalDate startDate = new LocalDate(2014, 03, 20);
final LocalDate endDate = new LocalDate(2014, 04, 20);
final DefaultTieredBlock block = createDefaultTieredBlock("unit", 100, 1000, BigDecimal.ONE);
final DefaultTier tier = createDefaultTierWithBlocks(block);
final DefaultUsage usage = createConsumableInArrearUsage(usageName, BillingPeriod.MONTHLY, TierBlockPolicy.ALL_TIERS, tier);
final LocalDate targetDate = startDate.plusDays(1);
final ContiguousIntervalUsageInArrear intervalConsumableInArrear = createContiguousIntervalConsumableInArrear(usage, ImmutableList.<RawUsageRecord>of(), targetDate, false, createMockBillingEvent(targetDate.toDateTimeAtStartOfDay(DateTimeZone.UTC), BillingPeriod.MONTHLY, Collections.<Usage>emptyList(), catalogEffectiveDate));
final List<InvoiceItem> existingUsage = Lists.newArrayList();
final UsageInvoiceItem ii1 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii1);
final UsageInvoiceItem ii2 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii2);
// Will be ignored as is starts one day earlier.
final UsageInvoiceItem ii3 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, usage.getName(), null, startDate.minusDays(1), endDate, BigDecimal.TEN, currency);
existingUsage.add(ii3);
// Will be ignored as it is for a different udsage section
final UsageInvoiceItem ii4 = new UsageInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, "other", null, startDate, endDate, BigDecimal.TEN, currency);
existingUsage.add(ii4);
// Will be ignored because non usage item
final FixedPriceInvoiceItem ii5 = new FixedPriceInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, startDate, BigDecimal.TEN, currency);
existingUsage.add(ii5);
final BigDecimal result = intervalConsumableInArrear.computeBilledUsage(intervalConsumableInArrear.getBilledItems(startDate, endDate, existingUsage));
assertEquals(result.compareTo(BigDecimal.TEN.add(BigDecimal.TEN)), 0);
}
use of org.killbill.billing.invoice.model.FixedPriceInvoiceItem in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testFormattedAmountFranceAndJPY.
@Test(groups = "fast", enabled = false, description = "JDK dependent")
public void testFormattedAmountFranceAndJPY() throws Exception {
final FixedPriceInvoiceItem fixedItem = new FixedPriceInvoiceItem(UUID.randomUUID(), UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), null, 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.FixedPriceInvoiceItem in project killbill by killbill.
the class TestDefaultInvoiceFormatter method testFormattedAmountFranceAndOMR.
@Test(groups = "fast", enabled = false, description = "JDK dependent")
public void testFormattedAmountFranceAndOMR() throws Exception {
final FixedPriceInvoiceItem fixedItem = new FixedPriceInvoiceItem(UUID.randomUUID(), UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), null, new LocalDate(), new BigDecimal("1499.958"), Currency.OMR);
final Invoice invoice = new DefaultInvoice(UUID.randomUUID(), new LocalDate(), new LocalDate(), Currency.OMR);
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 499,958 ر.ع</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>0,000 ر.ع</strong></td>\n" + "</tr>\n" + "<tr>\n" + " <td class=\"amount\"><strong>1 499,958 ر.ع</strong></td>\n" + "</tr>", Locale.FRANCE);
}
use of org.killbill.billing.invoice.model.FixedPriceInvoiceItem 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(), UUID.randomUUID().toString(), null, 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);
}
Aggregations