Beispiel #1
0
        /// <summary>
        /// WritePurchasingLimitsToDB
        /// </summary>
        /// <param name="limits"></param>
        private void WritePurchasingLimitsToDB(List <PurchasingLimits> limits)
        {
            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var currentLocalTime = HL.Common.Utilities.DateUtils.GetCurrentLocalTime(_currentLoggedInCountry);

                    foreach (PurchasingLimits l in limits)
                    {
                        PurchasingLimits_V01             lV01 = l as PurchasingLimits_V01;
                        PurchasingLimitRestrictionPeriod purchasingLimitRestrictionPeriod = HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionPeriod;
                        if (lV01.LimitsRestrictionType == LimitsRestrictionType.FOP || lV01.LimitsRestrictionType == LimitsRestrictionType.OrderThreshold)
                        {
                            purchasingLimitRestrictionPeriod = PurchasingLimitRestrictionPeriod.OneTime;
                        }
                        //else if (lV01.LimitsRestrictionType ==  HL.Order.ValueObjects.LimitsRestrictionType.OrderThreshold)
                        //    purchasingLimitRestrictionPeriod = PurchasingLimitRestrictionPeriod.Monthly;

                        var request = new SetPurchasingLimitsRequest_V02
                        {
                            DistributorId     = _distributorId,
                            Country           = _currentLoggedInCountry,
                            OrderMonth        = string.Format("{0}{1}", lV01.Year, lV01.Month),
                            PurchasingLimits  = lV01,
                            RestrictionPeriod = purchasingLimitRestrictionPeriod
                        };

                        var response =
                            proxy.SetPurchasingLimits(new SetPurchasingLimitsRequest1(request)).SetPurchasingLimitsResult as SetPurchasingLimitsResponse_V02;
                        if (response != null && response.Status == MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            HL.Common.Logging.LoggerHelper.Info("WritePurchasingLimitsToDB update successful");
                        }
                    }
                }
                catch (Exception ex)
                {
                    HL.Common.Logging.LoggerHelper.Exception("System.Exception", new Exception(
                                                                 string.Format(
                                                                     "Error WritePurchasingLimitsToDB for: DS:{0} - Country:{1}, {2}",
                                                                     _distributorId, _currentLoggedInCountry, ex)));
                }
            }
        }
 private void setValues(PurchasingLimits_V01 l, PurchasingLimitRestrictionPeriod period, decimal maxValue)
 {
     l.RestrictionPeriod     = period;
     l.maxVolumeLimit        = l.RemainingVolume = maxValue;
     l.LimitsRestrictionType = LimitsRestrictionType.PurchasingLimits;
 }
 /// <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;
 }
        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);
        }