示例#1
0
        public static Order FillOrderInfo(Order _order, MyHLShoppingCart shoppingCart)
        {
            Order_V01 order = _order as Order_V01;

            order.DistributorID = shoppingCart.DistributorID;
            order.Shipment      = GetShippingInfoFromCart(shoppingCart);
            order.InputMethod   = InputMethodType.Internet;
            var recvdDate = DateUtils.GetCurrentLocalTime(shoppingCart.Locale.Substring(3, 2));

            order.ReceivedDate = recvdDate;

            // TODO : Order CATEGORY
            order.OrderCategory =
                (ServiceProvider.OrderSvc.OrderCategoryType)Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType), shoppingCart.OrderCategory.ToString());
            //OrderCategoryType.RSO;
            if (order.OrderCategory == ServiceProvider.OrderSvc.OrderCategoryType.ETO)
            {
                if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType))
                {
                    order.OrderCategory =
                        (ServiceProvider.OrderSvc.OrderCategoryType)
                        Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType),
                                   HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType);
                }
            }

            var orderMonth = new OrderMonth(shoppingCart.CountryCode);

            order.OrderMonth = orderMonth.OrderMonthShortString;
            //order.OrderMonth = DateTime.Now.ToString("yyMM");

            order.UseSlidingScale     = HLConfigManager.Configurations.CheckoutConfiguration.UseSlidingScale;
            order.CountryOfProcessing = shoppingCart.CountryCode;

            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(shoppingCart.DistributorID, shoppingCart.CountryCode);

            if (null != distributorOrderingProfile)
            {
                //order.DiscountPercentage = order.UseSlidingScale && distributorOrderingProfile.StaticDiscount < 50
                //                               ? 0
                //                               : distributorOrderingProfile.StaticDiscount;
                order.DiscountPercentage = distributorOrderingProfile.StaticDiscount;  // always pass profile discount
            }
            if (HLConfigManager.Configurations.DOConfiguration.UsesDiscountRules)
            {
                HLRulesManager.Manager.PerformDiscountRules(shoppingCart, order, shoppingCart.Locale, ShoppingCartRuleReason.CartBeingCalculated);
            }
            if (HLConfigManager.Configurations.DOConfiguration.usesOrderManagementRules)
            {
                HLRulesManager.Manager.PerformOrderManagementRules(shoppingCart, order, shoppingCart.Locale, OrderManagementRuleReason.OrderFilled);
            }

            // some countries, like IT, need OrderSubType for correct Fusion pricing.
            // Added for User Story 226150
            if (HLConfigManager.Configurations.DOConfiguration.SaveDSSubType)
            {
                order.OrderSubType = shoppingCart.SelectedDSSubType;
            }
            return(order);
        }
示例#2
0
        protected void SetAPFDueDate(object sender, EventArgs e)
        {
            DateTime dueDate = DateTime.MinValue;

            try
            {
                if (DateTime.TryParse(txtDueDate.Text, out dueDate))
                {
                    DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);
                    if (null != distributorOrderingProfile)
                    {
                        distributorOrderingProfile.ApfDueDate = dueDate;
                        // TODO : this is not necessary?
                        //DistributorProvider.UpdateDistributor(distributor);
                        lblStatus.Text = "Set to: " + dueDate.ToString("M/d/yyyy", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        lblStatus.Text = "Distributor error";
                    }
                }
                else
                {
                    lblStatus.Text = "Date error";
                }
            }
            catch
            {
                lblStatus.Text = "Server Error";
            }

            DisplayData();
        }
        public static void GetHAPSettings(DistributorOrderingProfile distributor)
        {
            if (!distributor.HAPExpiryDateSpecified || distributor.HAPExpiryDate == null)
            {
                using (var proxy = ServiceClientProvider.GetDistributorServiceProxy())
                {
                    try
                    {
                        var response = proxy.GetBasicDistributor(new GetBasicDistributorRequest(
                                                                     new GetBasicDistributorRequest_V01()
                        {
                            DistributorID = distributor.Id,
                            CountryCode   = distributor.CurrentLoggedInCountry,
                            RequiresTin   = false
                        })).GetBasicDistributorResult as GetBasicDistributorResponse_V01;

                        if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null)
                        {
                            distributor.HAPExpiryDateSpecified = response.Distributor.HAPExpiryDateFieldSpecified;
                            distributor.HAPExpiryDate          = response.Distributor.HAPExpiryDateField;
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Warn(
                            string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider.GetHAPSettings - distributorId: {0} - country: {1} - Exception: {2}",
                                          distributor.Id, distributor.CurrentLoggedInCountry, ex.Message));
                    }
                }
            }
        }
        private void ResolveAPF()
        {
            if (ShoppingCart != null && ShoppingCart.CartItems != null &&
                APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems))
            {
                if (_paymentsSummary != null && _paymentsSummary.CurrentPaymentInfo != null && _paymentsSummary.CurrentPaymentInfo.Any())
                {
                    CreditPayment_V01 payment = _paymentsSummary.CurrentPaymentInfo[0] as CreditPayment_V01;
                    if (payment == null)
                    {
                        return;
                    }
                    if (this.Locale == "pt-BR" && payment.AuthorizationMethod != AuthorizationMethodType.Online)
                    {
                        return;
                    }
                    DistributorOrderingProfile orderingProfile = this.DistributorOrderingProfile;
                    if (orderingProfile != null)
                    {
                        int payedApf       = APFDueProvider.APFQuantityInCart(ShoppingCart);
                        var currentDueDate = orderingProfile.ApfDueDate;
                        var newDueDate     = currentDueDate + new TimeSpan(payedApf * 365, 0, 0, 0);

                        orderingProfile.ApfDueDate = newDueDate;
                        Session.Add("apfdue", newDueDate);
                        APFDueProvider.UpdateAPFDuePaid(DistributorID, newDueDate);
                        new DistributorOrderingProfileFactory().ReloadDistributorOrderingProfile(DistributorID, CountryCode);
                    }
                }
            }
        }
