Exemple #1
0
        protected static DistributorProfileModel DistributorProfile(string distributorId)
        {
            DistributorProfileLoader loader = new DistributorProfileLoader();
            var profile = loader.Load(new GetDistributorProfileById()
            {
                Id = distributorId
            });

            if (profile != null)
            {
                return(profile);
            }
            return(null);
        }
Exemple #2
0
        public static bool IsAPFDueAndNotPaid(string distributorID)
        {
            var isDue = false;

            string level = GetDSLevel();

            if (string.IsNullOrEmpty(level))
            {
                DistributorProfileLoader loader = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById()
                {
                    Id = distributorID
                });
                level = profile.TypeCode;
            }
            if (level == "SP")
            {
                return(isDue);
            }
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorID, "CN");

            if (distributorOrderingProfile != null)
            {
                if (distributorOrderingProfile.CNAPFStatus != 1 && distributorOrderingProfile.CNAPFStatus != 2)
                {
                    return(isDue);
                }
                DateTime annualProcessingFeeDue = distributorOrderingProfile.ApfDueDate;

                // APF due
                var hmsAPFDue = new DateTime(annualProcessingFeeDue.Year,
                                             annualProcessingFeeDue.Month,
                                             annualProcessingFeeDue.Day);
                var currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                if (hmsAPFDue <= currentDate)
                {
                    isDue = true;
                }

                if (isDue)
                {
                    isDue = !GetAPFDuePaid(distributorID, annualProcessingFeeDue);
                }
            }

            return(isDue);
        }
Exemple #3
0
        public IPurchasingLimitManager GetPurchasingLimitManager(string id)
        {
            //Load the DS/get it from cache..
            ILoader <DistributorProfileModel, GetDistributorProfileById> distributorProfileLoader =
                new DistributorProfileLoader();
            var currentLoggedInCounrtyCode = CultureInfo.CurrentCulture.Name.Substring(3);
            var distributorProfileModel    = distributorProfileLoader.Load(new GetDistributorProfileById {
                Id = id
            });
            var purchasingLimitKey = string.Format("PL_{0}_{1}", id, currentLoggedInCounrtyCode);

            return(_Cache.Retrieve(delegate
            {
                return new PurchasingLimitManager(id, currentLoggedInCounrtyCode, distributorProfileModel.TypeCode,
                                                  distributorProfileModel.ProcessingCountryCode);
            }, purchasingLimitKey, TimeSpan.FromMinutes(30)));
        }
