BillingEvent.getPlan
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.killbill.billing.junction.BillingEvent.getPlan(Showing top 15 results out of 315)

origin: org.kill-bill.billing/killbill-invoice

public String getPlanName() {
  return billingEvents.get(0).getPlan().getName();
}
origin: org.kill-bill.billing/killbill-junction

@Test(groups = "fast")
public void testCreateNewDisableEvent() throws CatalogApiException {
  final DateTime now = clock.getUTCNow();
  final BillingEvent event = new MockBillingEvent();
  final BillingEvent result = blockingCalculator.createNewDisableEvent(now, event, null);
  assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal());
  assertEquals(result.getEffectiveDate(), now);
  assertEquals(result.getPlanPhase(), event.getPlanPhase());
  assertEquals(result.getPlan(), event.getPlan());
  assertNull(result.getFixedPrice());
  assertNull(result.getRecurringPrice(null));
  assertEquals(result.getCurrency(), event.getCurrency());
  assertEquals(result.getDescription(), "");
  assertEquals(result.getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD);
  assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.START_BILLING_DISABLED);
  // TODO - ugly, fragile
  assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1));
}
origin: org.kill-bill.billing/killbill-junction

protected BillingEvent createNewDisableEvent(final DateTime disabledDurationStart, final BillingEvent previousEvent, final Catalog catalog) throws CatalogApiException {
  final int billCycleDay = previousEvent.getBillCycleDayLocal();
  final SubscriptionBase subscription = previousEvent.getSubscription();
  final DateTime effectiveDate = disabledDurationStart;
  final PlanPhase planPhase = previousEvent.getPlanPhase();
  final Plan plan = previousEvent.getPlan();
  // Make sure to set the fixed price to null and the billing period to NO_BILLING_PERIOD,
  // which makes invoice disregard this event
  final BigDecimal fixedPrice = null;
  final BillingPeriod billingPeriod = BillingPeriod.NO_BILLING_PERIOD;
  final Currency currency = previousEvent.getCurrency();
  final String description = "";
  final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.START_BILLING_DISABLED;
  final Long totalOrdering = globaltotalOrder.getAndIncrement();
  return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice,
                  currency,
                  billingPeriod, billCycleDay,
                  description, totalOrdering, type, catalog, true);
}
origin: org.kill-bill.billing/killbill-invoice

private InvoiceItem generateFixedPriceItem(final UUID invoiceId, final UUID accountId, final BillingEvent thisEvent,
                      final LocalDate targetDate, final Currency currency,
                      final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger, final InternalCallContext internalCallContext) throws InvoiceApiException {
  final LocalDate roundedStartDate = internalCallContext.toLocalDate(thisEvent.getEffectiveDate());
  if (roundedStartDate.isAfter(targetDate)) {
    return null;
  } else {
    final BigDecimal fixedPrice = thisEvent.getFixedPrice();
    if (fixedPrice != null) {
      final FixedPriceInvoiceItem fixedPriceInvoiceItem = new FixedPriceInvoiceItem(invoiceId, accountId, thisEvent.getSubscription().getBundleId(),
                                             thisEvent.getSubscription().getId(),
                                             thisEvent.getPlan().getName(), thisEvent.getPlanPhase().getName(),
                                             roundedStartDate, fixedPrice, currency);
      // For debugging purposes
      invoiceItemGeneratorLogger.append(thisEvent, fixedPriceInvoiceItem);
      return fixedPriceInvoiceItem;
    } else {
      return null;
    }
  }
}
origin: org.kill-bill.billing/killbill-invoice

protected BillingEvent createMockBillingEvent(final DateTime effectiveDate, final BillingPeriod billingPeriod, final List<Usage> usages) {
  final BillingEvent result = Mockito.mock(BillingEvent.class);
  Mockito.when(result.getCurrency()).thenReturn(Currency.BTC);
  Mockito.when(result.getBillCycleDayLocal()).thenReturn(BCD);
  Mockito.when(result.getEffectiveDate()).thenReturn(effectiveDate);
  Mockito.when(result.getBillingPeriod()).thenReturn(billingPeriod);
  final Account account = Mockito.mock(Account.class);
  Mockito.when(account.getId()).thenReturn(accountId);
  final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class);
  Mockito.when(subscription.getId()).thenReturn(subscriptionId);
  Mockito.when(subscription.getBundleId()).thenReturn(bundleId);
  Mockito.when(result.getSubscription()).thenReturn(subscription);
  final Plan plan = Mockito.mock(Plan.class);
  Mockito.when(plan.getName()).thenReturn(planName);
  Mockito.when(result.getPlan()).thenReturn(plan);
  final PlanPhase phase = Mockito.mock(PlanPhase.class);
  Mockito.when(phase.getName()).thenReturn(phaseName);
  Mockito.when(result.getPlanPhase()).thenReturn(phase);
  Mockito.when(result.getUsages()).thenReturn(usages);
  return result;
}
origin: org.kill-bill.billing/killbill-junction

