private static DiscountMethodType GetDiscountMethodType(PeriodicDiscountOfferType periodicDiscountType, int discountTypeFromDatabase)
            {
                DiscountMethodType discountMethod = DiscountMethodType.DealPrice;

                // ISNULL(pdmm.MIXANDMATCHDISCOUNTTYPE, ISNULL(pdmb.MULTIBUYDISCOUNTTYPE, pd.PERIODICDISCOUNTTYPE))
                switch (periodicDiscountType)
                {
                case PeriodicDiscountOfferType.Offer:
                case PeriodicDiscountOfferType.Promotion:
                    discountMethod = DiscountMethodType.LineSpecific;
                    break;

                case PeriodicDiscountOfferType.MixAndMatch:
                case PeriodicDiscountOfferType.MultipleBuy:
                    discountMethod = (DiscountMethodType)discountTypeFromDatabase;
                    break;

                case PeriodicDiscountOfferType.Threshold:
                    discountMethod = DiscountMethodType.LineSpecific;
                    break;

                default:
                    NetTracer.Warning("Unsupported discount type: {0}", discountTypeFromDatabase);
                    break;
                }

                return(discountMethod);
            }
            private static DiscountOfferMethod GetLineDiscountOfferMethod(PeriodicDiscountOfferType periodicDiscountType, DiscountMethodType discountMethod, int lineDiscountMethod, int lineSpecificDiscountType)
            {
                DiscountOfferMethod offerMethod = (DiscountOfferMethod)lineDiscountMethod;

                if (periodicDiscountType == PeriodicDiscountOfferType.MixAndMatch && discountMethod == DiscountMethodType.LineSpecific)
                {
                    if (lineSpecificDiscountType == (int)DiscountMethodType.DealPrice)
                    {
                        offerMethod = DiscountOfferMethod.OfferPrice;
                    }
                    else if (lineSpecificDiscountType == (int)DiscountMethodType.DiscountPercent)
                    {
                        offerMethod = DiscountOfferMethod.DiscountPercent;
                    }
                }

                return(offerMethod);
            }
Exemple #3
0
            /// <summary>
            /// Check whether discount type matches the discount calculation mode in price context.
            /// </summary>
            /// <param name="priceContext">Price context.</param>
            /// <param name="discountType">Discount type.</param>
            /// <returns>True if discount type matches the discount calculation mode.</returns>
            public static bool MatchCalculationMode(PriceContext priceContext, PeriodicDiscountOfferType discountType)
            {
                if (priceContext == null)
                {
                    throw new ArgumentNullException("priceContext");
                }

                bool match = false;
                DiscountCalculationMode filterFlag = DiscountCalculationMode.None;

                switch (discountType)
                {
                case PeriodicDiscountOfferType.Offer:
                    filterFlag = DiscountCalculationMode.CalculateOffer;
                    break;

                case PeriodicDiscountOfferType.MultipleBuy:
                    filterFlag = DiscountCalculationMode.CalculateMultipleBuy;
                    break;

                case PeriodicDiscountOfferType.MixAndMatch:
                    filterFlag = DiscountCalculationMode.CalculateMixAndMatch;
                    break;

                case PeriodicDiscountOfferType.Threshold:
                    filterFlag = DiscountCalculationMode.CalculateThreshold;
                    break;

                default:
                    break;
                }

                if (filterFlag != DiscountCalculationMode.None)
                {
                    match = (priceContext.DiscountCalculationMode & filterFlag) != DiscountCalculationMode.None;
                }

                return(match);
            }