示例#5
0
        public static bool IsAPFExemptOn200VP(DistributorOrderingProfile distributorProfile, decimal currentOrderPoint)
        {
            bool Exempted = false;

            try
            {
                if (distributorProfile == null)
                {
                    return(false);
                }

                var volumes    = getVolumePoints(distributorProfile.Id);
                var totalVolum = volumes.VolumePoints.Find(v => DateTime.Parse(v.VolumeMonth.ToString()).Month == DateTime.UtcNow.Month);
                if (distributorProfile.ApfDueDate != null && totalVolum != null && distributorProfile.ApfDueDate <= DateTime.UtcNow.Date && (totalVolum.Volume) >= 200)
                {
                    Exempted = true;
                }
                else if (distributorProfile.ApfDueDate != null && totalVolum != null && distributorProfile.ApfDueDate > DateTime.UtcNow.Date && (totalVolum.Volume + currentOrderPoint) >= 200)
                {
                    Exempted = true;
                }
                return(Exempted);
            }
            catch (Exception ex)
            {
                HL.Common.Logging.LoggerHelper.Error("APFDueProvider.IsAPFExemptOn200VP() Error \n" + ex.StackTrace);
                return(Exempted);
            }
        }
示例#6
0
        private void ReadFromData()
        {
            DistributorOrderingProfile distributorOrderingProfile =
                DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);

            _distributorId = DistributorID;
            _apfDueDate    = distributorOrderingProfile.ApfDueDate;
            if (_testing)
            {
                APFDueProvider.UpdateAPFDuePaid(_distributorId, _apfDueDate);
            }
            _apfSku                   = APFDueProvider.GetAPFSku();
            _cart                     = (Page as ProductsBase).ShoppingCart;
            _apfIsDue                 = APFDueProvider.IsAPFDueAndNotPaid(_distributorId, HLConfigManager.Configurations.Locale);
            _apfDueWithinOneYear      = APFDueProvider.IsAPFDueWithinOneYear(_distributorId, CountryCode);
            _apfDueGreaterThanOneYear = APFDueProvider.IsAPFDueGreaterThanOneYear(_distributorId, CountryCode);
            if (_apfIsDue)
            {
                _apfsDue = APFDueProvider.APFQuantityDue(_distributorId, HLConfigManager.Configurations.Locale);
            }
            List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList();

            _apfsInCart = 0;
            if (item.Count > 0)
            {
                _apfsInCart = item[0].Quantity;
            }
        }