Exemple #4
0
        public static string GetProcessCountry(string memberId)
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (null == member)
            {
                var loader  = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById {
                    Id = memberId
                });
                return(profile.ProcessingCountryCode);
            }
            else
            {
                return(((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.ProcessingCountryCode);
            }
        }
Exemple #5
0
        public static bool GetHapStatus(string memberId)
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (null == member)
            {
                var loader  = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById {
                    Id = memberId
                });
                return(profile.IsHapStatus);
            }
            else
            {
                return(((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.IsHapStatus);
            }
        }
Exemple #6
0
        public static string GetDSLevel(string memberId)
        {
            var    member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
            string type;

            if (null == member)
            {
                var loader  = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById {
                    Id = memberId
                });
                type = profile.TypeCode;
            }
            else
            {
                type = ((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.TypeCode;
            }
            return(type);
        }
Exemple #7
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ddlMemberID.SelectedValue))
            {
                //Need to display user friendly mesage, will take up in the next iteration
                return;
            }
            ILoader <DistributorProfileModel, GetDistributorProfileById> distributorProfileLoader = new DistributorProfileLoader();
            var distributorProfileModel = distributorProfileLoader.Load(new GetDistributorProfileById {
                Id = ddlMemberID.SelectedValue
            });
            var pcDistInfo     = DistributorOrderingProfileProvider.GetProfile(ddlMemberID.SelectedValue, CountryCode);
            var currentSession = Providers.SessionInfo.GetSessionInfo(DistributorID, Locale);

            currentSession.ReplacedPcDistributorProfileModel    = distributorProfileModel;
            currentSession.ReplacedPcDistributorOrderingProfile = pcDistInfo;
            currentSession.IsReplacedPcOrder = true;
            base.ShoppingCart.SrPlacingForPcOriginalMemberId = currentSession.ReplacedPcDistributorOrderingProfile.Id;
            Providers.SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession);
            var allSKU       = CatalogProvider.GetAllSKU(Locale);
            var SKUsToRemove = new List <string>();

            foreach (var cartitem in ShoppingCart.CartItems)
            {
                SKU_V01 PrmoSku;

                allSKU.TryGetValue(cartitem.SKU, out PrmoSku);
                if (PrmoSku != null)
                {
                    if (!PrmoSku.IsPurchasable)
                    {
                        SKUsToRemove.Add(PrmoSku.SKU.Trim());
                    }
                }
            }
            Array.ForEach(SKUsToRemove.ToArray(),
                          a => ShoppingCart.CartItems.Remove(ShoppingCart.CartItems.Find(x => x.SKU == a)));
            Array.ForEach(SKUsToRemove.ToArray(),
                          a => ShoppingCart.ShoppingCartItems.Remove(ShoppingCart.ShoppingCartItems.Find(x => x.SKU == a)));

            Response.Redirect("PriceList.aspx?ETO=False");
        }
        public static bool RequirePurchasingLimits(string distributorId, string countryCode)
        {
            if (Settings.GetRequiredAppSetting <bool>("FOPEnabled", false))
            {
                var    member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
                string type;
                if (null == member)
                {
                    var loader  = new DistributorProfileLoader();
                    var profile = loader.Load(new GetDistributorProfileById()
                    {
                        Id = distributorId
                    });
                    type = profile.TypeCode;
                }
                else
                {
                    type = ((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.TypeCode;
                }

                return(FOP.PurchaseRestrictionProvider.HasPurchaseRestriction(distributorId, countryCode, type));
            }
            else
            {
                var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

                if (null == member)
                {
                    var loader  = new DistributorProfileLoader();
                    var profile = loader.Load(new GetDistributorProfileById()
                    {
                        Id = distributorId
                    });
                    var isMpDS = nonExemptCountries.Contains(profile.ProcessingCountryCode) && profile.TypeCode == "DS";
                    return(isMpDS || HLConfigManager.Configurations.DOConfiguration.NonThresholdCountryRequiredPurchasingLimits || nonExemptCountries.Contains(countryCode));
                }
                else
                {
                    return(IsMarketingPlanDistributor || HLConfigManager.Configurations.DOConfiguration.NonThresholdCountryRequiredPurchasingLimits || nonExemptCountries.Contains(countryCode));
                }
            }
        }
        public static bool IsMarketingPlanDistributorById(string distributorId)
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (null == member)
            {
                var loader  = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById {
                    Id = distributorId
                });
                if (null == profile)
                {
                    return(false);
                }
                return(nonExemptCountries.Contains(profile.ProcessingCountryCode) && (profile.TypeCode == "DS"));
            }
            return(
                nonExemptCountries.Contains(
                    ((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.ProcessingCountryCode) &&
                ((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.TypeCode == "DS");
        }
        public IPurchaseRestrictionManager GetPurchaseRestrictionManager(string id)
        {
            //Load the DS/get it from cache..
            ILoader <DistributorProfileModel, GetDistributorProfileById> distributorProfileLoader = new DistributorProfileLoader();
            var locale = CultureInfo.CurrentCulture.Name;
            var currentLoggedInCounrtyCode = locale.Substring(3);
            var distributorProfileModel    = distributorProfileLoader.Load(new GetDistributorProfileById {
                Id = id
            });

            // to prevent recusive calls
            // get distributor ordering profile from Distributor_V01
            DistributorLoader distributorLoader = new DistributorLoader();
            var distributorProfile         = distributorLoader.Load(id, currentLoggedInCounrtyCode);
            var distributorOrderingProfile = DistributorOrderingProfileFactory.GetDistributorOrderingProfile(distributorProfile, currentLoggedInCounrtyCode);

            return(_Cache.Retrieve(delegate
            {
                return new PurchaseRestrictionManager(id, currentLoggedInCounrtyCode, distributorProfileModel.TypeCode, distributorProfileModel.ProcessingCountryCode, locale, distributorOrderingProfile.TinList, distributorOrderingProfile.OrderSubType);
            }, GetCacheKey(id, currentLoggedInCounrtyCode), TimeSpan.FromMinutes(Settings.GetRequiredAppSetting(
                                                                                     "PurchasingLimitsCacheMinutes",
                                                                                     30))));
        }
Exemple #11
0
        public static bool IsAPFDueAndNotPaid(string distributorID, string locale)
        {
            var isDue = false;

            var cop = GetProcessCountry(distributorID);
            DistributorProfileLoader loader = new DistributorProfileLoader();
            var profile = loader.Load(new GetDistributorProfileById()
            {
                Id = distributorID
            });

            if (cop == null)
            {
                cop = profile.ProcessingCountryCode;
            }

            if ((cop.Equals("CN")))
            {
                return(IsAPFDueAndNotPaid(distributorID));
            }

            if (IsGlobalExemptCountryOfProcessing(cop))
            {
                return(isDue);
            }

            string level = GetDSLevel(distributorID);

            if (string.IsNullOrEmpty(level))
            {
                level = profile.TypeCode;
            }

            if (HLConfigManager.Configurations.APFConfiguration.APFRequired)
            {
                DateTime annualProcessingFeeDue = GetAPFDueDate(distributorID, locale.Substring(3));
                if (
                    !HLConfigManager.Configurations.APFConfiguration.ApfExemptCountriesOfProcessing.Contains(
                        cop) && CanPurchaseApf(cop, locale.Substring(3), HLConfigManager.Configurations.APFConfiguration.ApfRestrictedByPurchaseLocation))
                {
                    // APF due
                    var hmsAPFDue = new DateTime(annualProcessingFeeDue.Year,
                                                 annualProcessingFeeDue.Month,
                                                 annualProcessingFeeDue.Day);
                    var currentDate = DateUtils.ConvertToLocalDateTime(DateTime.Now, locale.Substring(3));
                    if (hmsAPFDue < currentDate)
                    //if (ods.Value.AnnualProcessingFeeDue < DateTime.Now)
                    {
                        isDue = true;
                        if (IsExemptDueToHAPStatus(level, GetHapStatus(distributorID)))
                        {
                            isDue = false;
                        }
                    }
                    if (isDue)
                    {
                        isDue = !GetAPFDuePaid(distributorID, annualProcessingFeeDue);
                    }
                }
            }

            return(isDue);
        }