use of org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder in project killbill by killbill.
the class InvoiceDispatcher method createNextFutureNotificationDate.
private FutureAccountNotifications createNextFutureNotificationDate(final DateTime rescheduleDate, final BillingEventSet billingEvents, final InternalCallContext context) {
final FutureAccountNotificationsBuilder notificationsBuilder = new FutureAccountNotificationsBuilder();
notificationsBuilder.setRescheduled(true);
final Set<UUID> subscriptionIds = ImmutableSet.<UUID>copyOf(Iterables.<BillingEvent, UUID>transform(billingEvents, new Function<BillingEvent, UUID>() {
@Override
public UUID apply(final BillingEvent billingEvent) {
return billingEvent.getSubscriptionId();
}
}));
populateNextFutureNotificationDate(rescheduleDate, subscriptionIds, notificationsBuilder, context);
// Even though a plugin forced us to reschedule the invoice generation, honor the dry run notifications settings
populateNextFutureDryRunNotificationDate(billingEvents, notificationsBuilder, context);
return notificationsBuilder.build();
}
use of org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder in project killbill by killbill.
the class InvoiceDispatcher method createNextFutureNotificationDate.
private FutureAccountNotifications createNextFutureNotificationDate(final InvoiceWithMetadata invoiceWithMetadata, final BillingEventSet billingEvents, final InternalCallContext context) {
final FutureAccountNotificationsBuilder notificationsBuilder = new FutureAccountNotificationsBuilder();
populateNextFutureNotificationDate(invoiceWithMetadata, notificationsBuilder);
populateNextFutureDryRunNotificationDate(billingEvents, notificationsBuilder, context);
return notificationsBuilder.build();
}
use of org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder in project killbill by killbill.
the class InvoiceDispatcher method processSubscriptionStartRequestedDateWithLock.
private void processSubscriptionStartRequestedDateWithLock(final UUID accountId, final RequestedSubscriptionInternalEvent transition, final InternalCallContext context) {
try {
// TODO
// Can we use cutoffDt ?
// Do we even need the billing events ?
final BillingEventSet billingEvents = billingApi.getBillingEventsForAccountAndUpdateAccountBCD(accountId, null, null, context);
if (billingEvents.isEmpty()) {
return;
}
final FutureAccountNotificationsBuilder notificationsBuilder = new FutureAccountNotificationsBuilder();
populateNextFutureDryRunNotificationDate(billingEvents, notificationsBuilder, context);
final ImmutableAccountData account = accountApi.getImmutableAccountDataById(accountId, context);
setFutureNotifications(account, notificationsBuilder.build(), context);
} catch (final SubscriptionBaseApiException e) {
log.warn("Failed handling SubscriptionBase change.", new InvoiceApiException(ErrorCode.INVOICE_NO_ACCOUNT_ID_FOR_SUBSCRIPTION_ID, transition.getSubscriptionId().toString()));
} catch (final AccountApiException e) {
log.warn("Failed to retrieve BillingEvents for accountId='{}'", accountId, e);
} catch (final CatalogApiException e) {
log.warn("Failed to retrieve BillingEvents for accountId='{}'", accountId, e);
}
}
Aggregations