private void checkEvent(final BillingEvent event, final Plan nextPlan, final int BCD, final UUID id, final DateTime time,
            final PlanPhase nextPhase, final String desc, final InternationalPrice fixedPrice, final InternationalPrice recurringPrice) throws CatalogApiException {
  if (fixedPrice != null) {
    Assert.assertEquals(fixedPrice.getPrice(Currency.USD), event.getFixedPrice());
  } else {
    assertNull(event.getFixedPrice());
  }
  if (recurringPrice != null) {
    Assert.assertEquals(recurringPrice.getPrice(Currency.USD), event.getRecurringPrice(null));
  } else {
    assertNull(event.getRecurringPrice(null));
  }
  Assert.assertEquals(BCD, event.getBillCycleDayLocal());
  Assert.assertEquals(id, event.getSubscription().getId());
  Assert.assertEquals(time.getDayOfMonth(), event.getEffectiveDate().getDayOfMonth());
  Assert.assertEquals(nextPhase, event.getPlanPhase());
  Assert.assertEquals(nextPlan, event.getPlan());
  if (!SubscriptionBaseTransitionType.START_BILLING_DISABLED.equals(event.getTransitionType())) {
    Assert.assertEquals(nextPhase.getRecurring().getBillingPeriod(), event.getBillingPeriod());
  }
  Assert.assertEquals(desc, event.getTransitionType().toString());
}
origin: org.kill-bill.billing/killbill-invoice

private void processRecurringBillingEvents(final UUID invoiceId, final UUID accountId, final BillingEventSet events,
                      final LocalDate targetDate, final Currency currency, final List<InvoiceItem> proposedItems,
                      final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDate,
                      final InternalCallContext internalCallContext) throws InvoiceApiException {
  if (events.isEmpty()) {
    return;
  }
  // Pretty-print the generated invoice items from the junction events
  final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, accountId, "recurring", log);
  final Iterator<BillingEvent> eventIt = events.iterator();
  BillingEvent nextEvent = eventIt.next();
  while (eventIt.hasNext()) {
    final BillingEvent thisEvent = nextEvent;
    nextEvent = eventIt.next();
    if (!events.getSubscriptionIdsWithAutoInvoiceOff().
        contains(thisEvent.getSubscription().getId())) { // don't consider events for subscriptions that have auto_invoice_off
      final BillingEvent adjustedNextEvent = (thisEvent.getSubscription().getId() == nextEvent.getSubscription().getId()) ? nextEvent : null;
      final List<InvoiceItem> newProposedItems = processRecurringEvent(invoiceId, accountId, thisEvent, adjustedNextEvent, targetDate, currency, invoiceItemGeneratorLogger, thisEvent.getPlan().getRecurringBillingMode(), perSubscriptionFutureNotificationDate, internalCallContext);
      proposedItems.addAll(newProposedItems);
    }
  }
  final List<InvoiceItem> newProposedItems = processRecurringEvent(invoiceId, accountId, nextEvent, null, targetDate, currency, invoiceItemGeneratorLogger, nextEvent.getPlan().getRecurringBillingMode(), perSubscriptionFutureNotificationDate, internalCallContext);
  proposedItems.addAll(newProposedItems);
  invoiceItemGeneratorLogger.logItems();
}
origin: org.kill-bill.billing/killbill-junction

@Test(groups = "fast")
public void testCreateNewReenableEvent() throws CatalogApiException {
  final DateTime now = clock.getUTCNow();
  final BillingEvent event = new MockBillingEvent();
  final BillingEvent result = blockingCalculator.createNewReenableEvent(now, event, null, internalCallContext);
  assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal());
  assertEquals(result.getEffectiveDate(), now);
  assertEquals(result.getPlanPhase(), event.getPlanPhase());
  assertEquals(result.getPlan(), event.getPlan());
  assertEquals(result.getFixedPrice(), event.getFixedPrice());
  assertEquals(result.getRecurringPrice(null), event.getRecurringPrice(null));
  assertEquals(result.getCurrency(), event.getCurrency());
  assertEquals(result.getDescription(), "");
  assertEquals(result.getBillingPeriod(), event.getBillingPeriod());
  assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED);
  // TODO - ugly, fragile
  assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1));
}
origin: org.kill-bill.billing/killbill-junction

