private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StandaloneCatalog catalog) throws CatalogApiException { DefaultPriceList result = Case.getResult(priceListCase, specifier, catalog); if (result == null) { result = catalog.findCurrentPriceList(specifier.getPriceListName()); } return result; }
public BillingActionPolicy getPlanChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException { if (from.getProductName().equals(to.getProductName()) && from.getBillingPeriod() == to.getBillingPeriod() && from.getPriceListName().equals(to.getPriceListName())) { return BillingActionPolicy.ILLEGAL; } //Plan toPlan = catalog.findPlan() return CaseChange.getResult(changeCase, from, to, catalog); }
@Override public boolean canCreatePlan(final PlanSpecifier specifier) throws CatalogApiException { final Product product = findCurrentProduct(specifier.getProductName()); final Plan plan = findCurrentPlan(specifier.getProductName(), specifier.getBillingPeriod(), specifier.getPriceListName()); final DefaultPriceList priceList = findCurrentPriceList(specifier.getPriceListName()); return (!product.isRetired()) && (!plan.isRetired()) && (!priceList.isRetired()); }
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()); }
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 PlanChangeResult planChange(final PlanPhaseSpecifier from, PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException { final DefaultPriceList toPriceList; if (to.getPriceListName() == null) { // Pricelist may be null because it is unspecified this is the principal use-case toPriceList = findPriceList(from.toPlanSpecifier(), catalog); to = new PlanSpecifier(to.getProductName(), to.getProductCategory(), to.getBillingPeriod(), toPriceList.getName()); } else { toPriceList = catalog.findCurrentPriceList(to.getPriceListName()); } final BillingActionPolicy policy = getPlanChangePolicy(from, to, catalog); if (policy == BillingActionPolicy.ILLEGAL) { throw new IllegalPlanChange(from, to); } final PlanAlignmentChange alignment = getPlanChangeAlignment(from, to, catalog); return new PlanChangeResult(toPriceList, policy, alignment); }
protected boolean satisfiesCase(final PlanSpecifier planPhase, final StandaloneCatalog c) throws CatalogApiException { return (getProduct() == null || getProduct().equals(c.findCurrentProduct(planPhase.getProductName()))) && (getProductCategory() == null || getProductCategory().equals(planPhase.getProductCategory())) && (getBillingPeriod() == null || getBillingPeriod().equals(planPhase.getBillingPeriod())) && (getPriceList() == null || getPriceList().equals(c.findCurrentPriceList(planPhase.getPriceListName()))); }
public T getResult(final PlanPhaseSpecifier from, final PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException { if ( (phaseType == null || from.getPhaseType() == phaseType) && (fromProduct == null || fromProduct.equals(catalog.findCurrentProduct(from.getProductName()))) && (fromProductCategory == null || fromProductCategory.equals(from.getProductCategory())) && (fromBillingPeriod == null || fromBillingPeriod.equals(from.getBillingPeriod())) && (toProduct == null || toProduct.equals(catalog.findCurrentProduct(to.getProductName()))) && (toProductCategory == null || toProductCategory.equals(to.getProductCategory())) && (toBillingPeriod == null || toBillingPeriod.equals(to.getBillingPeriod())) && (fromPriceList == null || fromPriceList.equals(catalog.findCurrentPriceList(from.getPriceListName()))) && (toPriceList == null || toPriceList.equals(catalog.findCurrentPriceList(to.getPriceListName()))) ) { return getResult(); } return null; }