use of org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceItemGeneratorLogger in project killbill by killbill.
the class TestFixedAndRecurringInvoiceItemGenerator method testInArrear2.
//
// Scenario:
// - IN_ARREAR
// - one CREATE billing event
// - targetDate < CREATE date
//
// => Expect nothing
//
@Test(groups = "fast")
public void testInArrear2() throws InvoiceApiException {
final BillingMode billingMode = BillingMode.IN_ARREAR;
final UUID invoiceId = UUID.randomUUID();
final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, account.getId(), "recurring", logger);
final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDates = new HashMap<>();
final LocalDate eventDate1 = new LocalDate("2020-01-01");
final BillingEvent event1 = createDefaultBillingEvent(eventDate1, null, BigDecimal.TEN, SubscriptionBaseTransitionType.CREATE, 1, 1, billingMode);
final LocalDate targetDate = eventDate1.minusDays(1);
final List<InvoiceItem> invoiceItems = fixedAndRecurringInvoiceItemGenerator.processRecurringEvent(invoiceId, account.getId(), event1, null, targetDate, account.getCurrency(), invoiceItemGeneratorLogger, perSubscriptionFutureNotificationDates, internalCallContext);
assertEquals(invoiceItems.size(), 0);
final SubscriptionFutureNotificationDates notifications = perSubscriptionFutureNotificationDates.get(subscription.getId());
assertNull(notifications);
}
use of org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceItemGeneratorLogger in project killbill by killbill.
the class TestFixedAndRecurringInvoiceItemGenerator method testInAdvance1.
//
//
// PROCESS_RECURRING_EVENT TESTS
//
//
//
// Scenario:
// - IN_ADVANCE
// - one CREATE billing event
// - targetDate = CREATE date
//
// => Expect one item + 1 notification
//
@Test(groups = "fast")
public void testInAdvance1() throws InvoiceApiException {
final BillingMode billingMode = BillingMode.IN_ADVANCE;
final UUID invoiceId = UUID.randomUUID();
final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, account.getId(), "recurring", logger);
final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDates = new HashMap<>();
final LocalDate eventDate1 = new LocalDate("2020-01-01");
final BillingEvent event1 = createDefaultBillingEvent(eventDate1, null, BigDecimal.TEN, SubscriptionBaseTransitionType.CREATE, 1, 1, billingMode);
final LocalDate targetDate = eventDate1;
final List<InvoiceItem> invoiceItems = fixedAndRecurringInvoiceItemGenerator.processRecurringEvent(invoiceId, account.getId(), event1, null, targetDate, account.getCurrency(), invoiceItemGeneratorLogger, perSubscriptionFutureNotificationDates, internalCallContext);
assertEquals(invoiceItems.size(), 1);
assertEquals(invoiceItems.get(0).getStartDate(), eventDate1);
assertEquals(invoiceItems.get(0).getEndDate(), eventDate1.plusMonths(1));
assertEquals(invoiceItems.get(0).getAmount().compareTo(BigDecimal.TEN), 0);
final SubscriptionFutureNotificationDates notifications = perSubscriptionFutureNotificationDates.get(subscription.getId());
assertEquals(notifications.getNextRecurringDate(), eventDate1.plusMonths(1));
}
use of org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceItemGeneratorLogger in project killbill by killbill.
the class TestFixedAndRecurringInvoiceItemGenerator method testInArrear3.
//
// Scenario:
// - IN_ARREAR
// - one CREATE billing event
// - targetDate in the future (> 1 billingPeriod)
//
// => Expect 1 item item + 1 notification
//
@Test(groups = "fast")
public void testInArrear3() throws InvoiceApiException {
final BillingMode billingMode = BillingMode.IN_ARREAR;
final UUID invoiceId = UUID.randomUUID();
final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, account.getId(), "recurring", logger);
final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDates = new HashMap<>();
final LocalDate eventDate1 = new LocalDate("2020-01-01");
final BillingEvent event1 = createDefaultBillingEvent(eventDate1, null, BigDecimal.TEN, SubscriptionBaseTransitionType.CREATE, 1, 1, billingMode);
final LocalDate targetDate = eventDate1.plusMonths(1);
final List<InvoiceItem> invoiceItems = fixedAndRecurringInvoiceItemGenerator.processRecurringEvent(invoiceId, account.getId(), event1, null, targetDate, account.getCurrency(), invoiceItemGeneratorLogger, perSubscriptionFutureNotificationDates, internalCallContext);
assertEquals(invoiceItems.size(), 1);
assertEquals(invoiceItems.get(0).getStartDate(), eventDate1);
assertEquals(invoiceItems.get(0).getEndDate(), eventDate1.plusMonths(1));
assertEquals(invoiceItems.get(0).getAmount().compareTo(BigDecimal.TEN), 0);
final SubscriptionFutureNotificationDates notifications = perSubscriptionFutureNotificationDates.get(subscription.getId());
assertEquals(notifications.getNextRecurringDate(), eventDate1.plusMonths(2));
}
use of org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceItemGeneratorLogger in project killbill by killbill.
the class TestFixedAndRecurringInvoiceItemGenerator method testInAdvance2.
//
// Scenario:
// - IN_ADVANCE
// - one CREATE billing event
// - targetDate < CREATE date
//
// => Expect nothing
//
@Test(groups = "fast")
public void testInAdvance2() throws InvoiceApiException {
final BillingMode billingMode = BillingMode.IN_ADVANCE;
final UUID invoiceId = UUID.randomUUID();
final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, account.getId(), "recurring", logger);
final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDates = new HashMap<>();
final LocalDate eventDate1 = new LocalDate("2020-01-01");
final BillingEvent event1 = createDefaultBillingEvent(eventDate1, null, BigDecimal.TEN, SubscriptionBaseTransitionType.CREATE, 1, 1, billingMode);
final LocalDate targetDate = eventDate1.minusDays(1);
final List<InvoiceItem> invoiceItems = fixedAndRecurringInvoiceItemGenerator.processRecurringEvent(invoiceId, account.getId(), event1, null, targetDate, account.getCurrency(), invoiceItemGeneratorLogger, perSubscriptionFutureNotificationDates, internalCallContext);
assertEquals(invoiceItems.size(), 0);
final SubscriptionFutureNotificationDates notifications = perSubscriptionFutureNotificationDates.get(subscription.getId());
assertNull(notifications);
}
Aggregations