private Plan toDefaultPlan(final StaticCatalog staticCatalog, final Plan input) { if (tmpDefaultPlans != null) { final Plan existingPlan = tmpDefaultPlans.get(input.getName()); if (existingPlan == null) throw new IllegalStateException("Unknown plan " + input.getName()); return existingPlan; } final DefaultPlan result = new DefaultPlan(); result.setName(input.getName()); result.setPrettyName(input.getPrettyName()); result.setRecurringBillingMode(input.getRecurringBillingMode()); result.setEffectiveDateForExistingSubscriptions(input.getEffectiveDateForExistingSubscriptions()); result.setFinalPhase(toDefaultPlanPhase(input.getFinalPhase())); result.setInitialPhases(toDefaultPlanPhases(ImmutableList.copyOf(input.getInitialPhases()))); result.setPlansAllowedInBundle(input.getPlansAllowedInBundle()); result.setProduct(toDefaultProduct(input.getProduct())); result.setPriceListName(input.getPriceListName()); return result; }
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(); }
private Plan toDefaultPlan(final StaticCatalog staticCatalog, final Plan input) { if (tmpDefaultPlans != null) { final Plan existingPlan = tmpDefaultPlans.get(input.getName()); if (existingPlan == null) throw new IllegalStateException("Unknown plan " + input.getName()); return existingPlan; } final DefaultPlan result = new DefaultPlan(); result.setName(input.getName()); result.setPrettyName(input.getPrettyName()); result.setRecurringBillingMode(input.getRecurringBillingMode()); result.setEffectiveDateForExistingSubscriptions(input.getEffectiveDateForExistingSubscriptions()); result.setFinalPhase(toDefaultPlanPhase(input.getFinalPhase())); result.setInitialPhases(toDefaultPlanPhases(ImmutableList.copyOf(input.getInitialPhases()))); result.setPlansAllowedInBundle(input.getPlansAllowedInBundle()); result.setProduct(toDefaultProduct(input.getProduct())); result.setPriceListName(input.getPriceListName()); return result; }
Mockito.when(plan.getName()).thenReturn("plan"); Mockito.when(plan.getProduct()).thenReturn(product); Mockito.when(plan.getRecurringBillingMode()).thenReturn(BillingMode.IN_ADVANCE);
Mockito.when(plan.getProduct()).thenReturn(product); Mockito.when(plan.getRecurringBillingMode()).thenReturn(BillingMode.IN_ADVANCE);