Search in sources :

Example 1 with FutureAccountNotificationsBuilder

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();
}
Also used : Function(com.google.common.base.Function) FutureAccountNotificationsBuilder(org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder) BillingEvent(org.killbill.billing.junction.BillingEvent) UUID(java.util.UUID)

Example 2 with FutureAccountNotificationsBuilder

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();
}
Also used : FutureAccountNotificationsBuilder(org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder)

Example 3 with FutureAccountNotificationsBuilder

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);
    }
}
Also used : ImmutableAccountData(org.killbill.billing.account.api.ImmutableAccountData) InvoiceApiException(org.killbill.billing.invoice.api.InvoiceApiException) BillingEventSet(org.killbill.billing.junction.BillingEventSet) CatalogApiException(org.killbill.billing.catalog.api.CatalogApiException) AccountApiException(org.killbill.billing.account.api.AccountApiException) FutureAccountNotificationsBuilder(org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder) SubscriptionBaseApiException(org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)

Aggregations

FutureAccountNotificationsBuilder (org.killbill.billing.invoice.InvoiceDispatcher.FutureAccountNotifications.FutureAccountNotificationsBuilder)3 Function (com.google.common.base.Function)1 UUID (java.util.UUID)1 AccountApiException (org.killbill.billing.account.api.AccountApiException)1 ImmutableAccountData (org.killbill.billing.account.api.ImmutableAccountData)1 CatalogApiException (org.killbill.billing.catalog.api.CatalogApiException)1 InvoiceApiException (org.killbill.billing.invoice.api.InvoiceApiException)1 BillingEvent (org.killbill.billing.junction.BillingEvent)1 BillingEventSet (org.killbill.billing.junction.BillingEventSet)1 SubscriptionBaseApiException (org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)1