示例#7
0
        /// <summary>
        /// China ShouldShowAPFModule
        /// </summary>
        /// <param name="distributorId"></param>
        /// <returns></returns>
        public static bool ShouldShowAPFModule(string distributorId)
        {
            bool shouldDisplay = false;
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorId, "CN");

            try
            {
                if (distributorOrderingProfile != null)
                {
                    if (string.IsNullOrEmpty(distributorOrderingProfile.CNCustCategoryType))
                    {
                        return(false);
                    }
                    if (distributorOrderingProfile.CNCustCategoryType.ToLower() == "psr")
                    {
                        return(false);
                    }
                    //--0(normal DS) 1(overdue within next 3 month) 2(in grace period) 3(has renewed) 4(not DS) 5(overdue)
                    if (distributorOrderingProfile.CNAPFStatus == 2)
                    {
                        return(IsAPFDueAndNotPaid(distributorId));
                    }
                    if (distributorOrderingProfile.CNAPFStatus == 1) // if due in next 3 month, check if paid
                    {
                        DateTime annualProcessingFeeDue = distributorOrderingProfile.ApfDueDate;

                        // APF due
                        var hmsAPFDue = new DateTime(annualProcessingFeeDue.Year,
                                                     annualProcessingFeeDue.Month,
                                                     annualProcessingFeeDue.Day);
                        shouldDisplay = !GetAPFDuePaid(distributorId, annualProcessingFeeDue);
                    }
                    if (distributorOrderingProfile.CNAPFStatus == 0) // if normal, should show APF from Month 1 - Month 12
                    {
                        shouldDisplay = distributorOrderingProfile.ApfDueDate.AddYears(-1) <= DateTime.Today && DateTime.Today <= distributorOrderingProfile.ApfDueDate;
                    }
                }
            }
            catch (Exception ex)
            {
                if (distributorOrderingProfile != null)
                {
                    HL.Common.Logging.LoggerHelper.Error(
                        string.Format(
                            "there is an error in ShouldShowAPFModule DistributorId{0},CNCustCategoryType{1},CNAPFStatus{2},ApfDueDate{3}, error:{4}, stackTrace:{5}",
                            distributorId, distributorOrderingProfile.CNCustCategoryType,
                            distributorOrderingProfile.CNAPFStatus, distributorOrderingProfile.ApfDueDate, ex.Message, ex.StackTrace));
                }
                else
                {
                    HL.Common.Logging.LoggerHelper.Error(
                        string.Format(
                            "there is an error in ShouldShowAPFModule DistributorId{0},isdistributorOrderingProfile Null:{1}",
                            distributorId, "null"));
                }
            }
            return(shouldDisplay);
        }
        public DistributorOrderingProfile GetDistributorProfile()
        {
            DistributorOrderingProfile result = new DistributorOrderingProfile();

            result.Id         = "CN175803";
            result.ApfDueDate = DateTime.Now.AddYears(-1);

            return(result);
        }
        public void PerformTaxationRules(Order_V01 order, string locale)
        {
            if (null != order)
            {
                var limits = order.PurchasingLimits as PurchasingLimits_V01;
                if (null == limits)
                {
                    limits =
                        PurchasingLimitProvider.GetCurrentPurchasingLimits(order.DistributorID);
                    order.PurchasingLimits = limits;
                }
                if (null == limits)
                {
                    //Log an error here - can't tax this, it is invalid for IT if we don't have Limits created
                }
                else
                {
                    //Add suplemental items for Incaricato VAT and INPS calcs
                    limits.Items = new SupplementalItems();
                    limits.Items.Add("ConsignmentWitholdingRate", new List <decimal>(new[] { 0.1794M }));
                    //Both A1 and B1
                    limits.Items.Add("FlatFreightRate", new List <decimal>(new[] { 0.045M }));
                    if (!string.IsNullOrEmpty(limits.PurchaseSubType) && limits.PurchaseSubType.Equals("A1"))
                    //VAT Registered
                    {
                        DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(order.DistributorID, Country);
                        //Calcualte the INPS contribution for A1
                        if (distributorOrderingProfile.YTDEarnings > limits.MaxEarningsLimit &&
                            distributorOrderingProfile.YTDEarnings <=
                            HLConfigManager.Configurations.DOConfiguration.MaxTaxableEarnings)
                        {
                            var taxIds = DistributorOrderingProfileProvider.GetTinList(order.DistributorID, true);
                            if (taxIds.Count > 0 &&
                                taxIds.Where(
                                    p =>
                                    p.IDType.Key.Equals("IEVA") & p.IDType.Key.Equals("ITIN") &
                                    p.IDType.Key.Equals("ITSS")).Count() > 0)
                            {
                                limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0.0442M }));
                            }
                            else
                            {
                                limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0.0695M }));
                            }
                        }
                        else
                        {
                            limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0M }));
                        }
                        limits.Items.Add("VATReimbursementRate", new List <decimal>(new[] { 0.20M }));
                    }
                }

                CheckforMultipleDuplicateLinkedSkus(order);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (member != null)
            {
                var user = member.Value;
                _distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(user.Id, "CN");
            }
        }
示例#11
0
        private bool isPC()
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (member != null)
            {
                var user = member.Value;
                if (user != null)
                {
                    DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(user.Id, _CountryCode);
                    return(distributorOrderingProfile == null ? false : distributorOrderingProfile.IsPC);
                }
            }
            return(false);
        }
        public void Init()
        {
            distributor = new DistributorOrderingProfile();

            List <DistributorVolume_V01> vol = new List <DistributorVolume_V01> {
                new DistributorVolume_V01()
                {
                    VolumeDate  = DateTime.Now,
                    Volume      = 200,
                    VolumeMonth = "201509"
                }
            };

            distributor.DistributorVolumes = vol;
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            DistributorOrderingProfile orderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorId, "FR");

            limits.PurchaseLimitType = orderingProfile.OrderSubType == "F" ? PurchaseLimitType.Volume : PurchaseLimitType.None;
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            SetLimits(orderMonth, manager, limits);
        }
示例#14
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);
        }
        protected void OnYes(object sender, EventArgs e)
        {
            var member             = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
            var currentSessionInfo = SessionInfo.GetSessionInfo(member.Value.Id, CultureInfo.CurrentCulture.Name);

            currentSessionInfo.TrainingBreached = true;
            if (null != pnlMessageBox)
            {
                pnlMessageBox.Visible = false;
            }

            DistributorOrderingProfile dsProfile = DistributorOrderingProfileProvider.GetProfile(member.Value.Id,
                                                                                                 member.Value
                                                                                                 .ProcessingCountryCode);

            dsProfile.CantBuyOverride = true;
        }
        public void APFExempt_distributor_null()
        {
            distributor = null;
            decimal volume = 0;
            bool    result;

            result = APFDueProvider.IsAPFExemptOn200VP(distributor, 0);
            Assert.IsFalse(result);

            PrivateObject apf = new PrivateObject(typeof(APFRules));

            object[] args = new object[2] {
                distributor, volume
            };
            result = Convert.ToBoolean(apf.Invoke("IsAPFExempt", distributor, volume));
            Assert.IsFalse(result);
        }
        public List <string> PerformValidateDistributorRules(string DistributorID)
        {
            List <string> errors = null;
            //OnlineDistributor ods =  DistributorProvider.GetDistributor(DistributorID);
            DistributorOrderingProfile ods = DistributorOrderingProfileProvider.GetProfile(DistributorID, Country);

            if (ods != null)
            {
                if (ods.CantBuy)
                {
                    return(errors = new List <string> {
                        string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CantBuy").ToString())
                    });
                }
            }
            return(errors);
        }
        public void IsAPFExemptOnGracePeriod_Test()
        {
            var distributorProfiles = new DistributorOrderingProfile();

            distributorProfiles = GetDistributorProfile();

            GetDistributorVolumeResponse_V01 Volume;
            var apfExemptOnGracePeriod = Substitute.For <IChinaDistributorProviderLoader>();

            apfExemptOnGracePeriod.getVolumePoints().Returns(getVolumePoints(out Volume));

            decimal accumulatedVP = Volume.VolumePoints[0].Volume;

            if (distributorProfiles.ApfDueDate <= DateTime.UtcNow.Date)
            {
                Assert.AreEqual(accumulatedVP, 200);
            }
        }
