public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException { final DefaultPriceList toPriceList = to.getPriceListName() != null ? (DefaultPriceList) catalog.findCurrentPricelist(to.getPriceListName()) : findPriceList(from, catalog); // If we use old scheme {product, billingPeriod, pricelist}, ensure pricelist is correct // (Pricelist may be null because if it is unspecified this is the principal use-case) final PlanSpecifier toWithPriceList = to.getPlanName() == null ? new PlanSpecifier(to.getProductName(), to.getBillingPeriod(), toPriceList.getName()) : to; final BillingActionPolicy policy = getPlanChangePolicy(from, toWithPriceList, catalog); if (policy == BillingActionPolicy.ILLEGAL) { throw new IllegalPlanChange(from, toWithPriceList); } final PlanAlignmentChange alignment = getPlanChangeAlignment(from, toWithPriceList, catalog); return new PlanChangeResult(toPriceList, policy, alignment); }
public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException { final DefaultPriceList toPriceList = to.getPriceListName() != null ? (DefaultPriceList) catalog.findCurrentPricelist(to.getPriceListName()) : findPriceList(from, catalog); // If we use old scheme {product, billingPeriod, pricelist}, ensure pricelist is correct // (Pricelist may be null because if it is unspecified this is the principal use-case) final PlanSpecifier toWithPriceList = to.getPlanName() == null ? new PlanSpecifier(to.getProductName(), to.getBillingPeriod(), toPriceList.getName()) : to; final BillingActionPolicy policy = getPlanChangePolicy(from, toWithPriceList, catalog); if (policy == BillingActionPolicy.ILLEGAL) { throw new IllegalPlanChange(from, toWithPriceList); } final PlanAlignmentChange alignment = getPlanChangeAlignment(from, toWithPriceList, catalog); return new PlanChangeResult(toPriceList, policy, alignment); }