@Override public PriceList findPriceListForPlan(final String planName, final DateTime requestedDate, final DateTime subscriptionStartDate) throws CatalogApiException { final CatalogPlanEntry entry = findCatalogPlanEntry(new PlanRequestWrapper(planName), requestedDate, subscriptionStartDate); return entry.getStaticCatalog().findCurrentPricelist(entry.getPlan().getPriceListName()); }
private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException { DefaultPriceList result = DefaultCasePriceList.getResult(priceListCase, specifier, catalog); if (result == null) { final String priceListName = specifier.getPlanName() != null ? catalog.findCurrentPlan(specifier.getPlanName()).getPriceListName() : specifier.getPriceListName(); result = (DefaultPriceList) catalog.findCurrentPricelist(priceListName); } return result; }
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); }
inFromBillingPeriod = plan.getRecurringBillingPeriod(); inFromProductCategory = plan.getProduct().getCategory(); 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; inToBillingPeriod = plan.getRecurringBillingPeriod(); inToProductCategory = plan.getProduct().getCategory(); inToPriceList = catalog.findCurrentPricelist(plan.getPriceListName()); } else { inToProduct = catalog.findCurrentProduct(to.getProductName()); inToBillingPeriod = to.getBillingPeriod(); inToProductCategory = inToProduct.getCategory(); inToPriceList = to.getPriceListName() != null ? catalog.findCurrentPricelist(to.getPriceListName()) : null;
protected boolean satisfiesCase(final PlanSpecifier planPhase, final StaticCatalog c) throws CatalogApiException { final Product product; final BillingPeriod billingPeriod; final ProductCategory productCategory; final PriceList priceList; if (planPhase.getPlanName() != null) { final Plan plan = c.findCurrentPlan(planPhase.getPlanName()); product = plan.getProduct(); billingPeriod = plan.getRecurringBillingPeriod(); productCategory = plan.getProduct().getCategory(); priceList = c.findCurrentPricelist(plan.getPriceListName()); } else { product = c.findCurrentProduct(planPhase.getProductName()); billingPeriod = planPhase.getBillingPeriod(); productCategory = product.getCategory(); priceList = getPriceList() != null ? c.findCurrentPricelist(planPhase.getPriceListName()) : null; } return (getProduct() == null || getProduct().equals(product)) && (getProductCategory() == null || getProductCategory().equals(productCategory)) && (getBillingPeriod() == null || getBillingPeriod().equals(billingPeriod)) && (getPriceList() == null || getPriceList().equals(priceList)); }
@Override public PriceList findPriceListForPlan(final String planName, final DateTime requestedDate, final DateTime subscriptionStartDate) throws CatalogApiException { final CatalogPlanEntry entry = findCatalogPlanEntry(new PlanRequestWrapper(planName), requestedDate, subscriptionStartDate); return entry.getStaticCatalog().findCurrentPricelist(entry.getPlan().getPriceListName()); }
private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException { DefaultPriceList result = DefaultCasePriceList.getResult(priceListCase, specifier, catalog); if (result == null) { final String priceListName = specifier.getPlanName() != null ? catalog.findCurrentPlan(specifier.getPlanName()).getPriceListName() : specifier.getPriceListName(); result = (DefaultPriceList) catalog.findCurrentPricelist(priceListName); } return result; }
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); }
protected boolean satisfiesCase(final PlanSpecifier planPhase, final StaticCatalog c) throws CatalogApiException { final Product product; final BillingPeriod billingPeriod; final ProductCategory productCategory; final PriceList priceList; if (planPhase.getPlanName() != null) { final Plan plan = c.findCurrentPlan(planPhase.getPlanName()); product = plan.getProduct(); billingPeriod = plan.getRecurringBillingPeriod(); productCategory = plan.getProduct().getCategory(); priceList = c.findCurrentPricelist(plan.getPriceListName()); } else { product = c.findCurrentProduct(planPhase.getProductName()); billingPeriod = planPhase.getBillingPeriod(); productCategory = product.getCategory(); priceList = getPriceList() != null ? c.findCurrentPricelist(planPhase.getPriceListName()) : null; } return (getProduct() == null || getProduct().equals(product)) && (getProductCategory() == null || getProductCategory().equals(productCategory)) && (getBillingPeriod() == null || getBillingPeriod().equals(billingPeriod)) && (getPriceList() == null || getPriceList().equals(priceList)); }
inFromBillingPeriod = plan.getRecurringBillingPeriod(); inFromProductCategory = plan.getProduct().getCategory(); 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; inToBillingPeriod = plan.getRecurringBillingPeriod(); inToProductCategory = plan.getProduct().getCategory(); inToPriceList = catalog.findCurrentPricelist(plan.getPriceListName()); } else { inToProduct = catalog.findCurrentProduct(to.getProductName()); inToBillingPeriod = to.getBillingPeriod(); inToProductCategory = inToProduct.getCategory(); inToPriceList = to.getPriceListName() != null ? catalog.findCurrentPricelist(to.getPriceListName()) : null;