示例#19
0
        private bool IsAPFExempt(DistributorOrderingProfile distributorProfile, decimal currentOrderPoint)
        {
            bool isVPExceeded = false;

            if (distributorProfile == null)
            {
                return(false);
            }

            //var datenow = DateTime.Now; // new DateTime(2015, 9, 17, 12, 0, 0); //(DateTime.Now).Date
            //if (!orderingProfile.ApfDueDate.Equals(datenow.Date)) return false;

            var totalVolum = distributorProfile.DistributorVolumes.Find(v => v.VolumeDate.Month == DateTime.UtcNow.Month);

            if (totalVolum != null && (totalVolum.Volume + currentOrderPoint) >= 200)
            {
                isVPExceeded = true;
            }

            return(isVPExceeded);
        }
        /// <summary>
        /// Gets the distrubutor notes from service if needed and save them in the object
        /// </summary>
        /// <param name="distributor">The distributor</param>
        /// <param name="noteType">The note type</param>
        /// <param name="noteCode">The note code</param>
        public static void GetDistributorNotes(DistributorOrderingProfile distributor, string noteType, string noteCode)
        {
            if (distributor.DistributorNotes == null)
            {
                var request = new GetDistributorNotesRequest_V01
                {
                    DistributorId = distributor.Id,
                    NoteType      = noteType,
                    NoteCode      = noteCode
                };

                var response = new GetDistributorNotesResponse_V01();

                var proxy = ServiceClientProvider.GetDistributorServiceProxy();
                response = proxy.GetDistributorNotes(new GetDistributorNotesRequest(request)).GetDistributorNotesResult as GetDistributorNotesResponse_V01;
                if (response.Status == ServiceResponseStatusType.Success)
                {
                    distributor.DistributorNotes = response.DistibutorNotes;
                }
            }
        }
        public static void CheckForMPCFraud(DistributorOrderingProfile distributor)
        {
            string errorResxKey = string.Empty;

            try
            {
                if (distributor != null && distributor.IsMPCFraud == null)
                {
                    using (var proxyDs = ServiceClientProvider.GetDistributorServiceProxy())
                    {
                        var requestV01 = new GetBasicDistributorRequest_V01
                        {
                            DistributorID = distributor.Id
                        };

                        var circuitBreaker =
                            CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBasicDistributorResponse_V01>();
                        var responseV01 =
                            circuitBreaker.Execute(() => proxyDs.GetBasicDistributor(new GetBasicDistributorRequest(requestV01))).GetBasicDistributorResult as
                            GetBasicDistributorResponse_V01;

                        if (responseV01 != null && responseV01.Status == ServiceResponseStatusType.Success)
                        {
                            if (responseV01.Distributor != null)
                            {
                                distributor.IsMPCFraud = responseV01.Distributor.IsMPCFraud;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Exception("System.Exception", new Exception(
                                           string.Format(
                                               "Error retrieving MPC Fraud from Distributor service for: DS:{0} - Country:{1}, {2}",
                                               distributor.Id, distributor.CurrentLoggedInCountry, ex)));
            }
        }
        public static Address_V01 GetAddress(AddressType type, string distributorID, string countryCode)
        {
            DistributorOrderingProfile profile = GetProfile(distributorID, countryCode);

            if (profile != null && profile.Addresses != null)
            {
                foreach (HL.Common.ValueObjects.Address_V02 a in profile.Addresses)
                {
                    if (a.TypeOfAddress.ToString() == type.ToString())
                    {
                        return(new Address_V01 {
                            Country = a.Country, City = a.City, CountyDistrict = a.CountyDistrict, Line1 = a.Line1, Line2 = a.Line2,
                            Line3 = a.Line3,
                            Line4 = a.Line4,
                            StateProvinceTerritory = a.StateProvinceTerritory,
                            PostalCode = a.PostalCode
                        });
                    }
                }
            }
            return(null);
        }
        public static List <TaxIdentification> GetTinList(string distributorID, bool getCurrentOnly, bool reload = false)
        {
            var    tinList        = new List <TaxIdentification>();
            string isoCountryCode = Thread.CurrentThread.CurrentCulture.Name.Substring(3);

            DistributorOrderingProfile distributorOrderingProfile = reload
                                                                        ? new DistributorOrderingProfileFactory().ReloadDistributorOrderingProfile(distributorID, isoCountryCode)
                                                                        : GetProfile(distributorID, isoCountryCode);

            var countryCodes = new List <string>();

            countryCodes.Add(isoCountryCode);
            countryCodes.AddRange(HL.Common.ValueObjects.CountryType.Parse(isoCountryCode).HmsCountryCodes);
            var now = DateUtils.GetCurrentLocalTime(isoCountryCode);

            if (null != distributorOrderingProfile && null != distributorOrderingProfile.TinList)
            {
                foreach (TaxIdentification taxId in distributorOrderingProfile.TinList)
                {
                    if (countryCodes.Contains(taxId.CountryCode))
                    {
                        if (getCurrentOnly)
                        {
                            if (taxId.IDType.ExpirationDate > now)
                            {
                                tinList.Add(taxId);
                            }
                        }
                        else
                        {
                            tinList.Add(taxId);
                        }
                    }
                }
            }

            return(tinList);
        }
示例#24
0
        // TODO: remove temp profile
        private static DistributorOrderingProfile createTempOrderingProfile(string id, string countryCode)
        {
            var distributorProfile = new DistributorOrderingProfile
            {
                Id                   = id,
                CantBuy              = false,
                StaticDiscount       = 25,
                TodaysMagazine       = false,
                HardCashOnly         = false,
                ApfDueDate           = DateTime.Now.AddDays(-2),
                IsDistributorBlocked = true,
                IsSponsorBlocked     = true,
            };

            var membershipUser = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (membershipUser != null && membershipUser.Value != null && membershipUser.Value.ProcessingCountryCode == "KR" && countryCode == "KR")
            {
                distributorProfile.StaticDiscount = 25;
            }

            return(distributorProfile);
        }
        public static Address_V02 GetAddressV02(AddressType type, string distributorID, string countryCode)
        {
            DistributorOrderingProfile profile = GetProfile(distributorID, countryCode);

            if (profile != null && profile.Addresses != null)
            {
                foreach (HL.Common.ValueObjects.Address_V02 a in profile.Addresses)
                {
                    if (a.TypeOfAddress.ToString() == type.ToString())
                    {
                        return new Address_V02()
                               {
                                   Building               = a.Building,
                                   CareOf                 = a.CareOf,
                                   City                   = a.CareOf,
                                   Country                = a.Country,
                                   CountyDistrict         = a.CountyDistrict,
                                   IsActive               = a.IsActive,
                                   IsPrimary              = a.IsPrimary,
                                   IsValidated            = a.IsValidated,
                                   Line1                  = a.Line1,
                                   Line2                  = a.Line2,
                                   Line3                  = a.Line3,
                                   Line4                  = a.Line4,
                                   PostalCode             = a.PostalCode,
                                   StateProvinceTerritory = a.StateProvinceTerritory,
                                   Suburb                 = a.Suburb,
                                   To            = a.To,
                                   TypeOfAddress = (AddressType)Enum.Parse(typeof(AddressType), a.TypeOfAddress.ToString())
                               }
                    }
                    ;
                }
            }
            return(null);
        }
示例#26
0
        /// <summary>
        ///     The IShoppingCart Rule Interface implementation
        /// </summary>
        /// <param name="cart">The current Shopping Cart</param>
        /// <param name="reason">The Rule invoke Reason</param>
        /// <param name="Result">The Rule Results collection</param>
        /// <returns>The cumulative rule results - including the results of this iteration</returns>
        protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                               ShoppingCartRuleReason reason,
                                                               ShoppingCartRuleResult Result)
        {
            var dpm = DistributorProfileModel;

            CurrentSession = (dpm != null)
                ? SessionInfo.GetSessionInfo(dpm.Id, Locale)
                : SessionInfo.GetSessionInfo(cart.DistributorID, Locale);
            string dsid = string.Empty;

            if (CurrentSession.IsReplacedPcOrder)
            {
                dsid = CurrentSession.ReplacedPcDistributorOrderingProfile != null && CurrentSession.ReplacedPcDistributorOrderingProfile.Id != null ? CurrentSession.ReplacedPcDistributorOrderingProfile.Id : cart.DistributorID;
            }
            else
            {
                dsid = cart.DistributorID;
            }
            //   OrderTotals_V01 totals = (OrderTotals_V01)(cart as MyHLShoppingCart).Totals;
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded || reason == ShoppingCartRuleReason.CartRetrieved)
            {
                var Cart           = cart as MyHLShoppingCart;
                var calcTheseItems = new List <ShoppingCartItem_V01>();

                var purchasingLimitManager = PurchasingLimitManager(dsid);
                var myhlCart = cart as MyHLShoppingCart;

                if (null == myhlCart)
                {
                    LoggerHelper.Error(
                        string.Format("{0} myhlCart is null {1}", Locale, dsid));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }

                PurchasingLimits_V01 PurchasingLimits =
                    PurchasingLimitProvider.GetCurrentPurchasingLimits(dsid);

                purchasingLimitManager.SetPurchasingLimits(PurchasingLimits);


                if (null == PurchasingLimits)
                {
                    LoggerHelper.Error(
                        string.Format("{0} PurchasingLimits could not be retrieved for distributor {1}", Locale,
                                      dsid));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }

                var shoppingCart = cart as MyHLShoppingCart;
                if (shoppingCart == null)
                {
                    return(Result);
                }

                if (PurchasingLimits.MaxPCEarningsLimit == -1)
                {
                    return(Result);
                }
                DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, "CN");
                if ((CurrentSession.ReplacedPcDistributorOrderingProfile != null && CurrentSession.ReplacedPcDistributorOrderingProfile.IsPC) || (distributorOrderingProfile != null && distributorOrderingProfile.IsPC))
                {
                    if (cart.CurrentItems != null)
                    {
                        calcTheseItems.AddRange(from i in cart.CurrentItems
                                                where !APFDueProvider.IsAPFSku(i.SKU)
                                                select
                                                new ShoppingCartItem_V01(i.ID, i.SKU, i.Quantity, i.Updated,
                                                                         i.MinQuantity));
                    }
                    if (cart.CartItems != null)
                    {
                        calcTheseItems.AddRange(from i in cart.CartItems
                                                where !APFDueProvider.IsAPFSku(i.SKU)
                                                select
                                                new ShoppingCartItem_V01(i.ID, i.SKU, i.Quantity, i.Updated,
                                                                         i.MinQuantity));
                    }
                    var totals = Cart.Calculate(calcTheseItems, false) as OrderTotals_V01;

                    //OrderTotals_V01 totals = (OrderTotals_V01)(cart as MyHLShoppingCart).Totals;
                    if (totals != null && totals.DiscountedItemsTotal > purchasingLimitManager.MaxPersonalPCConsumptionLimit)
                    {
                        if (cart.CurrentItems.Count > 0)
                        {
                            var sessionInfo = SessionInfo.GetSessionInfo(cart.DistributorID, Locale);
                            if (sessionInfo != null && sessionInfo.ShoppingCart != null && sessionInfo.ShoppingCart.CurrentItems != null)
                            {
                                sessionInfo.ShoppingCart.CurrentItems.RemoveAll(x => x.SKU != null);
                            }
                            cart.CurrentItems.RemoveAll(s => s.SKU != null);
                        }
                        Result.Result = RulesResult.Failure;
                        Result.AddMessage(
                            string.Format(
                                HttpContext.GetGlobalResourceObject(
                                    string.Format("{0}_Rules", HLConfigManager.Platform),
                                    "ErrorMessageToPCWhenhittheFOPLimits").ToString(),
                                purchasingLimitManager.MaxPersonalPCConsumptionLimit));
                    }
                    else
                    {
                        var ruleMessage = cart.RuleResults.FirstOrDefault(x => x.Messages != null && x.Messages.Count > 0 && x.RuleName == "PurchasingLimits Rules");
                        if (ruleMessage != null)
                        {
                            cart.RuleResults.Remove(ruleMessage);
                        }
                    }

                    cart.RuleResults.Add(Result);
                }
                else
                {
                    decimal DistributorRemainingVolumePoints = 0;
                    decimal NewVolumePoints = 0;


                    if (null == myhlCart)
                    {
                        LoggerHelper.Error(
                            string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID));
                        Result.Result = RulesResult.Failure;
                        return(Result);
                    }

                    DistributorRemainingVolumePoints = PurchasingLimits.RemainingVolume;
                    if (cart.CurrentItems != null && cart.CurrentItems.Count > 0)
                    {
                        var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                        if (currentItem != null)
                        {
                            NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity;
                        }
                    }

                    if (NewVolumePoints > 0 || purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan)
                    {
                        //if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.Volume)
                        {
                            if (PurchasingLimits.maxVolumeLimit == -1)
                            {
                                return(Result);
                            }
                            decimal cartVolume = (cart as MyHLShoppingCart).VolumeInCart;

                            if (DistributorRemainingVolumePoints - (cartVolume + NewVolumePoints) < 0)
                            {
                                Result.Result = RulesResult.Failure;
                                Result.AddMessage(
                                    string.Format(
                                        HttpContext.GetGlobalResourceObject(
                                            string.Format("{0}_Rules", HLConfigManager.Platform),
                                            "VolumePointExceedsThresholdByIncreasingQuantity").ToString(),
                                        purchasingLimitManager.MaxPersonalPCConsumptionLimit));
                                cart.RuleResults.Add(Result);
                                //if (purchasingLimitManager.PurchasingLimitsRestriction ==
                                //    PurchasingLimitRestrictionType.MarketingPlan)
                                //    //MPE Thresholds
                                //{
                                //    if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU))
                                //    {
                                //        Result.AddMessage(
                                //            string.Format(
                                //                HttpContext.GetGlobalResourceObject(
                                //                    string.Format("{0}_Rules", HLConfigManager.Platform),
                                //                    "VolumePointExceedsThresholdByIncreasingQuantity").ToString(),
                                //                cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity));
                                //    }
                                //else
                                //{
                                //    Result.AddMessage(
                                //        string.Format(
                                //            HttpContext.GetGlobalResourceObject(
                                //                string.Format("{0}_Rules", HLConfigManager.Platform),
                                //                "VolumePointExceedsThreshold").ToString(), cart.CurrentItems[0].SKU));
                                //}
                                //}
                                //else
                                //{
                                //    if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU))
                                //    {
                                //        Result.AddMessage(
                                //            string.Format(
                                //                HttpContext.GetGlobalResourceObject(
                                //                    string.Format("{0}_Rules", HLConfigManager.Platform),
                                //                    "VolumePointExceedsByIncreasingQuantity").ToString(),
                                //                cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity));
                                //    }
                                //    else
                                //    {
                                //        Result.AddMessage(
                                //            string.Format(
                                //                HttpContext.GetGlobalResourceObject(
                                //                    string.Format("{0}_Rules", HLConfigManager.Platform),
                                //                    "VolumePointExceeds").ToString(), cart.CurrentItems[0].SKU));
                                //    }
                                //}
                            }
                        }
                    }
                }
            }
            return(Result);
        }
