use of org.killbill.billing.invoice.model.RecurringInvoiceItem in project killbill by killbill.
the class TestSubscriptionItemTree method testWithBCDChange2.
@Test(groups = "fast")
public void testWithBCDChange2() {
final LocalDate existingItemStartPeriod = new LocalDate(2014, 6, 20);
final LocalDate existingItemEndPeriod = new LocalDate(2014, 7, 20);
final LocalDate proposedItem1StartPeriod = new LocalDate(2014, 6, 17);
final LocalDate proposedItem1EndPeriod = new LocalDate(2014, 7, 17);
final LocalDate proposedItem2StartPeriod = proposedItem1EndPeriod;
final LocalDate proposedItem2EndPeriod = new LocalDate(2014, 8, 17);
final BigDecimal monthlyRate = new BigDecimal("10.00");
final BigDecimal fullAmount = monthlyRate;
final InvoiceItem item1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItemStartPeriod, existingItemEndPeriod, fullAmount, monthlyRate, currency);
final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(item1);
tree.build();
tree.flatten(true);
final InvoiceItem proposed1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem1StartPeriod, proposedItem1EndPeriod, fullAmount, monthlyRate, currency);
final InvoiceItem proposed2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem2StartPeriod, proposedItem2EndPeriod, fullAmount, monthlyRate, currency);
tree.mergeProposedItem(proposed1);
tree.mergeProposedItem(proposed2);
tree.buildForMerge();
final List<InvoiceItem> expectedResult = Lists.newLinkedList();
final InvoiceItem expected1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem1StartPeriod, existingItemStartPeriod, new BigDecimal("1"), monthlyRate, currency);
expectedResult.add(expected1);
final InvoiceItem expected2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItemEndPeriod, proposedItem2EndPeriod, new BigDecimal("9.03"), monthlyRate, currency);
expectedResult.add(expected2);
verifyResult(tree.getView(), expectedResult);
}
use of org.killbill.billing.invoice.model.RecurringInvoiceItem in project killbill by killbill.
the class TestSubscriptionItemTree method testWithBCDChange4.
@Test(groups = "fast")
public void testWithBCDChange4() {
final LocalDate existingItem1StartPeriod = new LocalDate(2014, 5, 17);
final LocalDate existingItem1EndPeriod = new LocalDate(2014, 5, 20);
final LocalDate existingItem2StartPeriod = existingItem1EndPeriod;
final LocalDate existingItem2EndPeriod = new LocalDate(2014, 6, 20);
final LocalDate existingItem3StartPeriod = existingItem2EndPeriod;
final LocalDate existingItem3EndPeriod = new LocalDate(2014, 7, 20);
final LocalDate existingItem4StartPeriod = existingItem3EndPeriod;
final LocalDate existingItem4EndPeriod = new LocalDate(2014, 8, 17);
final LocalDate proposedItem1StartPeriod = new LocalDate(2014, 5, 17);
final LocalDate proposedItem1EndPeriod = new LocalDate(2014, 6, 17);
final LocalDate proposedItem2StartPeriod = proposedItem1EndPeriod;
final LocalDate proposedItem2EndPeriod = new LocalDate(2014, 7, 17);
final LocalDate proposedItem3StartPeriod = proposedItem2EndPeriod;
final LocalDate proposedItem3EndPeriod = new LocalDate(2014, 8, 17);
final BigDecimal monthlyRate = new BigDecimal("10.00");
final BigDecimal fullAmount = monthlyRate;
final InvoiceItem item1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItem1StartPeriod, existingItem1EndPeriod, new BigDecimal("1"), monthlyRate, currency);
final InvoiceItem item2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItem2StartPeriod, existingItem2EndPeriod, fullAmount, monthlyRate, currency);
final InvoiceItem item3 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItem3StartPeriod, existingItem3EndPeriod, fullAmount, monthlyRate, currency);
final InvoiceItem item4 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, existingItem4StartPeriod, existingItem4EndPeriod, new BigDecimal("7"), monthlyRate, currency);
final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
tree.addItem(item1);
tree.addItem(item2);
tree.addItem(item3);
tree.addItem(item4);
tree.build();
tree.flatten(true);
final InvoiceItem proposed1 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem1StartPeriod, proposedItem1EndPeriod, fullAmount, monthlyRate, currency);
final InvoiceItem proposed2 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem2StartPeriod, proposedItem2EndPeriod, fullAmount, monthlyRate, currency);
final InvoiceItem proposed3 = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, proposedItem3StartPeriod, proposedItem3EndPeriod, fullAmount, monthlyRate, currency);
tree.mergeProposedItem(proposed1);
tree.mergeProposedItem(proposed2);
tree.mergeProposedItem(proposed3);
tree.buildForMerge();
final List<InvoiceItem> expectedResult = Lists.newLinkedList();
verifyResult(tree.getView(), expectedResult);
}
use of org.killbill.billing.invoice.model.RecurringInvoiceItem in project killbill by killbill.
the class TestSubscriptionItemTree method testWithWrongInitialItem.
@Test(groups = "fast")
public void testWithWrongInitialItem() throws IOException {
final LocalDate wrongStartDate = new LocalDate(2016, 9, 9);
final LocalDate correctStartDate = new LocalDate(2016, 9, 8);
final LocalDate endDate = new LocalDate(2016, 10, 8);
final BigDecimal rate = new BigDecimal("12.00");
final BigDecimal amount = rate;
final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
final InvoiceItem wrongInitialItem = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, wrongStartDate, endDate, amount, rate, currency);
tree.addItem(wrongInitialItem);
final InvoiceItem itemAdj = new ItemAdjInvoiceItem(wrongInitialItem, new LocalDate(2016, 10, 2), amount.negate(), currency);
tree.addItem(itemAdj);
final InvoiceItem correctInitialItem = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, correctStartDate, endDate, amount, rate, currency);
tree.flatten(true);
tree.mergeProposedItem(correctInitialItem);
tree.buildForMerge();
final InvoiceItem expected = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, productName, planName, phaseName, null, correctStartDate, wrongStartDate, new BigDecimal("0.40"), rate, currency);
final List<InvoiceItem> expectedResult = ImmutableList.<InvoiceItem>of(expected);
verifyResult(tree.getView(), expectedResult);
}
Aggregations