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; }
Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly")); Assert.assertEquals(e.getCode(), ErrorCode.CAT_NO_SUCH_PLAN.getCode()); Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly-1")); Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly-12345"));
@Test(groups = "fast", description = "https://github.com/killbill/killbill/issues/842") public void testCreateAmbiguousPlan() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final SimplePlanDescriptor desc = new DefaultSimplePlanDescriptor("foo-monthly-12345", "Foo", ProductCategory.BASE, Currency.EUR, BigDecimal.TEN, BillingPeriod.MONTHLY, 0, TimeUnit.UNLIMITED, ImmutableList.<String>of()); final CatalogUpdater catalogUpdater = new CatalogUpdater(now, desc.getCurrency()); catalogUpdater.addSimplePlanDescriptor(desc); final StandaloneCatalog catalog = catalogUpdater.getCatalog(); assertEquals(catalog.getCurrentPlans().size(), 1); final StaticCatalog standaloneCatalogWithPriceOverride = new StandaloneCatalogWithPriceOverride(catalog, priceOverride, internalCallContext.getTenantRecordId(), internalCallContextFactory); final Plan plan = catalog.findCurrentPlan("foo-monthly-12345"); assertEquals(plan.getName(), "foo-monthly-12345"); // Verify PriceOverride logic final Plan plan2 = standaloneCatalogWithPriceOverride.findCurrentPlan("foo-monthly-12345"); assertEquals(plan2.getName(), "foo-monthly-12345"); final PlanPhase planPhase = catalog.findCurrentPhase("foo-monthly-12345-evergreen"); assertEquals(planPhase.getName(), "foo-monthly-12345-evergreen"); // Verify PriceOverride logic final PlanPhase phase2 = standaloneCatalogWithPriceOverride.findCurrentPhase("foo-monthly-12345-evergreen"); assertEquals(phase2.getName(), "foo-monthly-12345-evergreen"); }
final PriceList inFromPriceList; if (from.getPlanName() != null) { final Plan plan = catalog.findCurrentPlan(from.getPlanName()); inFromProduct = plan.getProduct(); inFromBillingPeriod = plan.getRecurringBillingPeriod(); final PriceList inToPriceList; if (to.getPlanName() != null) { final Plan plan = catalog.findCurrentPlan(to.getPlanName()); inToProduct = plan.getProduct(); inToBillingPeriod = plan.getRecurringBillingPeriod();
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)); }
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; }
Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly")); Assert.assertEquals(e.getCode(), ErrorCode.CAT_NO_SUCH_PLAN.getCode()); Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly-1")); Assert.assertNotNull(standaloneCatalogWithPriceOverride.findCurrentPlan("standard-monthly-12345"));
@Test(groups = "fast", description = "https://github.com/killbill/killbill/issues/842") public void testCreateAmbiguousPlan() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final SimplePlanDescriptor desc = new DefaultSimplePlanDescriptor("foo-monthly-12345", "Foo", ProductCategory.BASE, Currency.EUR, BigDecimal.TEN, BillingPeriod.MONTHLY, 0, TimeUnit.UNLIMITED, ImmutableList.<String>of()); final CatalogUpdater catalogUpdater = new CatalogUpdater(now, desc.getCurrency()); catalogUpdater.addSimplePlanDescriptor(desc); final StandaloneCatalog catalog = catalogUpdater.getCatalog(); assertEquals(catalog.getCurrentPlans().size(), 1); final StaticCatalog standaloneCatalogWithPriceOverride = new StandaloneCatalogWithPriceOverride(catalog, priceOverride, internalCallContext.getTenantRecordId(), internalCallContextFactory); final Plan plan = catalog.findCurrentPlan("foo-monthly-12345"); assertEquals(plan.getName(), "foo-monthly-12345"); // Verify PriceOverride logic final Plan plan2 = standaloneCatalogWithPriceOverride.findCurrentPlan("foo-monthly-12345"); assertEquals(plan2.getName(), "foo-monthly-12345"); final PlanPhase planPhase = catalog.findCurrentPhase("foo-monthly-12345-evergreen"); assertEquals(planPhase.getName(), "foo-monthly-12345-evergreen"); // Verify PriceOverride logic final PlanPhase phase2 = standaloneCatalogWithPriceOverride.findCurrentPhase("foo-monthly-12345-evergreen"); assertEquals(phase2.getName(), "foo-monthly-12345-evergreen"); }
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)); }
final PriceList inFromPriceList; if (from.getPlanName() != null) { final Plan plan = catalog.findCurrentPlan(from.getPlanName()); inFromProduct = plan.getProduct(); inFromBillingPeriod = plan.getRecurringBillingPeriod(); final PriceList inToPriceList; if (to.getPlanName() != null) { final Plan plan = catalog.findCurrentPlan(to.getPlanName()); inToProduct = plan.getProduct(); inToBillingPeriod = plan.getRecurringBillingPeriod();