Search in sources :

Example 1 with NextBillingDateNotificationKey

use of org.killbill.billing.invoice.notification.NextBillingDateNotificationKey in project killbill by killbill.

the class InvoiceDispatcher method getNextScheduledInvoiceEffectiveDate.

private Iterable<DateTime> getNextScheduledInvoiceEffectiveDate(final Iterable<UUID> filteredSubscriptionIds, final InternalCallContext internalCallContext) {
    try {
        final NotificationQueue notificationQueue = notificationQueueService.getNotificationQueue(DefaultInvoiceService.INVOICE_SERVICE_NAME, DefaultNextBillingDateNotifier.NEXT_BILLING_DATE_NOTIFIER_QUEUE);
        final Iterable<NotificationEventWithMetadata<NextBillingDateNotificationKey>> futureNotifications = notificationQueue.getFutureNotificationForSearchKeys(internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId());
        final Collection<DateTime> effectiveDates = new LinkedList<DateTime>();
        for (final NotificationEventWithMetadata<NextBillingDateNotificationKey> input : futureNotifications) {
            final boolean isEventForSubscription = !filteredSubscriptionIds.iterator().hasNext() || Iterables.contains(filteredSubscriptionIds, input.getEvent().getUuidKey());
            final boolean isEventDryRunForNotifications = input.getEvent().isDryRunForInvoiceNotification() != null ? input.getEvent().isDryRunForInvoiceNotification() : false;
            if (isEventForSubscription && !isEventDryRunForNotifications) {
                effectiveDates.add(input.getEffectiveDate());
            }
        }
        return effectiveDates;
    } catch (final NoSuchNotificationQueue noSuchNotificationQueue) {
        throw new IllegalStateException(noSuchNotificationQueue);
    }
}
Also used : NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) NextBillingDateNotificationKey(org.killbill.billing.invoice.notification.NextBillingDateNotificationKey) NotificationEventWithMetadata(org.killbill.notificationq.api.NotificationEventWithMetadata) NotificationQueue(org.killbill.notificationq.api.NotificationQueue) NoSuchNotificationQueue(org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue) LinkedList(java.util.LinkedList) DateTime(org.joda.time.DateTime)

Aggregations

LinkedList (java.util.LinkedList)1 DateTime (org.joda.time.DateTime)1 NextBillingDateNotificationKey (org.killbill.billing.invoice.notification.NextBillingDateNotificationKey)1 NotificationEventWithMetadata (org.killbill.notificationq.api.NotificationEventWithMetadata)1 NotificationQueue (org.killbill.notificationq.api.NotificationQueue)1 NoSuchNotificationQueue (org.killbill.notificationq.api.NotificationQueueService.NoSuchNotificationQueue)1