private double calculateRatio(CPrice p)
        {
            MPackage pkg        = getPackage();
            String   pricingDef = pkg.DiscountDefinition;

            MIntervalConfig ivc = new MIntervalConfig(new CTable(""));

            ivc.DeserializeConfig(pricingDef);

            CPrice      o     = null;
            CBasketItem dummy = new CBasketItem("", null, p.Quantity, p.TotalAmount);

            //Gui might not see correctly earlier
            pkg.DiscountMapType = "1";
            ivc.TierScopeType   = 0;

            if (ivc.SelectionType == 1)
            {
                //step
                o = getStepDiscount(ivc, dummy);
            }
            else
            {
                //Tier
                o = getTierDiscount(ivc, dummy);
            }

            if (o != null)
            {
                //Use DiscountAmount as a temp field
                return(o.DiscountAmount);
            }

            return(-9999);
        }
        private Boolean calculateFinalDiscount(CPrice p)
        {
            Boolean  matched    = false;
            MPackage pkg        = getPackage();
            String   pricingDef = pkg.DiscountDefinition;

            MIntervalConfig ivc = new MIntervalConfig(new CTable(""));

            ivc.DeserializeConfig(pricingDef);

            CPrice      o     = null;
            CBasketItem dummy = new CBasketItem("", null, p.Quantity, p.TotalAmount);

            if (ivc.SelectionType == 1)
            {
                //step
                o = getStepDiscount(ivc, dummy);
            }
            else
            {
                //Tier
                o = getTierDiscount(ivc, dummy);
            }

            if (o != null)
            {
                res.FinalDiscount = o.DiscountAmount;
                finalDiscount     = res.FinalDiscount;
                isFinalDiscount   = true;

                matched = true;
            }

            return(matched);
        }
Exemplo n.º 3
0
        public WinAddEditIntervalConfigEx(String cfgString, String itemName, String type)
        {
            t = type;
            initComboBox();

            cfg.StepSelectionMap = outputsStep;
            cfg.TierSelectionMap = outputsTier;
            cfg.MappingTypeMap   = mappingType;

            cfg.Name = itemName;
            cfg.DeserializeConfig(cfgString);
            cfg.IsModified = false;

            this.DataContext = cfg;
            InitializeComponent();
        }
        private CBasketItem calculatePrice(CBasketItem bi)
        {
            MPackage pkg = getPackage();

            CBasketItem nbi = new CBasketItem(bi.Key, bi.Item, bi.Quantity);

            foreach (MPackagePrice pp in pkg.PackageItemPrices)
            {
                if (pp.EnabledFlag.Equals("N"))
                {
                    continue;
                }

                if (!isItemApplicable(pp, bi))
                {
                    continue;
                }

                MIntervalConfig ivc = new MIntervalConfig(new CTable(""));
                ivc.DeserializeConfig(pp.PricingDefination);

                CPrice o = null;
                if (ivc.SelectionType == 1)
                {
                    //step
                    o = getStepPrice(ivc, bi);
                }
                else
                {
                    //Tier
                    o = getTierPrice(ivc, bi);
                }

                if (o != null)
                {
                    nbi.SetAppliedPackage(pkg);
                    nbi.SetUnitPrice(o.UnitPrice);

                    return(nbi);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        private CBasketItem calculateDiscount(CBasketItem bi)
        {
            MPackage      pkg = getPackage();
            MSelectedItem vi  = (MSelectedItem)bi.Item;

            CBasketItem nbi = new CBasketItem(bi.Key, bi.Item, bi.Quantity);

            nbi.SetUnitPrice(bi.GetUnitPrice());

            foreach (MPackageTrayPriceDiscount pp in pkg.PackageTrayByItems)
            {
                if (!isItemApplicable(pp, bi))
                {
                    continue;
                }

                MIntervalConfig ivc = new MIntervalConfig(new CTable(""));
                ivc.DeserializeConfig(pp.DiscountDefination);

                CPrice o = null;
                if (ivc.SelectionType == 1)
                {
                    //step
                    o = getStepDiscount(ivc, bi);
                }
                else
                {
                    //Tier
                    o = getTierDiscount(ivc, bi);
                }

                if (o != null)
                {
                    nbi.SetAppliedPackage(pkg);
                    nbi.SetDiscount(o.DiscountAmount);

                    return(nbi);
                }
            }

            return(null);
        }
Exemplo n.º 6
0
        private CBasketItem calculatePrice(CBasketItem bi)
        {
            CBasketItem   nbi = new CBasketItem(bi.Key, bi.Item, bi.Quantity);
            MSelectedItem si  = (MSelectedItem)bi.Item;

            String pricingDef = si.PricingDefination;

            if (si.SelectionType.Equals("1"))
            {
                pricingDef = si.ServicePricingDefinition;
            }

            MIntervalConfig ivc = new MIntervalConfig(new CTable(""));

            ivc.DeserializeConfig(pricingDef);

            CPrice o = null;

            if (ivc.SelectionType == 1)
            {
                //step
                o = getStepPrice(ivc, bi);
            }
            else
            {
                //Tier
                o = getTierPrice(ivc, bi);
            }

            if (o != null)
            {
                nbi.SetAppliedPackage(getPackage());
                nbi.SetUnitPrice(o.UnitPrice);

                return(nbi);
            }

            return(null);
        }
Exemplo n.º 7
0
        private CBasketItem calculatePrice(CBasketItem bi)
        {
            MPackage        pkg        = getPackage();
            MIntervalConfig ivc        = null;
            CPrice          o          = null;
            Boolean         applicable = false;
            CBasketItem     nbi        = new CBasketItem(bi.Key, bi.Item, bi.Quantity);

            foreach (MPackageTrayPriceDiscount pp in pkg.PackageTrayByItems)
            {
                if (pp.EnabledFlag.Equals("N"))
                {
                    continue;
                }

                if (!isItemApplicable(pp, bi))
                {
                    continue;
                }

                //Applicable here

                applicable = true;

                ivc = new MIntervalConfig(new CTable(""));
                ivc.DeserializeConfig(pp.PricingDefination);

                o = null;
                if (ivc.SelectionType == 1)
                {
                    //step
                    o = getStepPrice(ivc, bi);
                }
                else
                {
                    //Tier
                    o = getTierPrice(ivc, bi);
                }

                if (o != null)
                {
                    //Got the price

                    nbi.SetAppliedPackage(pkg);
                    nbi.SetUnitPrice(o.UnitPrice);

                    return(nbi);
                }
            }

            //Applicable but price not match here, or not applicable for all

            if (!applicable)
            {
                //Not applicable for all
                return(null);
            }

            //Get Default Price here
            MSelectedItem si = (MSelectedItem)bi.Item;

            ivc = new MIntervalConfig(new CTable(""));

            String pricingDef = si.PricingDefination;

            if (si.SelectionType.Equals("1"))
            {
                pricingDef = si.ServicePricingDefinition;
            }

            ivc.DeserializeConfig(pricingDef);

            o = null;
            if (ivc.SelectionType == 1)
            {
                //step
                o = getStepPrice(ivc, bi);
            }
            else
            {
                //Tier
                o = getTierPrice(ivc, bi);
            }

            if (o != null)
            {
                nbi.SetAppliedPackage(pkg);
                nbi.SetUnitPrice(o.UnitPrice);

                return(nbi);
            }

            return(null);
        }