@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(); } }
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; }
@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();
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); }
subscription.setProcessedDate(context.getCreatedDate()); subscription.setPlan(plan); subscription.setInitialPhase(spec.getPhaseType()); subscription.setBuilder(new SubscriptionBuilder() .setId(UUIDs.randomUUID())
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()
(phaseType == null || from.getPhaseType() == phaseType) && (fromProduct == null || fromProduct.equals(inFromProduct)) && (fromProductCategory == null || fromProductCategory.equals(inFromProductCategory)) &&
@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(); } }
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; }
@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();
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); }
subscription.setProcessedDate(context.getCreatedDate()); subscription.setPlan(plan); subscription.setInitialPhase(spec.getPhaseType()); subscription.setBuilder(new SubscriptionBuilder() .setId(UUIDs.randomUUID())
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()
(phaseType == null || from.getPhaseType() == phaseType) && (fromProduct == null || fromProduct.equals(inFromProduct)) && (fromProductCategory == null || fromProductCategory.equals(inFromProductCategory)) &&