public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            PurchaseLimitType limitType = PurchaseLimitType.Volume;
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }
            if (tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "HROI", "HRNA", "HRBL" }).Count() == 3)
            {
                limitType = PurchaseLimitType.None;
            }

            else if (tins != null
                     &&
                     (tins.Select(c => c.IDType.Key).Intersect(new[] { "HROI", "HRNA", "HRRP" }).Count() == 3 ||
                      tins.Select(c => c.IDType.Key).Intersect(new[] { "HROI", "HRNA", "HRPI" }).Count() == 3)
                     )
            {
                limitType = PurchaseLimitType.Volume;
            }
            limits.PurchaseLimitType = limitType;
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            SetLimits(orderMonth, manager, limits);
        }
Example #2
0
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            Dictionary <int, PurchasingLimits_V01> currentLimits = base.GetPurchasingLimits(distributorId, TIN);
            PurchasingLimits_V01 theLimits  = currentLimits[PurchasingLimitProvider.GetOrderMonth()];
            PurchaseLimitType    limitsType = PurchaseLimitType.ProductCategory;

            var  tins     = DistributorOrderingProfileProvider.GetTinList(distributorId, true);
            bool bHasMYID = tins.Find(t => t.IDType.Key == "MYID") != null;

            if (!DistributorIsExemptFromPurchasingLimits(distributorId))
            {
                limitsType = PurchaseLimitType.Volume;
                if (!bHasMYID)
                {
                    limitsType = PurchaseLimitType.ProductCategory;
                }
            }
            else
            {
                if (bHasMYID)
                {
                    limitsType = PurchaseLimitType.None;
                }
            }
            currentLimits.Values.AsQueryable().ToList().ForEach(pl => pl.PurchaseLimitType = limitsType);

            return(currentLimits);
        }
Example #3
0
        protected void ddl_OrderType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(ddl_OrderType.SelectedItem.Value))
            {
                OnOrderSubTypeChanged(sender, e);
                //bool refresh = false;
                PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_OrderType.SelectedItem.Value);

                ShoppingCart.SelectedDSSubType = ddl_OrderType.SelectedItem.Value;
                lblOrderTypeVal.Text           = ddl_OrderType.SelectedItem.ToString();

                //If the order type is switched to Resale and DS has added APFs to cart, throw them out
                if (ddl_OrderType.SelectedItem.Value == OrderTypesBG.CO.ToString() &&
                    APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems) &&
                    !APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale))
                {
                    ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList());
                    // refresh = true;
                }

                if (ShoppingCart.CartItems.Count > 0)
                {
                    List <ShoppingCartRuleResult> results = HLRulesManager.Manager.ProcessCart(ShoppingCart,
                                                                                               ShoppingCartRuleReason
                                                                                               .CartCalculated);
                    if (results.Count > 0 && results.Any(r => r.Result == RulesResult.Failure))
                    {
                        foreach (ShoppingCartRuleResult result in results)
                        {
                            if (result.Result == RulesResult.Failure)
                            {
                                var args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]);
                                OnCartItemRemovedDueToSKULimitationRules(this, args);
                            }
                        }
                    }
                }

                if (HasMemberVPLimitations())
                {
                    PurchaseLimitType limitType = PurchaseLimitType.Volume;
                    limits.PurchaseLimitType = limitType;
                    DisplayRemaining(ShoppingCart.SelectedDSSubType);
                }
                else
                {
                    PurchaseLimitType limitType = PurchaseLimitType.None;
                    limits.PurchaseLimitType = limitType;
                }
            }
            else
            {
                ShoppingCart.SelectedDSSubType = String.Empty;
                trRemainingVal.Visible         = false;
                lblOrderTypeVal.Text           = String.Empty;
            }
        }