protected BillingEvent createNewReenableEvent(final DateTime odEventTime, final BillingEvent previousEvent, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException {
  // All fields are populated with the event state from before the blocking period, for invoice to resume invoicing
  final int billCycleDay = previousEvent.getBillCycleDayLocal();
  final SubscriptionBase subscription = previousEvent.getSubscription();
  final DateTime effectiveDate = odEventTime;
  final PlanPhase planPhase = previousEvent.getPlanPhase();
  final BigDecimal fixedPrice = previousEvent.getFixedPrice();
  final Plan plan = previousEvent.getPlan();
  final Currency currency = previousEvent.getCurrency();
  final String description = "";
  final BillingPeriod billingPeriod = previousEvent.getBillingPeriod();
  final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.END_BILLING_DISABLED;
  final Long totalOrdering = globaltotalOrder.getAndIncrement();
  return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice,
                  currency,
                  billingPeriod, billCycleDay,
                  description, totalOrdering, type, catalog, false);
}
origin: org.kill-bill.billing/killbill-junction

@Test(groups = "fast")
public void testCreateNewReenableEvent() throws CatalogApiException {
  final DateTime now = clock.getUTCNow();
  final BillingEvent event = new MockBillingEvent();
  final BillingEvent result = blockingCalculator.createNewReenableEvent(now, event, null, internalCallContext);
  assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal());
  assertEquals(result.getEffectiveDate(), now);
  assertEquals(result.getPlanPhase(), event.getPlanPhase());
  assertEquals(result.getPlan(), event.getPlan());
  assertEquals(result.getFixedPrice(), event.getFixedPrice());
  assertEquals(result.getRecurringPrice(null), event.getRecurringPrice(null));
  assertEquals(result.getCurrency(), event.getCurrency());
  assertEquals(result.getDescription(), "");
  assertEquals(result.getBillingPeriod(), event.getBillingPeriod());
  assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED);
  // TODO - ugly, fragile
  assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1));
}
origin: org.kill-bill.billing/killbill-junction

@Test(groups = "fast")
public void testCreateNewDisableEvent() throws CatalogApiException {
  final DateTime now = clock.getUTCNow();
  final BillingEvent event = new MockBillingEvent();
  final BillingEvent result = blockingCalculator.createNewDisableEvent(now, event, null);
  assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal());
  assertEquals(result.getEffectiveDate(), now);
  assertEquals(result.getPlanPhase(), event.getPlanPhase());
  assertEquals(result.getPlan(), event.getPlan());
  assertNull(result.getFixedPrice());
  assertNull(result.getRecurringPrice(null));
  assertEquals(result.getCurrency(), event.getCurrency());
  assertEquals(result.getDescription(), "");
  assertEquals(result.getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD);
  assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.START_BILLING_DISABLED);
  // TODO - ugly, fragile
  assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1));
}
origin: org.kill-bill.billing/killbill-junction

protected BillingEvent createNewReenableEvent(final DateTime odEventTime, final BillingEvent previousEvent, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException {
  // All fields are populated with the event state from before the blocking period, for invoice to resume invoicing
  final int billCycleDay = previousEvent.getBillCycleDayLocal();
  final SubscriptionBase subscription = previousEvent.getSubscription();
  final DateTime effectiveDate = odEventTime;
  final PlanPhase planPhase = previousEvent.getPlanPhase();
  final BigDecimal fixedPrice = previousEvent.getFixedPrice();
  final Plan plan = previousEvent.getPlan();
  final Currency currency = previousEvent.getCurrency();
  final String description = "";
  final BillingPeriod billingPeriod = previousEvent.getBillingPeriod();
  final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.END_BILLING_DISABLED;
  final Long totalOrdering = globaltotalOrder.getAndIncrement();
  return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice,
                  currency,
                  billingPeriod, billCycleDay,
                  description, totalOrdering, type, catalog, false);
}
origin: org.kill-bill.billing/killbill-junction

