public CatalogUpdater(final DateTime effectiveDate, final Currency... currencies) { final DefaultPriceList defaultPriceList = new DefaultPriceList().setName(PriceListSet.DEFAULT_PRICELIST_NAME); final StandaloneCatalog tmp = new StandaloneCatalog() .setCatalogName(DEFAULT_CATALOG_NAME) .setEffectiveDate(effectiveDate.toDate()) .setRecurringBillingMode(BillingMode.IN_ADVANCE) .setProducts(ImmutableList.<Product>of()) .setPlans(ImmutableList.<Plan>of()) .setPriceLists(new DefaultPriceListSet(defaultPriceList, new DefaultPriceList[0])) .setPlanRules(getSaneDefaultPlanRules(defaultPriceList)); if (currencies != null && currencies.length > 0) { tmp.setSupportedCurrencies(currencies); } else { tmp.setSupportedCurrencies(new Currency[0]); } tmp.initialize(tmp); this.catalog = new DefaultMutableStaticCatalog(tmp); }
public MockPlan(final String name, final DefaultProduct product, final DefaultPlanPhase[] planPhases, final DefaultPlanPhase finalPhase, final int plansAllowedInBundle) { this.staticCatalog = new StandaloneCatalog(new Date()); setName(name); setProduct(product); setFinalPhase(finalPhase); setInitialPhases(planPhases); setPlansAllowedInBundle(plansAllowedInBundle); setRecurringBillingMode(BillingMode.IN_ADVANCE); setPriceListName(DefaultPriceListSet.DEFAULT_PRICELIST_NAME); finalPhase.setPlan(this); for (final DefaultPlanPhase pp : planPhases) { pp.setPlan(this); } }
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog) { final StandaloneCatalog result = new StandaloneCatalog(); result.setCatalogName(catalogName); result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate()); result.setProducts(toDefaultProducts(pluginCatalog.getProducts())); result.setPlans(toDefaultPlans(result, pluginCatalog.getPlans())); result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList())); result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies())); result.setUnits(toDefaultUnits(pluginCatalog.getUnits())); result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules())); for (final Product cur : pluginCatalog.getProducts()) { final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName()); if (target != null) { ((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable())); ((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded())); } } result.initialize(result); return result; }
public CatalogUpdater(final DateTime effectiveDate, final Currency... currencies) { final DefaultPriceList defaultPriceList = new DefaultPriceList().setName(PriceListSet.DEFAULT_PRICELIST_NAME); final StandaloneCatalog tmp = new StandaloneCatalog() .setCatalogName(DEFAULT_CATALOG_NAME) .setEffectiveDate(effectiveDate.toDate()) .setRecurringBillingMode(BillingMode.IN_ADVANCE) .setProducts(ImmutableList.<Product>of()) .setPlans(ImmutableList.<Plan>of()) .setPriceLists(new DefaultPriceListSet(defaultPriceList, new DefaultPriceList[0])) .setPlanRules(getSaneDefaultPlanRules(defaultPriceList)); if (currencies != null && currencies.length > 0) { tmp.setSupportedCurrencies(currencies); } else { tmp.setSupportedCurrencies(new Currency[0]); } tmp.initialize(tmp); this.catalog = new DefaultMutableStaticCatalog(tmp); }
public MockPlan(final String name, final DefaultProduct product, final DefaultPlanPhase[] planPhases, final DefaultPlanPhase finalPhase, final int plansAllowedInBundle) { this.staticCatalog = new StandaloneCatalog(new Date()); setName(name); setProduct(product); setFinalPhase(finalPhase); setInitialPhases(planPhases); setPlansAllowedInBundle(plansAllowedInBundle); setRecurringBillingMode(BillingMode.IN_ADVANCE); setPriceListName(DefaultPriceListSet.DEFAULT_PRICELIST_NAME); finalPhase.setPlan(this); for (final DefaultPlanPhase pp : planPhases) { pp.setPlan(this); } }
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog) { final StandaloneCatalog result = new StandaloneCatalog(); result.setCatalogName(catalogName); result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate()); result.setProducts(toDefaultProducts(pluginCatalog.getProducts())); result.setPlans(toDefaultPlans(result, pluginCatalog.getPlans())); result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList())); result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies())); result.setUnits(toDefaultUnits(pluginCatalog.getUnits())); result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules())); for (final Product cur : pluginCatalog.getProducts()) { final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName()); if (target != null) { ((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable())); ((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded())); } } result.initialize(result); return result; }