Example #4
0
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            //check if is a elearning and set the new limits for the second order
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            var currentLimits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (HLConfigManager.Configurations.ShoppingCartConfiguration.CheckELearning)
            {
                PurchaseLimitType limitType = PurchaseLimitType.Volume;
                currentLimits.PurchaseLimitType = limitType;
                var session = SessionInfo.GetSessionInfo(distributorId, Locale);
                if (PurchaseRestrictionProvider.RequireTraining(distributorId, this.Locale, this.Country))
                {
                    if (currentLimits.RemainingVolume != currentLimits.maxVolumeLimit && !session.LimitsHasModified)
                    {
                        var used     = (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                        var shouldbe = 1100 - used;
                        currentLimits.PurchaseLimitType = limitType;
                        if (currentLimits.RemainingVolume != shouldbe && shouldbe > 0 && !session.LimitsHasModified)
                        {
                            currentLimits.RemainingVolume = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                            session.LimitsHasModified     = true;
                        }
                    }
                    //check for the members without limits and create
                    else if (currentLimits.RemainingVolume == -1 && currentLimits.maxVolumeLimit == -1 && !session.LimitsHasModified)
                    {
                        var currentLoggedInCounrtyCode      = Locale.Substring(3);
                        DistributorLoader distributorLoader = new DistributorLoader();
                        var distributorProfile = distributorLoader.Load(distributorId, currentLoggedInCounrtyCode);

                        var remainingVolume = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - distributorProfile.PersonallyPurchasedVolume;
                        //PurchasingLimits_V01 newLimits = new PurchasingLimits_V01();
                        currentLimits.Month                 = currentLimits.Month;
                        currentLimits.LastRead              = DateTime.UtcNow;
                        currentLimits.RemainingVolume       = distributorProfile.PersonallyPurchasedVolume != 0 ? remainingVolume : 0;
                        currentLimits.LimitsRestrictionType = LimitsRestrictionType.PurchasingLimits;
                        currentLimits.PurchaseLimitType     = limitType;
                        currentLimits.LastRead              = DateTime.UtcNow;
                        currentLimits.maxVolumeLimit        = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV;
                        session.LimitsHasModified           = true;
                    }
                }
            }
            else
            {
                base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            }

            if (currentLimits == null)
            {
                return;
            }
            SetLimits(orderMonth, manager, currentLimits);
        }
        private void checkLimits(MyHLShoppingCart hlCart)
        {
            var currentLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(hlCart.DistributorID);

            var    session      = SessionInfo.GetSessionInfo(hlCart.DistributorID, hlCart.Locale);
            string trainingCode = HLConfigManager.Configurations.ShoppingCartConfiguration.TrainingCode;

            if (session.DsTrainings == null || session.DsTrainings.Count == 0)
            {
                session.DsTrainings = DistributorOrderingProfileProvider.GetTrainingList(hlCart.DistributorID, hlCart.CountryCode);
            }
            if (session.DsTrainings != null && session.DsTrainings.Count > 0 &&
                session.DsTrainings.Exists(t => t.TrainingCode == trainingCode && !t.TrainingFlag))
            {
                //if is true the member place an order without taking the training and the limits shoud be applicable for only 1100
                if (currentLimits.RemainingVolume != currentLimits.maxVolumeLimit && !session.LimitsHasModified)
                {
                    var used     = (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                    var shouldbe = 1100 - used;
                    PurchaseLimitType limitType = PurchaseLimitType.Volume;
                    currentLimits.PurchaseLimitType = limitType;
                    if (currentLimits.RemainingVolume != shouldbe && shouldbe > 0 && !session.LimitsHasModified)
                    {
                        currentLimits.RemainingVolume = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                        session.LimitsHasModified     = true;
                    }
                    string country = DistributorProfileModel.ProcessingCountryCode;
                    PurchasingLimitProvider.savePurchasingLimitsToCache(ConvertCurrentLimitsToSave(currentLimits), hlCart.DistributorID);
                    PurchasingLimitProvider.SavePurchaseLimitsToStore(country, hlCart.DistributorID);
                }
                //check for the members without limits and create
                else if (currentLimits.RemainingVolume == -1 && currentLimits.maxVolumeLimit == -1 && !session.LimitsHasModified)
                {
                    var currentLoggedInCounrtyCode      = Locale.Substring(3);
                    DistributorLoader distributorLoader = new DistributorLoader();
                    var distributorProfile = distributorLoader.Load(hlCart.DistributorID, currentLoggedInCounrtyCode);

                    var remainingVolume         = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - distributorProfile.PersonallyPurchasedVolume;
                    PurchaseLimitType limitType = PurchaseLimitType.Volume;
                    //PurchasingLimits_V01 newLimits = new PurchasingLimits_V01();
                    currentLimits.Month                 = currentLimits.Month;
                    currentLimits.LastRead              = DateTime.UtcNow;
                    currentLimits.RemainingVolume       = distributorProfile.PersonallyPurchasedVolume != 0 ? remainingVolume : 0;
                    currentLimits.LimitsRestrictionType = LimitsRestrictionType.PurchasingLimits;
                    currentLimits.PurchaseLimitType     = limitType;
                    currentLimits.LastRead              = DateTime.UtcNow;
                    currentLimits.maxVolumeLimit        = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV;
                    session.LimitsHasModified           = true;
                    string country = DistributorProfileModel.ProcessingCountryCode;
                    PurchasingLimitProvider.savePurchasingLimitsToCache(ConvertCurrentLimitsToSave(currentLimits), hlCart.DistributorID);
                    PurchasingLimitProvider.SavePurchaseLimitsToStore(country, hlCart.DistributorID);
                }
            }
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            if (manager.ApplicableLimits == null)
            {
                return;
            }

            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            PurchaseLimitType limitType = PurchaseLimitType.Volume;
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            bool isForeignMember = IsForeignMember(CURRENT_COUNTRY);

            if (isForeignMember)  //Foreign member have a restriction of 7500 VPs per year
            {
                limitType = PurchaseLimitType.Volume;
                setValues(limits, PurchasingLimitRestrictionPeriod.Annually, limits.RemainingVolume);
            }
            else  //BY members
            {
                if (HasValidTinCodes(tins))
                {
                    limitType = PurchaseLimitType.None;  //no limitations for members with valid tin codes
                }
                else
                {
                    limitType = PurchaseLimitType.Volume;
                    setValues(limits, PurchasingLimitRestrictionPeriod.Annually, limits.RemainingVolume);
                }
            }

            if (limits != null)
            {
                if (limits.maxVolumeLimit == -1 && limits.MaxEarningsLimit == -1)
                {
                    limits.PurchaseLimitType = PurchaseLimitType.None;
                }
                else
                {
                    limits.PurchaseLimitType = limitType;
                }
                SetLimits(orderMonth, manager, limits);
            }
        }
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            Dictionary <int, PurchasingLimits_V01> currentLimits = base.GetPurchasingLimits(distributorId, TIN);
            PurchasingLimits_V01 theLimits  = currentLimits[PurchasingLimitProvider.GetOrderMonth()];
            PurchaseLimitType    limitsType = PurchaseLimitType.ProductCategory;
            var tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true);

            List <string> codes = new List <string>(CountryType.SG.HmsCountryCodes);

            codes.Add(CountryType.SG.Key);

            if (tins != null)
            {
                TaxIdentification tid = null;
                if ((tid = tins.Find(t => t.IDType.Key == "SNID")) != null)
                {
                    limitsType = PurchaseLimitType.None;
                }
                else
                {
                    // no SNID
                    if (codes.Contains(DistributorProfileModel.ProcessingCountryCode))
                    {
                        limitsType = PurchaseLimitType.None;
                    }
                }
            }

            // DS with Dummy TIN No "S0000000S", can purchase any category of products up to 1100 vp per order
            if (tins != null && tins.Find(t => t.ID == "S0000000S") != null)
            {
                limitsType = PurchaseLimitType.Volume;
                theLimits.RemainingVolume = MaxVolPoints;
            }

            if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorId))
            {
                limitsType = PurchaseLimitType.Volume;
            }
            currentLimits.Values.AsQueryable().ToList().ForEach(pl => pl.PurchaseLimitType = limitsType);

            return(currentLimits);
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            if (manager.ApplicableLimits == null)
            {
                return;
            }

            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            PurchaseLimitType limitType = PurchaseLimitType.Volume;
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            var now = DateUtils.GetCurrentLocalTime("SK");

            foreach (TaxIdentification taxId in tins)
            {
                if (taxId.IDType != null && (taxId.IDType.Key == "SKBL" && taxId.IDType.ExpirationDate > now))
                {
                    limitType = PurchaseLimitType.None;
                    break;
                }
            }

            if (limits != null)
            {
                if (limits.maxVolumeLimit == -1 && limits.MaxEarningsLimit == -1)
                {
                    limits.PurchaseLimitType = PurchaseLimitType.None;
                }
                else
                {
                    limits.PurchaseLimitType = limitType;
                }
                SetLimits(orderMonth, manager, limits);
            }
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            PurchaseLimitType limitType = PurchaseLimitType.TotalPaid;

            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            // have all four tins, no limit
            if (tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "GRVT", "GRTN", "GRSS", "GRBL" }).Count() == 4)
            {
                limitType = PurchaseLimitType.None;
            }

            limits.PurchaseLimitType = limitType;
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            SetLimits(orderMonth, manager, limits);
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, Providers.FOP.IPurchaseRestrictionManager manager)
        {
            if (manager.ApplicableLimits == null)
            {
                return;
            }

            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            PurchaseLimitType limitType = PurchaseLimitType.Volume;
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            if (!HLConfigManager.Configurations.DOConfiguration.EnforcesPurchasingPermissions)
            {
                var now = DateUtils.GetCurrentLocalTime(COUNTRY_TIME);

                var  idTIN      = RetrieveIDTinCode(tins);
                bool isDummyTIN = IsDummyTin(idTIN);
                bool isIDCOP    = IsIDCountryOfProcessing();

                if (idTIN != null && !isDummyTIN)
                {
                    if (idTIN.IDType.ExpirationDate > now) //tin non expired and processing country any
                    {
                        limitType = PurchaseLimitType.None;
                    }
                    else if (!isIDCOP)  //tin expired and foreign member
                    {
                        limitType = PurchaseLimitType.Volume;
                        setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1000.00m);
                    }
                }
                else if (isDummyTIN)  //with dummy TIN purchase restriction per order 1000 VPs
                {
                    limitType = PurchaseLimitType.Volume;
                    setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1000.00m);
                }
                else //no TINs found
                {
                    if (!isIDCOP)  //foreign members can purchase with a limit of 1000 VPs per order
                    {
                        limitType = PurchaseLimitType.Volume;
                        setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1000.00m);
                    }
                    else //ID members with no TIN codes can't buy
                    {
                        limitType = PurchaseLimitType.Volume;
                        setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 0.00m);
                    }
                }
            }

            if (limits != null)
            {
                if (limits.maxVolumeLimit == -1 && limits.MaxEarningsLimit == -1)
                {
                    limits.PurchaseLimitType = PurchaseLimitType.None;
                }
                else
                {
                    limits.PurchaseLimitType = limitType;
                }
                SetLimits(orderMonth, manager, limits);
            }
        }
