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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }