Class FindBundlePricingWithCurrentPriceFactoryStrategy

  • All Implemented Interfaces:
    FindDiscountValuesStrategy, FindPriceStrategy, FindTaxValuesStrategy, ServiceLayerOnlyCalculationVerifier, UserNetCheckingStrategy, java.io.Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

    public class FindBundlePricingWithCurrentPriceFactoryStrategy
    extends FindSubscriptionPricingWithCurrentPriceFactoryStrategy
    This strategy should replace the FindPricingWithCurrentPriceFactoryStrategy and will change the discount calculation for bundle entries based on the bundle rules. So based on the products that exist in the cart in the same bundle, the price rules are evaluated and the a matching reduced price is found. Once the final price has been identified, the same logic applies as for DiscountValues and they are persisted in exactly the same way in the database as well as the calculation is don in exactly the same way.
    See Also:
    Serialized Form
    • Constructor Detail

      • FindBundlePricingWithCurrentPriceFactoryStrategy

        public FindBundlePricingWithCurrentPriceFactoryStrategy()
    • Method Detail

      • findDiscountValues

        @Nonnull
        public java.util.List<DiscountValue> findDiscountValues​(@Nonnull
                                                                AbstractOrderEntryModel entry)
                                                         throws CalculationException
        For non Bundle products it should work as is, so the DiscountValues should result from the DiscountRows defined at the product. For Bundle products it should work in a different way: All other products where the AbstractOrderEntries have the same entry group number should be added to a list for comparison. The Product of the current AbstractOrderEntry will be used to identify PriceRules from the current BundleTemplate where that product is set as a target. All conditional products of the rules have to be in the comparison list and that is how we find the matching rules. If there are still multiple matching rules, because, then the one with the lowest price in the current currency will be used as discount. That absolute discount will be converted into a relative DiscountValue for the AbstractOrderEntry only. All calculations of totals later will work as is. For subscription products the discount is applied to the 1st tier of recurring charge entries in the price plan. In case there is a price rule that can be applied to the subscription product and there is also a discount that comes from the tiered recurring charge entries, the better (= cheaper) price is used as discount. For subscription product, if the there is price rule with the billing event, the specific one time charge price reduce logic will be applied.
        Specified by:
        findDiscountValues in interface FindDiscountValuesStrategy
        Overrides:
        findDiscountValues in class FindSubscriptionPricingWithCurrentPriceFactoryStrategy
        Returns:
        List of DiscountValues
        Throws:
        CalculationException
      • reduceOneTimePrice

        protected void reduceOneTimePrice​(@Nonnull
                                          SubscriptionPricePlanModel pricePlan,
                                          @Nonnull
                                          ChangeProductPriceBundleRuleModel priceRule,
                                          @Nonnull
                                          java.util.List<DiscountValue> discountValues,
                                          @Nonnull
                                          CurrencyModel currency,
                                          @Nonnull
                                          AbstractOrderEntryModel entry)
        The price logic for subscription product: discount are applied to one time charge.
        Parameters:
        pricePlan - the subscription price plan
        priceRule - the change product price bundle rule
        discountValues - the discount values list
        currency - the currency
        entry - the order entry
      • reduceRecurringPrice

        protected void reduceRecurringPrice​(ProductModel subscriptionProduct,
                                            ChangeProductPriceBundleRuleModel priceRule,
                                            java.util.List<DiscountValue> discountValues,
                                            AbstractOrderEntryModel entry,
                                            SubscriptionPricePlanModel pricePlan)
        hard coded price logic for subscription products: discounts are only applied to recurring prices
        Parameters:
        subscriptionProduct - the subscription product
        priceRule - the change product price bundle rule
        discountValues - the discount values list
        entry - the order entry
        pricePlan - the subscription price plan
      • createDiscountValue

        protected DiscountValue createDiscountValue​(double discountPrice,
                                                    double basePrice,
                                                    java.lang.String id,
                                                    CurrencyModel currency)
        Creates a DiscountValue with an absolute reduction based on the given basePrice and the given discountPrice
        Returns:
        DiscountValue
      • setBundleRuleService

        public void setBundleRuleService​(BundleRuleService bundleRuleService)
      • setBundleTemplateService

        public void setBundleTemplateService​(BundleTemplateService bundleTemplateService)