Example #11
0
        /// <summary>
        /// if DS has purchasing limits
        /// </summary>
        /// <param name="tins"></param>
        /// <param name="orderMonth"></param>
        /// <param name="distributorId"></param>
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            //if (manager.PurchasingLimits == null)
            //    return;

            if (manager.ApplicableLimits == null)
            {
                return;
            }

            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            PurchaseLimitType limitType = PurchaseLimitType.Volume;
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            //if (!manager.CanPurchase)
            //     return;

            switch (this.Country)
            {
            case "BA":
            {
                //DS without BATX are restricted to 5000VPs
                limitType = tins.Find(t => t.IDType.Key == "BATX") != null ? PurchaseLimitType.None : limitType;
            }
            break;

            case "BE":
            {
                if (HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionType == PurchasingLimitRestrictionType.Annually &&
                    tins.Any(t => t.IDType.Key == "BENO" || t.IDType.Key == "BEVT"))
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "BY":
            {
                limitType = PurchaseLimitType.None;
            }
            break;

            case "CO":
            {
                if ((new List <string>(CountryType.CO.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.CO.Key
                    }).Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            //case "FR":
            //    {
            //        limitType = _IPurchaseRestrictionManager.OrderSubType != "F" ? PurchaseLimitType.None : limitType;
            //    }
            //    break;
            case "IN":
            {
                if (tins.Find(t => t.IDType.Key == "INID") == null && new[] { "INTX", "INPP", "INRS", "INNR", "INAD", "INRC", "INVR", "INDL" }.Intersect(from t in tins select t.IDType.Key).ToList().Count > 0)
                {
                    limitType = PurchaseLimitType.None;
                }

                if (limitType != PurchaseLimitType.None)
                {
                    var dsProfile = DistributorOrderingProfileProvider.GetProfile(DistributorProfileModel.Id, "IN");
                    if (dsProfile != null && (!dsProfile.Refreshed || (DateTime.Now - dsProfile.ApplicationDate).TotalMinutes <= WaitMinutes))
                    {
                        tins = DistributorOrderingProfileProvider.GetTinList(DistributorProfileModel.Id, true, true);
                        if (tins.Find(t => t.IDType.Key == "INID") == null && new[] { "INTX", "INPP", "INRS", "INNR", "INAD", "INRC", "INVR", "INDL" }.Intersect(from t in tins select t.IDType.Key).ToList().Count > 0)
                        {
                            limitType = PurchaseLimitType.None;
                        }
                    }
                }
            }
            break;

            case "HU":
            {
                if (tins.Find(p => p.IDType.Key == "HUVT") != null && tins.Find(p => p.IDType.Key == "HUBL" || p.IDType.Key == "HUPT") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "KZ":
            {
                if ((new List <string>(CountryType.KZ.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.KZ.Key
                    }).Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = (tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "KZTX", "KZBL" }).Count() == 2) ? PurchaseLimitType.None : limitType;
                }
                else
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "MK":
            {
                limitType = tins.Find(p => p.IDType.Key == "MKTX") != null ? PurchaseLimitType.None : limitType;
            }
            break;

            case "MN":
            {
                if ((new List <string>(CountryType.MN.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.MN.Key
                    }).Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = tins.Find(p => p.IDType.Key == "MGTX") != null ? PurchaseLimitType.None : limitType;
                }
                else
                {
                    limitType = PurchaseLimitType.Volume;
                }
            }
            break;

            case "MY":
            {
                limitType = tins.Find(t => t.IDType.Key == "MYID") != null ? PurchaseLimitType.None : limitType;
                if (tins.Find(t => t.IDType.Key == "MYID" && t.ID == "MY00") != null)
                {
                    //For the DS with ‘Dummy TIN No” (MYID = ‘MY00’), he/she can purchase any category of products up to 1000 Volume Points per month.
                    limitType = PurchaseLimitType.Volume;
                }
            }
            break;

            case "PE":
            {
                if ((new List <string>(CountryType.PE.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.PE.Key
                    }).Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = tins.Find(p => p.IDType.Key == "PETX") != null ? PurchaseLimitType.None : limitType;
                }
                else
                {
                    limitType = (tins.Select(c => c.IDType.Key).Intersect(new[] { "PEID", "PETX" }).Count() == 2) ? PurchaseLimitType.None : limitType;
                }
            }
            break;

            case "PF":
            {
                limitType = tins.Find(t => t.IDType.Key == "FPBL") != null ? PurchaseLimitType.None : limitType;

                if (limitType == PurchaseLimitType.None)
                {
                    // NOTE THAT NEED TO CHECK WH on ADD TO CART TOO
                    if (tins.Find(t => t.IDType.Key == "APP") != null)
                    {
                        limitType = PurchaseLimitType.Volume;
                    }
                }
            }
            break;

            case "PH":
            {
                var countryCodes = (new List <string>(CountryType.PH.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.PH.Key
                    });
                if (!countryCodes.Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = PurchaseLimitType.Volume;
                    setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1050.00m);
                }
            }
            break;

            case "PY":
            {
                limitType = tins.Find(t => t.IDType.Key == "PYTX") != null ? PurchaseLimitType.None : limitType;
            }
            break;


            case "PL":
            {
                var countryCodes = (new List <string>(CountryType.PL.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.PL.Key
                    });
                //Foreign DS have no limit. "
                if (!countryCodes.Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = PurchaseLimitType.None;
                }
                else
                {
                    limitType = tins.Find(p => p.IDType.Key == "REGN") != null && tins.Find(p => p.IDType.Key == "APP") == null ? PurchaseLimitType.None : limitType;
                }
            }
            break;

            case "RO":
            {
                if (tins.Find(t => t.IDType.Key == "ROBL") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
                if (tins.Find(t => t.IDType.Key == "APP") != null)
                {
                    limitType = PurchaseLimitType.Volume;
                }
            }
            break;

            case "RS":
            {
                if (tins.Find(t => t.IDType.Key == "SRTX") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "RU":
            {
                limitType = (tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "RUTX", "RUBL" }).Count() == 2) ? PurchaseLimitType.None : limitType;
            }
            break;

            case "SG":
            {
                if (tins.Find(t => t.IDType.Key == "SNID") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
                else
                {
                    if ((new List <string>(CountryType.SG.HmsCountryCodes)).Union(new List <string>()
                        {
                            CountryType.SG.Key
                        }).Contains(DistributorProfileModel.ProcessingCountryCode))
                    {
                        limitType = PurchaseLimitType.None;
                    }
                }
                // DS with Dummy TIN No "S0000000S", can purchase any category of products up to 1100 vp per order
                if (tins != null && tins.Find(t => t.ID == "S0000000S") != null)
                {
                    limitType = PurchaseLimitType.Volume;
                    setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1100.00m);
                }
            }
            break;

            case "SI":
            {
                if (tins.Find(t => t.IDType.Key == "SITX") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "TH":

            {
                if (tins.Find(t => t.ID == "TH00000000000") != null)
                {
                    limitType = PurchaseLimitType.Volume;
                    setValues(limits, PurchasingLimitRestrictionPeriod.PerOrder, 1050.00m);
                }
            }
            break;

            case "UA":
            {
                if (tins.Find(t => t.IDType.Key == "UABL") != null)
                {
                    limitType = PurchaseLimitType.None;
                }
            }
            break;

            case "UY":
            {
                limitType = tins.Find(t => t.IDType.Key == "UYTX") != null ? PurchaseLimitType.None : limitType;
            }
            break;

            case "VN":
            {
                if ((new List <string>(CountryType.VN.HmsCountryCodes)).Union(new List <string>()
                    {
                        CountryType.VN.Key
                    }).Contains(DistributorProfileModel.ProcessingCountryCode))
                {
                    limitType = tins.Find(t => t.IDType.Key == "VNID") != null ? PurchaseLimitType.None : limitType;
                }
            }
            break;

            case "BG":
            {
                var processingCountryCode = DistributorProfileModel.ProcessingCountryCode;

                if (processingCountryCode == "BG")
                {
                    var now   = DateUtils.GetCurrentLocalTime("BG");
                    var bgTin = tins.Find(t => t.IDType.Key == "BGBL");
                    var cart  = ShoppingCartProvider.GetShoppingCart(distributorId, Locale, true);
                    if (bgTin != null && bgTin.IDType != null && bgTin.IDType.ExpirationDate > now && cart != null && cart.SelectedDSSubType != "PC")
                    {
                        limitType = PurchaseLimitType.None;
                    }
                    else          //BG Members with NO BGBL have a 7500 VP per year
                    {
                        limitType = PurchaseLimitType.Volume;
                    }
                }
                else          //foreign members have a 7500 VP per year
                {
                    limitType = PurchaseLimitType.Volume;
                }
            }
            break;

            default:
                if (!HLConfigManager.Configurations.DOConfiguration.GetPurchaseLimitsFromFusion)
                {
                    limitType = PurchaseLimitType.None;
                }
                break;
            }

            if (limits != null)
            {
                if (limits.maxVolumeLimit == -1 && limits.MaxEarningsLimit == -1)
                {
                    limits.PurchaseLimitType = PurchaseLimitType.None;
                }
                else
                {
                    limits.PurchaseLimitType = limitType;
                }
                SetLimits(orderMonth, manager, limits);
            }
        }
 /// <summary>
 /// setValues
 /// </summary>
 /// <param name="l"></param>
 /// <param name="period"></param>
 /// <param name="maxValue"></param>
 public static void SetValues(PurchasingLimits_V01 l, PurchasingLimitRestrictionPeriod period, PurchaseLimitType limitType)
 {
     l.RestrictionPeriod = period;
     l.PurchaseLimitType = limitType;
 }
Example #13
0
        private void DisplayRemaining(string orderSubType)
        {
            //string DSType = ProductsBase.LevelSubType;
            ShoppingCart.EmailValues.RemainingVolume = string.Empty;
            //ShoppingCart.SelectedDSSubType = orderSubType;

            PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, orderSubType);
            decimal cartVolume          = 0M;

            if (null != limits)
            {
                if (FOPEnabled)
                {
                    if (limits.PurchaseLimitType == PurchaseLimitType.TotalPaid)
                    {
                        cartVolume = TotalsExcludeAPF(ShoppingCart, this.CountryCode);
                        lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingAmount").ToString();
                    }
                    else
                    {
                        cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart;
                    }
                }
                else
                {
                    var purchasingLimitManager = PurchasingLimitManager(this.DistributorID);
                    cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart;
                }
                decimal remaining = (limits.RemainingVolume - cartVolume);

                if (remaining < 0)
                {
                    remaining = 0;
                }

                if (limits.PurchaseLimitType == PurchaseLimitType.Volume)
                {
                    lblRemainingVal.Text = ProductsBase.GetVolumePointsFormat(remaining);
                }
                //else
                //{
                //    lblRemainingVal.Text = ProductsBase.getAmountString(remaining);
                //}
            }

            if (PurchasingLimitProvider.DisplayLimits(DistributorID, CountryCode))
            {
                if (HasMemberVPLimitations())
                {
                    trRemainingVal.Visible = null != limits ? true : false;
                    //trRemainingVal.Visible = null != limits &&
                    //                         (limits.PurchaseLimitType == PurchaseLimitType.Earnings ||
                    //                          limits.PurchaseLimitType == PurchaseLimitType.Volume ||
                    //                          limits.PurchaseLimitType == PurchaseLimitType.TotalPaid);
                    PurchaseLimitType limitType = PurchaseLimitType.Volume;
                    limits.PurchaseLimitType = limitType;
                }
                else
                {
                    if (limits.LimitsRestrictionType == LimitsRestrictionType.FOP)
                    {
                        trRemainingVal.Visible = null != limits ? true : false; //Show remaining VP when FOP regardless of Limitations
                    }
                    else
                    {
                        trRemainingVal.Visible = false;
                    }
                }
            }
            else
            {
                trRemainingVal.Visible = false;
            }

            if (trRemainingVal.Visible)
            {
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            PurchaseLimitType limitType             = PurchaseLimitType.Volume;
            PurchasingLimitRestrictionPeriod period = PurchasingLimitRestrictionPeriod.Unknown;

            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);

            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            var processingCountryCode = DistributorProfileModel.ProcessingCountryCode;
            var arCOP = (new List <string>(CountryType.AR.HmsCountryCodes)).Union(new List <string>()
            {
                CountryType.AR.Key
            }).Contains(processingCountryCode);
            bool isExempted = CatalogProvider.IsDistributorExempted(distributorId);
            var  nonVolumeOrderingCountries = new List <string> {
                "BR", "UY", "BO", "PY"
            };

            //Members with any Sub types whose country of processing is not equal to Brazil/ Bolivia/ Paraguay/ Uruguay,
            //If added to white list then respective Members can place ‘P’ type orders with a purchasing limit of 999.99 pesos/order.
            if (nonVolumeOrderingCountries.Contains(processingCountryCode))
            // equal to BR,UY,BO,PY
            {
                if (!isExempted) // not in whitelist
                {
                    manager.CanPurchasePType = false;
                }
            }
            var FOPlimits = GetFOPLimits(manager);

            if (FOPlimits != null && !FOPlimits.Completed)
            {
                limitType = PurchaseLimitType.Volume;
                period    = PurchasingLimitRestrictionPeriod.OneTime;
            }
            else
            {
                if (!arCOP) //
                {
                    limitType = PurchaseLimitType.TotalPaid;
                    period    = PurchasingLimitRestrictionPeriod.PerOrder;
                    limits.RemainingVolume = limits.maxVolumeLimit = MaxAmount;
                }
                else
                {
                    limitType = PurchaseLimitType.Volume;
                    period    = PurchasingLimitRestrictionPeriod.Monthly;
                }
            }
            limits.PurchaseLimitType = limitType;
            limits.RestrictionPeriod = period;

            if (limits.maxVolumeLimit == -1)
            {
                limits.RemainingVolume   = -1;
                limits.PurchaseLimitType = PurchaseLimitType.None;
            }
            SetLimits(orderMonth, manager, limits);
        }