@Override public PlanPhaseSpecifier getPlanPhaseSpecifier() { return new PlanPhaseSpecifier(productName, term, planSet, phaseType); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("DefaultEntitlementSpecifier{"); sb.append("planName=").append(planPhaseSpecifier.getPlanName()); sb.append(", productName=").append(planPhaseSpecifier.getProductName()); sb.append(", billingPeriod=").append(planPhaseSpecifier.getBillingPeriod()); sb.append(", phaseType=").append(planPhaseSpecifier.getPhaseType()); sb.append(", priceListName=").append(planPhaseSpecifier.getPriceListName()); sb.append(", billCycleDay=").append(billCycleDay); sb.append(", overrides=").append(overrides); sb.append('}'); return sb.toString(); } }
final PlanPhaseSpecifier inputSpec = entitlementSpecifier.getPlanPhaseSpecifier(); final boolean isInputSpecNullOrEmpty = inputSpec == null || (inputSpec.getPlanName() == null && inputSpec.getProductName() == null && inputSpec.getBillingPeriod() == null); final DateTime bundleStartDate = getBundleStartDateWithSanity(bundleId, baseSubscription, plan, startEffectiveDate, addonUtils, context); final UUID subscriptionId = UUIDs.randomUUID(); dryRunEvents = apiService.getEventsOnCreation(subscriptionId, startEffectiveDate, bundleStartDate, plan, inputSpec.getPhaseType(), plan.getPriceListName(), startEffectiveDate, entitlementSpecifier.getBillCycleDay(), catalog, context); final SubscriptionBuilder builder = new SubscriptionBuilder() if (policy == null) { final Plan currentPlan = subscriptionForCancellation.getCurrentPlan(); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(currentPlan.getName(), subscriptionForCancellation.getCurrentPhase().getPhaseType()); policy = catalog.planCancelPolicy(spec, clock.getUTCNow(), subscriptionForCancellation.getStartDate());
if (phase == null) { throw new SubscriptionBaseError(String.format("No initial PlanPhase for Product %s, term %s and set %s does not exist in the catalog", spec.getProductName(), spec.getBillingPeriod().toString(), plan.getPriceListName())); subscription.setProcessedDate(context.getCreatedDate()); subscription.setPlan(plan); subscription.setInitialPhase(spec.getPhaseType()); subscription.setBuilder(new SubscriptionBuilder() .setId(UUIDs.randomUUID())
public IllegalPlanChange(final PlanPhaseSpecifier from, final PlanSpecifier to) { super(ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }
public PlanSpecifier(final PlanPhaseSpecifier planPhase) { super(); this.productName = planPhase.getProductName(); this.productCategory = planPhase.getProductCategory(); this.billingPeriod = planPhase.getBillingPeriod(); this.priceListName = planPhase.getPriceListName(); }
public T getResult(final PlanPhaseSpecifier specifier, final StaticCatalog c) throws CatalogApiException { if ((phaseType == null || specifier.getPhaseType() == phaseType) && satisfiesCase(new PlanSpecifier(specifier), c)) { return getResult(); } return null; }
.setEventPlan(existingEvent.getPlanName()) .setEventPlanPhase(currentPhase.getName()) .setEventPriceList(spec.getPriceListName()) .setEffectiveDate(effectiveDate) .setFromDisk(true);
final PlanPhaseSpecifier inputSpec = entitlementSpecifier.getPlanPhaseSpecifier(); final boolean isInputSpecNullOrEmpty = inputSpec == null || (inputSpec.getPlanName() == null && inputSpec.getProductName() == null && inputSpec.getBillingPeriod() == null); final DateTime bundleStartDate = getBundleStartDateWithSanity(bundleId, baseSubscription, plan, startEffectiveDate, addonUtils, context); final UUID subscriptionId = UUIDs.randomUUID(); dryRunEvents = apiService.getEventsOnCreation(subscriptionId, startEffectiveDate, bundleStartDate, plan, inputSpec.getPhaseType(), plan.getPriceListName(), startEffectiveDate, entitlementSpecifier.getBillCycleDay(), catalog, context); final SubscriptionBuilder builder = new SubscriptionBuilder() if (policy == null) { final Plan currentPlan = subscriptionForCancellation.getCurrentPlan(); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(currentPlan.getName(), subscriptionForCancellation.getCurrentPhase().getPhaseType()); policy = catalog.planCancelPolicy(spec, clock.getUTCNow(), subscriptionForCancellation.getStartDate());
public IllegalPlanChange(final Throwable cause, final PlanPhaseSpecifier from, final PlanSpecifier to) { super(cause, ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }
if (phase == null) { throw new SubscriptionBaseError(String.format("No initial PlanPhase for Product %s, term %s and set %s does not exist in the catalog", spec.getProductName(), spec.getBillingPeriod().toString(), plan.getPriceListName())); subscription.setProcessedDate(context.getCreatedDate()); subscription.setPlan(plan); subscription.setInitialPhase(spec.getPhaseType()); subscription.setBuilder(new SubscriptionBuilder() .setId(UUIDs.randomUUID())
@Override public boolean apply(final PlanPhasePriceOverride input) { if (input.getPhaseName() != null) { return input.getPhaseName().equals(curPhase.getName()); } // If the phaseName was not passed, we infer by matching the phaseType. This obviously would not work in a case where // a plan is defined with multiple phases of the same type. final PlanPhaseSpecifier curPlanPhaseSpecifier = input.getPlanPhaseSpecifier(); if (curPlanPhaseSpecifier.getPhaseType().equals(curPhase.getPhaseType())) { return true; } return false; } }).orNull();
.setEventPlan(existingEvent.getPlanName()) .setEventPlanPhase(currentPhase.getName()) .setEventPriceList(spec.getPriceListName()) .setEffectiveDate(effectiveDate) .setFromDisk(true);
public PlanPhaseSpecifier getProductSpecifier(final String productName, final String priceList, final BillingPeriod term, @Nullable final PhaseType phaseType) { return new PlanPhaseSpecifier(productName, term, priceList, phaseType); }
final ProductCategory inFromProductCategory; final PriceList inFromPriceList; if (from.getPlanName() != null) { final Plan plan = catalog.findCurrentPlan(from.getPlanName()); inFromProduct = plan.getProduct(); inFromBillingPeriod = plan.getRecurringBillingPeriod(); inFromPriceList = catalog.findCurrentPricelist(plan.getPriceListName()); } else { inFromProduct = catalog.findCurrentProduct(from.getProductName()); inFromBillingPeriod = from.getBillingPeriod(); inFromProductCategory = inFromProduct.getCategory(); inFromPriceList = from.getPriceListName() != null ? catalog.findCurrentPricelist(from.getPriceListName()) : null; (phaseType == null || from.getPhaseType() == phaseType) && (fromProduct == null || fromProduct.equals(inFromProduct)) && (fromProductCategory == null || fromProductCategory.equals(inFromProductCategory)) &&
public IllegalPlanChange(final Throwable cause, final PlanPhaseSpecifier from, final PlanSpecifier to) { super(cause, ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }
private void doChangePlan(final DefaultSubscriptionBase subscription, final EntitlementSpecifier spec, final DateTime effectiveDate, final CallContext context) throws SubscriptionBaseApiException, CatalogApiException { final InternalCallContext internalCallContext = createCallContextFromBundleId(subscription.getBundleId(), context); final PlanPhasePriceOverridesWithCallContext overridesWithContext = new DefaultPlanPhasePriceOverridesWithCallContext(spec.getOverrides(), context); final Catalog fullCatalog = catalogInternalApi.getFullCatalog(true, true, internalCallContext); final PlanPhaseSpecifier planPhaseSpecifier = spec.getPlanPhaseSpecifier(); final Plan newPlan = fullCatalog.createOrFindPlan(planPhaseSpecifier, overridesWithContext, effectiveDate, subscription.getStartDate()); final PhaseType initialPhaseType = planPhaseSpecifier.getPhaseType(); if (ProductCategory.ADD_ON.toString().equalsIgnoreCase(newPlan.getProduct().getCategory().toString())) { if (newPlan.getPlansAllowedInBundle() != -1 && newPlan.getPlansAllowedInBundle() > 0 && addonUtils.countExistingAddOnsWithSamePlanName(dao.getSubscriptions(subscription.getBundleId(), null, fullCatalog, internalCallContext), newPlan.getName()) >= newPlan.getPlansAllowedInBundle()) { // the plan can be changed to the new value, because it has reached its limit by bundle throw new SubscriptionBaseApiException(ErrorCode.SUB_CHANGE_AO_MAX_PLAN_ALLOWED_BY_BUNDLE, newPlan.getName()); } } if (newPlan.getProduct().getCategory() != subscription.getCategory()) { throw new SubscriptionBaseApiException(ErrorCode.SUB_CHANGE_INVALID, subscription.getId()); } final List<DefaultSubscriptionBase> addOnSubscriptionsToBeCancelled = new ArrayList<DefaultSubscriptionBase>(); final List<SubscriptionBaseEvent> addOnCancelEvents = new ArrayList<SubscriptionBaseEvent>(); final List<SubscriptionBaseEvent> changeEvents = getEventsOnChangePlan(subscription, newPlan, newPlan.getPriceListName(), effectiveDate, true, addOnSubscriptionsToBeCancelled, addOnCancelEvents, initialPhaseType, spec.getBillCycleDay(), fullCatalog, internalCallContext); dao.changePlan(subscription, changeEvents, addOnSubscriptionsToBeCancelled, addOnCancelEvents, fullCatalog, internalCallContext); subscription.rebuildTransitions(dao.getEventsForSubscription(subscription.getId(), internalCallContext), fullCatalog); }
@Override public PlanPhaseSpecifier getPlanPhaseSpecifier() { return SubscriptionBaseTransitionType.CANCEL.equals(subscriptionTransitionType) ? null : new PlanPhaseSpecifier("1-BicycleTrialEvergreen1USD", BillingPeriod.NO_BILLING_PERIOD, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.FIXEDTERM); }
public PlanSpecifier(final PlanPhaseSpecifier planPhase) { super(); this.planName = planPhase.getPlanName(); this.productName = planPhase.getProductName(); this.billingPeriod = planPhase.getBillingPeriod(); this.priceListName = planPhase.getPriceListName(); }
public IllegalPlanChange(final PlanPhaseSpecifier from, final PlanSpecifier to) { super(ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName()); }