示例#27
0
        private void setupCart()
        {
            MyHLShoppingCart _cart = new MyHLShoppingCart
            {
                CurrentItems      = new ShoppingCartItemList(),
                CartItems         = new ShoppingCartItemList(),
                CountryCode       = "CN",
                DeliveryInfo      = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo(),
                DistributorID     = "test123",
                RuleResults       = new List <ShoppingCartRuleResult> {
                },
                Totals            = new HL.Order.ValueObjects.OrderTotals(),
                ShoppingCartItems = new List <Shared.Providers.DistributorShoppingCartItem>(),
            };

            OrderTotals_V02 totals = new OrderTotals_V02
            {
                AmountDue  = 500,
                ChargeList = new HL.Order.ValueObjects.ChargeList {
                    new HL.Order.ValueObjects.Charge_V01 {
                        ChargeType       = HL.Order.ValueObjects.ChargeTypes.FREIGHT,
                        Amount           = 25,
                        DiscountedAmount = 1
                    }
                },
                DiscountAmount = 1,
                ItemsTotal     = 500,
                OrderFreight   = new OrderFreight {
                    ActualFreight = 1, Packages = new List <Package> {
                        new Package {
                            Packagetype = "C", Unit = 1, Volume = 0.0078045M
                        }
                    },
                }
            };

            _cart.CartItems.Add(new ShoppingCartItem_V01()
            {
                SKU = "1316", ID = 1, Quantity = 2
            });
            _cart.CurrentItems.Add(new ShoppingCartItem_V01()
            {
                SKU = "1316", ID = 1, Quantity = 2
            });
            _cart.RuleResults.Add(new ShoppingCartRuleResult {
                RuleName = "ETO Rules"
            });
            _cart.DeliveryInfo = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo {
                FreightCode = "22", AddressType = "EXP", WarehouseCode = "3019", Option = HL.Common.ValueObjects.DeliveryOptionType.Shipping
            };
            _cart.Totals       = totals;
            _cart.DeliveryInfo = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo
            {
                Address = new HL.Shipping.ValueObjects.ShippingAddress_V01
                {
                    Address = new HL.Common.ValueObjects.Address_V01 {
                        StateProvinceTerritory = "广西壮族自治区", City = "梧州市", Country = "CN", CountyDistrict = "蝶山区", PostalCode = "111111"
                    }
                },
                AddressType = "EXP"
            };

            cart = _cart;

            var onePromo = new PromotionElement
            {
                AmountMinInclude = 500,
                PromotionType    = HL.Order.ValueObjects.China.PromotionType.Freight,
                StartDate        = DateTime.Now.ToString("MM-dd-yyyy"),
                EndDate          = DateTime.Now.ToString("MM-dd-yyyy"),
                excludedExpID    = new List <string> {
                    "10,30"
                },
                CustTypeList = new List <string> {
                    "PC,CS"
                },
                CustCategoryTypeList = new List <string> {
                    "PC"
                },
                Code = "DecPCPromo"
            };

            promotionSet.Add(onePromo);

            // Session
            sessionInfo = new SessionInfo
            {
                ShippingAddresses = new List <HL.Shipping.ValueObjects.ShippingAddress_V02>()
                {
                    new HL.Shipping.ValueObjects.ShippingAddress_V02
                    {
                        Address = new HL.Common.ValueObjects.Address_V01 {
                            City = "南宁市", StateProvinceTerritory = "广西壮族自治区", CountyDistrict = "青秀区", Country = "CN"
                        }
                    }
                }
            };

            //DistributorProfile
            distributorProfile = new DistributorOrderingProfile
            {
                CNAPFStatus        = 2,
                CNCustCategoryType = "PC",
                CNCustType         = "PC",
                IsPC            = true,
                Id              = "test123",
                CNStoreProvince = "广西壮族自治区"
            };
        }