protected BillingEvent createNewDisableEvent(final DateTime disabledDurationStart, final BillingEvent previousEvent, final Catalog catalog) throws CatalogApiException {
  final int billCycleDay = previousEvent.getBillCycleDayLocal();
  final SubscriptionBase subscription = previousEvent.getSubscription();
  final DateTime effectiveDate = disabledDurationStart;
  final PlanPhase planPhase = previousEvent.getPlanPhase();
  final Plan plan = previousEvent.getPlan();
  // Make sure to set the fixed price to null and the billing period to NO_BILLING_PERIOD,
  // which makes invoice disregard this event
  final BigDecimal fixedPrice = null;
  final BillingPeriod billingPeriod = BillingPeriod.NO_BILLING_PERIOD;
  final Currency currency = previousEvent.getCurrency();
  final String description = "";
  final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.START_BILLING_DISABLED;
  final Long totalOrdering = globaltotalOrder.getAndIncrement();
  return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice,
                  currency,
                  billingPeriod, billCycleDay,
                  description, totalOrdering, type, catalog, true);
}
origin: org.kill-bill.billing/killbill-invoice

private InvoiceItem generateFixedPriceItem(final UUID invoiceId, final UUID accountId, final BillingEvent thisEvent,
                      final LocalDate targetDate, final Currency currency,
                      final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger, final InternalCallContext internalCallContext) throws InvoiceApiException {
  final LocalDate roundedStartDate = internalCallContext.toLocalDate(thisEvent.getEffectiveDate());
  if (roundedStartDate.isAfter(targetDate)) {
    return null;
  } else {
    final BigDecimal fixedPrice = thisEvent.getFixedPrice();
    if (fixedPrice != null) {
      final FixedPriceInvoiceItem fixedPriceInvoiceItem = new FixedPriceInvoiceItem(invoiceId, accountId, thisEvent.getSubscription().getBundleId(),
                                             thisEvent.getSubscription().getId(),
                                             thisEvent.getPlan().getName(), thisEvent.getPlanPhase().getName(),
                                             roundedStartDate, fixedPrice, currency);
      // For debugging purposes
      invoiceItemGeneratorLogger.append(thisEvent, fixedPriceInvoiceItem);
      return fixedPriceInvoiceItem;
    } else {
      return null;
    }
  }
}
origin: org.kill-bill.billing/killbill-invoice

private void processRecurringBillingEvents(final UUID invoiceId, final UUID accountId, final BillingEventSet events,
                      final LocalDate targetDate, final Currency currency, final List<InvoiceItem> proposedItems,
                      final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDate,
                      final InternalCallContext internalCallContext) throws InvoiceApiException {
  if (events.isEmpty()) {
    return;
  }
  // Pretty-print the generated invoice items from the junction events
  final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger = new InvoiceItemGeneratorLogger(invoiceId, accountId, "recurring", log);
  final Iterator<BillingEvent> eventIt = events.iterator();
  BillingEvent nextEvent = eventIt.next();
  while (eventIt.hasNext()) {
    final BillingEvent thisEvent = nextEvent;
    nextEvent = eventIt.next();
    if (!events.getSubscriptionIdsWithAutoInvoiceOff().
        contains(thisEvent.getSubscription().getId())) { // don't consider events for subscriptions that have auto_invoice_off
      final BillingEvent adjustedNextEvent = (thisEvent.getSubscription().getId() == nextEvent.getSubscription().getId()) ? nextEvent : null;
      final List<InvoiceItem> newProposedItems = processRecurringEvent(invoiceId, accountId, thisEvent, adjustedNextEvent, targetDate, currency, invoiceItemGeneratorLogger, thisEvent.getPlan().getRecurringBillingMode(), perSubscriptionFutureNotificationDate, internalCallContext);
      proposedItems.addAll(newProposedItems);
    }
  }
  final List<InvoiceItem> newProposedItems = processRecurringEvent(invoiceId, accountId, nextEvent, null, targetDate, currency, invoiceItemGeneratorLogger, nextEvent.getPlan().getRecurringBillingMode(), perSubscriptionFutureNotificationDate, internalCallContext);
  proposedItems.addAll(newProposedItems);
  invoiceItemGeneratorLogger.logItems();
}
org.killbill.billing.junctionBillingEventgetPlan

Popular methods of BillingEvent

  • getBillCycleDayLocal
  • getBillingPeriod
  • getCurrency
  • getEffectiveDate
  • getPlanPhase
  • getSubscription
  • getFixedPrice
  • getTotalOrdering
  • getUsages
  • getRecurringPrice
  • getTransitionType
  • compareTo
  • getTransitionType,
  • compareTo,
  • getDescription

Popular classes and methods

  • setRequestProperty (URLConnection)
    Sets the value of the specified request header field. The value will only be used by the current URL
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Graphics2D (java.awt)
  • BufferedImage (java.awt.image)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)