示例#28
0
        public static DateTime GetAPFDueDate(string distributorID, string countryCode)
        {
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorID, countryCode);

            return(distributorOrderingProfile.ApfDueDate);
        }
        public static DRFraudStatusType CheckForDRFraud(string distributorID, string countryCode, string zipCode)
        {
            var fraudStatus = DRFraudStatusType.None;

            string CacheKey = string.Format("{0}_{1}", "DSFraud", countryCode);
            Dictionary <string, List <string> > blockedPostalCodes = HttpRuntime.Cache[CacheKey] as Dictionary <string, List <string> >;

            DistributorOrderingProfile distributorOrderingProfile = GetProfile(distributorID, countryCode);

            if (blockedPostalCodes == null)
            {
                using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
                {
                    try
                    {
                        var request = new GetDRFraudStatusRequest_V01();
                        request.DistributorID = distributorID;
                        request.CountryCode   = countryCode;
                        request.PostalCode    = zipCode;

                        request.DistributorIsBlocked = distributorOrderingProfile.IsDistributorBlocked;
                        request.SponsorIsBlocked     = distributorOrderingProfile.IsSponsorBlocked;

                        var response =
                            proxy.GetDRFraudStatus(new GetDRFraudStatusRequest(request)).GetDRFraudStatusResult as GetDRFraudStatusResponse_V01;
                        if (response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            fraudStatus        = response.FraudStatus;
                            blockedPostalCodes = response.BlockedPostCodes;
                        }
                        HttpRuntime.Cache[CacheKey] = response.BlockedPostCodes != null ? response.BlockedPostCodes : new Dictionary <string, List <string> > {
                        };
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Exception("System.Exception", new Exception(
                                                   string.Format(
                                                       "Error retrieving DRFraud Status from Order service for: DS:{0} - Country:{1}, {2}",
                                                       distributorID, countryCode, ex)));
                        fraudStatus = DRFraudStatusType.None;
                    }
                }
            }
            if (distributorOrderingProfile.IsDistributorBlocked && blockedPostalCodes != null)
            {
                if (blockedPostalCodes.ContainsKey(countryCode) && blockedPostalCodes[countryCode].Contains(zipCode))
                {
                    return(DRFraudStatusType.PostalCodeIsBlocked);
                }
            }

            //if (fraudStatus == DRFraudStatusType.DistributorIsBlocked)
            //{
            //    errorResxKey = "BlockedDS";
            //}
            //else if (fraudStatus == DRFraudStatusType.PostalCodeIsBlocked)
            //{
            //    errorResxKey = "BlockedZip";
            //}

            return(fraudStatus);
        }
        public static string CheckForDRFraud(DistributorOrderingProfile distributor, string zipCode)
        {
            string errorResxKey = string.Empty;
            var    fraudStatus = DRFraudStatusType.None;
            bool   isBlocked, isSponsorBlocked, isDsFound;

            isBlocked = isSponsorBlocked = isDsFound = false;

            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    if (distributor != null && distributor.FraudStatus == null)
                    {
                        using (var proxyDs = ServiceClientProvider.GetDistributorServiceProxy())
                        {
                            var requestV01 = new GetBasicDistributorRequest_V01
                            {
                                DistributorID = distributor.Id
                            };

                            var circuitBreaker =
                                CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBasicDistributorResponse_V01>();
                            var responseV01 =
                                circuitBreaker.Execute(() => proxyDs.GetBasicDistributor(new GetBasicDistributorRequest(requestV01))).GetBasicDistributorResult as
                                GetBasicDistributorResponse_V01;

                            if (responseV01 != null && responseV01.Status == ServiceResponseStatusType.Success)
                            {
                                if (responseV01.Distributor != null)
                                {
                                    isBlocked        = responseV01.Distributor.DRFraudStatusFlags.IsDistributorblocked;
                                    isSponsorBlocked = responseV01.Distributor.DRFraudStatusFlags.IsSponsorBlocked;
                                    isDsFound        = true;
                                }
                            }
                        }
                    }
                    else if (distributor != null && distributor.FraudStatus != null)
                    {
                        isBlocked        = distributor.FraudStatus.IsDistributorblocked;
                        isSponsorBlocked = distributor.FraudStatus.IsSponsorBlocked;
                        isDsFound        = true;
                    }

                    if (isDsFound)
                    {
                        var request = new GetDRFraudStatusRequest_V01();
                        request.DistributorID        = distributor.Id;
                        request.CountryCode          = distributor.CurrentLoggedInCountry;
                        request.PostalCode           = zipCode;
                        request.DistributorIsBlocked = isBlocked;
                        request.SponsorIsBlocked     = isSponsorBlocked;

                        var response =
                            proxy.GetDRFraudStatus(new GetDRFraudStatusRequest(request)).GetDRFraudStatusResult as GetDRFraudStatusResponse_V01;
                        if (response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            fraudStatus = response.FraudStatus;
                        }
                    }
                    else
                    {
                        LoggerHelper.Exception("System.Exception", new Exception(
                                                   string.Format(
                                                       "Error retrieving DS DRFraudStatusFlags from Cache and Distributor service for: DS:{0} - Country:{1}",
                                                       distributor.Id, distributor.CurrentLoggedInCountry)));
                        fraudStatus = DRFraudStatusType.None;
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Exception("System.Exception", new Exception(
                                               string.Format(
                                                   "Error retrieving DRFraud Status from Order service for: DS:{0} - Country:{1}, {2}",
                                                   distributor.Id, distributor.CurrentLoggedInCountry, ex)));
                    fraudStatus = DRFraudStatusType.None;
                }
            }

            if (fraudStatus == DRFraudStatusType.DistributorIsBlocked)
            {
                errorResxKey = "BlockedDS";
            }
            else if (fraudStatus == DRFraudStatusType.PostalCodeIsBlocked)
            {
                errorResxKey = "BlockedZip";
            }

            return(errorResxKey);
        }