private void DisplayRemainingValues(string DSSubType, bool Refresh)
        {
            trRemainingVal.Visible = true;
            var limits = new PurchasingLimits_V01();

            if (string.IsNullOrEmpty(DSSubType))
            {
                trRemainingVal.Visible = false;
                return;
            }
            else
            {
                limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSSubType);
            }
            if (!this.FOPEnabled)
            {
                displayPurchasingLimits(DSSubType, limits, Refresh);
            }
            else
            {
                if (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits)
                {
                    displayPurchasingLimits(DSSubType, limits, Refresh);
                }
                else
                {
                    displayFOP(limits, Refresh);
                }
            }
        }
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            var currentLimits = base.GetPurchasingLimits(distributorId, TIN);
            var theLimits     = currentLimits[PurchasingLimitProvider.GetOrderMonth()];
            var limitsType    = PurchaseLimitType.ProductCategory;

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

            codes.Add(CountryType.VN.Key);

            if (codes.Contains(DistributorProfileModel.ProcessingCountryCode))
            {
                var hasValidTin = HasValidTin(distributorId);
                //var hasMandatoryNotes = HasMandatoryNotes(distributorId);

                //if (hasValidTin && !hasMandatoryNotes && DistributorProfileModel.TypeCode.ToUpper().Equals("DS"))
                if (hasValidTin && DistributorProfileModel.TypeCode.ToUpper().Equals("DS"))
                {
                    limitsType = PurchaseLimitType.Volume;
                    theLimits.RemainingVolume = MaxVolPoints;
                }
            }
            currentLimits.Values.AsQueryable().ToList().ForEach(pl => pl.PurchaseLimitType = limitsType);
            return(currentLimits);
        }
        private void CleanupCart(MyHLShoppingCart cart)
        {
            if (PurchasingLimitProvider.RequirePurchasingLimits(cart.DistributorID, cart.CountryCode))
            {
                PurchasingLimitProvider.ReconcileAfterPurchase(cart, cart.DistributorID, Country);
            }

            if (null != HttpContext.Current)
            {
                var currentSession = SessionInfo.GetSessionInfo(cart.DistributorID, Locale);
                if (currentSession != null)
                {
                    if (!String.IsNullOrEmpty(currentSession.OrderNumber))
                    {
                        currentSession.OrderNumber                      = String.Empty;
                        currentSession.OrderMonthShortString            = string.Empty;
                        currentSession.OrderMonthString                 = string.Empty;
                        currentSession.ShippingMethodNameMX             = String.Empty;
                        currentSession.ShippingMethodNameUSCA           = String.Empty;
                        currentSession.ShoppingCart.CustomerOrderDetail = null;
                        // currentSession.CustomerPaymentSettlementApproved = false; Commented out for merge. Need to investigate
                        currentSession.CustomerOrderNumber = String.Empty;
                        currentSession.CustomerAddressID   = 0;
                    }
                }
                //Clear the order month session...
                HttpContext.Current.Session["OrderMonthDataSessionKey"] = null;
                SessionInfo.SetSessionInfo(cart.DistributorID, Locale, currentSession);
            }

            ShoppingCartProvider.UpdateInventory(cart, Country, Locale, true);
        }
Exemple #4
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);
        }
        public PurchasingLimits ReloadPurchasingLimits(int orderMonth)
        {
            PurchasingLimits_V01 purchasingLimitsV01 = null;

            try
            {
                if (PurchasingLimitProvider.RequirePurchasingLimits(_distributorId, _currentLoggedInCountry))
                {
                    CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection());
                }
                if (PurchasingLimits == null)
                {
                    return(purchasingLimitsV01);
                }
                if (orderMonth > 0)
                {
                    SetPurchasingLimits(orderMonth);
                }
                SaveToCache();
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString());
            }
            if (PurchasingLimits != null)
            {
                PurchasingLimits.TryGetValue(orderMonth, out purchasingLimitsV01);
            }
            return(purchasingLimitsV01);
        }
        private bool CanBuy_eLearningRule(MyHLShoppingCart hlCart)
        {
            bool   retVal       = true;
            var    session      = SessionInfo.GetSessionInfo(hlCart.DistributorID, hlCart.Locale);
            string trainingCode = HLConfigManager.Configurations.ShoppingCartConfiguration.TrainingCode;

            if (session.DsTrainings == null)
            {
                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))
            {
                var     currentLimits       = PurchasingLimitProvider.GetCurrentPurchasingLimits(hlCart.DistributorID);
                decimal currentVolumePoints = hlCart.VolumeInCart;

                var currentItem = CatalogProvider.GetCatalogItem(hlCart.CurrentItems[0].SKU, Country);
                currentVolumePoints += currentItem.VolumePoints * hlCart.CurrentItems[0].Quantity;
                if (currentLimits.PurchaseLimitType == PurchaseLimitType.Volume)
                {
                    currentVolumePoints += (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                }

                if (currentVolumePoints > HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV)
                {
                    retVal = false;
                }
            }


            return(retVal);
        }
Exemple #7
0
        protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason,
                                                               ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                var myhlCart = cart as MyHLShoppingCart;

                if (null == myhlCart)
                {
                    LoggerHelper.Error(
                        string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }
                // to set purchasing limit type
                var theLimits     = GetPurchasingLimits(cart.DistributorID, myhlCart.SelectedDSSubType ?? string.Empty);
                var currentLimits = theLimits[PurchasingLimitProvider.GetOrderMonth()];
                if (currentLimits.PurchaseLimitType == PurchaseLimitType.Earnings)
                {
                    var itemsToCalc = new List <ShoppingCartItem_V01>();
                    itemsToCalc.AddRange(myhlCart.CartItems);
                    if (myhlCart.CurrentItems != null && myhlCart.CurrentItems.Count > 0)
                    {
                        itemsToCalc.Add(myhlCart.CurrentItems[0]);
                    }
                    OrderTotals_V01 orderTotals = myhlCart.Calculate(itemsToCalc) as OrderTotals_V01;
                    if (orderTotals != null && orderTotals.DiscountPercentage != 0.0M)
                    {
                        myhlCart.SetDiscountForLimits(orderTotals.DiscountPercentage);
                        myhlCart.Totals = orderTotals;
                    }
                }
            }
            return(base.PerformRules(cart, reason, Result));
        }
 public override bool PurchasingLimitsAreExceeded(string distributorId)
 {
     if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorId))
     {
         return(base.PurchasingLimitsAreExceeded(distributorId));
     }
     return(false);
 }
Exemple #9
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;
            }
        }
        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);
            }
        }
        private void DisplayRemainingValues(string DSSubType, bool Refresh)
        {
            PurchasingLimits_V01 limits = new PurchasingLimits_V01();

            ShoppingCart.EmailValues.RemainingVolume = string.Empty;

            if (string.IsNullOrEmpty(DSSubType))
            {
                limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID);
            }
            else
            {
                limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSSubType);
            }
            if (FOPEnabled)
            {
                trRemainingVal.Visible = limits.RemainingVolume > -1;
            }
            else
            {
                trRemainingVal.Visible = PurchasingLimitManager(ShoppingCart.DistributorID).PurchasingLimitsRestriction != PurchasingLimitRestrictionType.MarketingPlan;
            }

            if (DSSubType == "RE")
            {
                //trRemainingVal.Visible = false;
                OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, Refresh));
            }

            lblRemainingValDisplay.Text = this.GetLocalResourceObject("RemainingVolume").ToString();
            if (ShoppingCart != null && limits != null)
            {
                decimal totalDue  = TotalsExcludeAPF(ShoppingCart, this.CountryCode);
                decimal remaining = decimal.Zero;
                if (FOPEnabled)
                {
                    decimal cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart;
                    remaining = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? limits.RemainingVolume - totalDue : limits.RemainingVolume - cartVolume;
                }
                else
                {
                    remaining = limits.RemainingVolume - totalDue;
                }
                if (remaining < 0)
                {
                    remaining = 0;
                }
                this.lblRemainingVal.Text    = limits.PurchaseLimitType == PurchaseLimitType.Volume ? remaining.ToString("N2") : this.getAmountString(remaining);
                this.lblRemainingVal.Visible = limits.PurchaseLimitType != PurchaseLimitType.None;
            }
            if (trRemainingVal.Visible)
            {
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
            OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, false, true, Refresh));
        }
 public void LoadPurchasingLimits()
 {
     if (PurchasingLimitProvider.RequirePurchasingLimits(_distributorId, _currentLoggedInCountry))
     {
         if (PurchasingLimits == null)
         {
             CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection());
         }
     }
 }
        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 void ReloadPurchasingLimits(string distributorID)
 {
     try
     {
         if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorID))
         {
             CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection());
         }
         if (PurchasingLimits != null)
         {
             SaveToCache();
         }
     }
     catch (Exception ex)
     {
         LoggerHelper.Error(ex.ToString());
     }
 }
        private void CleanupOrder(MyHLShoppingCart cart, string distributorId)
        {
            if (!IsPostBack)
            {
                if (PurchasingLimitProvider.RequirePurchasingLimits(distributorId, _country))
                {
                    PurchasingLimitProvider.ReconcileAfterPurchase(cart, distributorId, _country);
                }

                if (cart != null)
                {
                    // take out quantities from inventory
                    ShoppingCartProvider.UpdateInventory(cart, cart.CountryCode, cart.Locale, true);
                }

                cart.CloseCart();
            }
        }
        private DateTime GetLastQuarterlyCutoff()
        {
            int currentOrderMonth = PurchasingLimitProvider.GetOrderMonth();
            var lastCutoff        = DateTime.MinValue;
            int month             = int.Parse(currentOrderMonth.ToString().Substring(4));
            int year = int.Parse(currentOrderMonth.ToString().Substring(0, 4));

            switch (month)
            {
            case 1:
            case 2:
            case 3:
            {
                lastCutoff = new DateTime(year - 1, 12, 31, 23, 59, 59);
                break;
            }

            case 4:
            case 5:
            case 6:
            {
                lastCutoff = new DateTime(year, 3, 31, 23, 59, 59);
                break;
            }

            case 7:
            case 8:
            case 9:
            {
                lastCutoff = new DateTime(year, 6, 30, 23, 59, 59);
                break;
            }

            case 10:
            case 11:
            case 12:
            {
                lastCutoff = new DateTime(year, 9, 30, 23, 59, 59);
                break;
            }
            }

            return(lastCutoff);
        }
Exemple #17
0
 public void RefreshVisibility(object sender, EventArgs e)
 {
     if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode))
     {
         if (null != _cart)
         {
             PurchasingLimits_V01 limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID);
             if (null != limits)
             {
                 if (limits.PurchaseType == OrderPurchaseType.Consignment)
                 {
                     pnlAPFIsDueWithinYear.Visible = false;
                     pnlAPFPaid.Visible            = false;
                 }
                 SetPanelsVisibility();
             }
         }
     }
 }
        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);
        }
Exemple #19
0
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            var currentLimits = base.GetPurchasingLimits(distributorId, TIN);
            var theLimits     = currentLimits[PurchasingLimitProvider.GetOrderMonth()];

            if (TIN.Equals("ETO"))
            {
                TIN = "E";
            }

            theLimits.PurchaseSubType = TIN;

            if (RetailSubTypes.Contains(theLimits.PurchaseSubType))
            {
                theLimits.PurchaseType      = OrderPurchaseType.PersonalConsumption;
                theLimits.PurchaseLimitType = PurchaseLimitType.DiscountedRetail;
            }
            else if (ResaleSubTypes.Contains(theLimits.PurchaseSubType))
            {
                theLimits.PurchaseType      = OrderPurchaseType.Consignment;
                theLimits.PurchaseLimitType = PurchaseLimitType.None;
            }
            else
            {
                if (PurchasingLimitManager(distributorId).PurchasingLimitsRestriction !=
                    PurchasingLimitRestrictionType.MarketingPlan)
                {
                    theLimits.PurchaseLimitType = PurchaseLimitType.None;

                    if (!ExemptSubTypes.Contains(theLimits.PurchaseSubType))
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "Unknown Distributor Subtype of \"{0}\" encountered in PurchasingLimitRules for fr-FR, Distributor: {1}",
                                theLimits.PurchaseSubType, distributorId));
                    }
                }
            }

            return(currentLimits);
        }
Exemple #20
0
        protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason,
                                                               ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                var currentLimits = base.GetPurchasingLimits(cart.DistributorID, string.Empty);
                var theLimits     = currentLimits[PurchasingLimitProvider.GetOrderMonth()];
                // If it's threshold volume point for all product types is counted
                if (PurchasingLimitProvider.IsOrderThresholdMaxVolume(theLimits))
                {
                    Result = base.PerformRules(cart, reason, Result);
                }
                else if (!DistributorIsExemptFromPurchasingLimits(cart.DistributorID))
                {
                    CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                    Result = base.PerformRules(cart, reason, Result);
                }
            }

            return(Result);
        }
Exemple #21
0
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            var codes = new List <string>(CountryType.AR.HmsCountryCodes);

            codes.Add(CountryType.AR.Key);
            var arCOP = codes.Contains(DistributorProfileModel.ProcessingCountryCode);

            var purchasingLimits = base.GetPurchasingLimits(distributorId, TIN);

            // inform UI to not show remaining info.
            var purchasingLimitManager = PurchasingLimitManager(distributorId);
            var currentLimits          = PurchasingLimitProvider.GetCurrentPurchasingLimits(distributorId);

            if (currentLimits.RemainingVolume == MaxAmount || !arCOP || currentLimits.maxVolumeLimit == -1)
            {
                purchasingLimitManager.PurchasingLimits.Values.AsQueryable()
                .ToList()
                .ForEach(pl => pl.PurchaseLimitType = PurchaseLimitType.None);
            }
            return(purchasingLimits);
        }
Exemple #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            (Page.Master as OrderingMaster).EventBus.RegisterObject(this);
            _testing = !string.IsNullOrEmpty(Request["testAPF"]);
            _cart    = (Page as ProductsBase).ShoppingCart;
            //TaskID: 9016 fix
            Visible = _testing |
                      (APFDueProvider.ShouldShowAPFModule(DistributorID, Thread.CurrentThread.CurrentCulture.Name.Substring(3)) &&
                       (null != _cart && _cart.OrderCategory == OrderCategoryType.RSO));
            if (DistributorOrderingProfile.IsPC)
            {
                Visible = false;
            }
            if (_cart.OrderCategory == OrderCategoryType.HSO)
            {
                Visible = false;
            }
            SetPanelsVisibility();
            if (Visible)
            {
                if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, this.CountryCode))
                {
                    ReadFromData();
                    RefreshVisibility(null, null);
                }

                pnlAPFIsDueWithinYear.Visible = false;
                pnlAPFPaid.Visible            = false;
                pnlTesting.Visible            = _testing;

                //if (IsPostBack)
                //{
                ReadFromPage();
                //}
                //else
                //{
                DisplayData();
                //}
            }
        }
Exemple #23
0
        public DistributorOrderingProfile GetDistributorOrderingProfile(string id, string countryCode)
        {
            var distributorOrderingProfileCacheKey = string.Format("DO_DS_{0}", id);
            var expires = 15;

            int.TryParse(Settings.GetRequiredAppSetting("DistributorCacheExpireMinutes"), out expires);

            var orderingProfile = _cache.Retrieve(_ => CreateDistributorOrderingProfile(id, countryCode),
                                                  distributorOrderingProfileCacheKey, TimeSpan.FromMinutes(expires));

            if (orderingProfile.CurrentLoggedInCountry != countryCode)
            {
                if (orderingProfile.CurrentLoggedInCountry == "KR" | countryCode == "KR")
                {
                    var distributor = _distributorLoader.Load(id, countryCode);
                    if (distributor != null)
                    {
                        _distributorLoader.Expire(distributor, id, string.Empty);
                    }
                    _cache.Expire(typeof(DistributorOrderingProfile), distributorOrderingProfileCacheKey);
                    orderingProfile = _cache.Retrieve(_ => CreateDistributorOrderingProfile(id, countryCode),
                                                      distributorOrderingProfileCacheKey, TimeSpan.FromMinutes(expires));
                }
                else
                {
                    if (!Settings.GetRequiredAppSetting <bool>("FOPEnabled", false))
                    {
                        //For other countries, we just update the existing cached distributor
                        if (PurchasingLimitProvider.RequirePurchasingLimits(id, countryCode))
                        {
                            IPurchasingLimitManagerFactory purchasingLimitManagerFactory =
                                new PurchasingLimitManagerFactory();
                            purchasingLimitManagerFactory.GetPurchasingLimitManager(id).LoadPurchasingLimits();
                        }
                    }
                }
                orderingProfile.CurrentLoggedInCountry = countryCode;
            }
            return(orderingProfile);
        }
 protected void ddl_DSSubType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(ddl_DSSubType.SelectedItem.Value))
     {
         bool refresh = false;
         PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_DSSubType.SelectedItem.Value);
         ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value;
         //If the order type is switched to Resale and DS has added APFs to cart, throw them out
         if (limits.PurchaseType == OrderPurchaseType.Consignment && 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)
                     {
                         CartModifiedForSKULimitationsEventArgs args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]);
                         OnCartItemRemovedDueToSKULimitationRules(this, args);
                     }
                 }
             }
             ShoppingCart.Calculate();
             OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, true));
         }
         DisplayRemainingValues(ddl_DSSubType.SelectedItem.Value, refresh);
         lblMessageZeroPercent.Visible = ShoppingCart.SelectedDSSubType == "RE";
     }
     else
     {
         ShoppingCart.SelectedDSSubType = String.Empty;
         trRemainingVal.Visible         = false;
     }
 }
Exemple #25
0
        private ShoppingCartRuleResult CartRetrievedRuleHandler(ShoppingCart_V01 cart,
                                                                ShoppingCartRuleResult result)
        {
            try
            {
                if (null != cart)
                {
                    if (APFDueProvider.IsAPFSkuPresent(cart.CartItems) &&
                        APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale))
                    {
                        var limits =
                            PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID);
                        if (null != limits && null != limits.PurchaseSubType)
                        {
                            if (limits.PurchaseType == ServiceProvider.OrderSvc.OrderPurchaseType.Consignment)
                            //No consignment allowed when APFDue
                            {
                                if (limits.PurchaseSubType == "A1")
                                {
                                    limits.PurchaseSubType = "A2";
                                }
                                if (limits.PurchaseSubType == "B1")
                                {
                                    limits.PurchaseSubType = "B2";
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("APFRules.it-IT.ProcessAPF DS:{0} locale:{2} ERR:{1}", cart.DistributorID, ex, Locale));
            }

            return(result);
        }
Exemple #26
0
        public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN)
        {
            var currentLimits = base.GetPurchasingLimits(distributorId, TIN);
            var theLimits     = currentLimits[PurchasingLimitProvider.GetOrderMonth()];

            //conditional massage of subtype
            if (TIN.Equals("D") || TIN.Equals("ETO"))
            {
                TIN = "D2";
            }

            theLimits.PurchaseSubType = TIN;

            if (RetailSubTypes.Contains(theLimits.PurchaseSubType))
            {
                theLimits.PurchaseType      = OrderPurchaseType.PersonalConsumption;
                theLimits.PurchaseLimitType = PurchaseLimitType.Volume;
            }
            else if (ResaleSubTypes.Contains(theLimits.PurchaseSubType))
            {
                theLimits.PurchaseType      = OrderPurchaseType.Consignment;
                theLimits.PurchaseLimitType = PurchaseLimitType.Earnings;
            }
            else
            {
                if (!ExemptSubTypes.Contains(theLimits.PurchaseSubType))
                {
                    LoggerHelper.Error(
                        string.Format(
                            "Unknown Distributor Subtype of \"{0}\" encountered in PurchasingLimitRules for it-IT, Distributor: {1}",
                            theLimits.PurchaseSubType, distributorId));
                }
            }

            return(currentLimits);
        }
Exemple #27
0
        private void DisplayRemaining()
        {
            string DSType = DistributorOrderingProfile.OrderSubType == null ? string.Empty : DistributorOrderingProfile.OrderSubType;
            PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType);

            ShoppingCart.SelectedDSSubType           = string.IsNullOrEmpty(DSType) ? "NA" : DSType;
            ShoppingCart.EmailValues.RemainingVolume = string.Empty;
            decimal cartVolume = ShoppingCart.VolumeInCart;

            if (null != limits)
            {
                decimal remaining = decimal.Zero;
                if (FOPEnabled)
                {
                    cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart;
                }
                remaining = (limits.RemainingVolume - cartVolume);

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

                lblRemainingVal.Text = remaining.ToString("N2");
            }

            trRemainingVal.Visible = ((null != limits && limits.PurchaseLimitType == PurchaseLimitType.Volume)
                                      ||
                                      (null != limits &&
                                       PurchasingLimitManager(DistributorID).PurchasingLimitsRestriction ==
                                       PurchasingLimitRestrictionType.MarketingPlan));
            if (trRemainingVal.Visible)
            {
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
        }
        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()];

            theLimits.PurchaseSubType = TIN;

            if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorId))
            {
                theLimits.PurchaseLimitType = PurchaseLimitType.Volume;
                return(currentLimits);
            }
            if (DistributorIsExemptFromPurchasingLimits(distributorId))
            {
                theLimits.PurchaseLimitType = PurchaseLimitType.None;
            }
            else
            {
                theLimits.PurchaseType      = OrderPurchaseType.PersonalConsumption;
                theLimits.PurchaseLimitType = PurchaseLimitType.TotalPaid;
            }

            return(currentLimits);
        }
        protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result)
        {
            decimal NewVolumePoints = 0m;
            decimal cartVolume      = 0m;

            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                if (currentItem == null)
                {
                    return(Result);
                }

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

                var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true);
                IPurchasingLimitManager manager = new PurchasingLimitManagerFactory().GetPurchasingLimitManager(cart.DistributorID);

                if (!codes.Contains(DistributorProfileModel.ProcessingCountryCode)) // foreign DS
                {
                    //Foreign DS without local National ID they cannot purchase "P" type products.
                    if (tins != null && tins.Find(t => t.IDType.Key == "SNID") == null)
                    {
                        if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.Product)
                        {
                            Result.Result = RulesResult.Failure;
                            Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString());
                            cart.RuleResults.Add(Result);
                            return(Result);
                        }
                    }
                    //Foreign DS with local National ID they can purchase P L and A type items.
                }
                if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(cart.DistributorID))
                {
                    return(base.PerformRules(cart, reason, Result));
                }

                // 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)
                {
                    MyHLShoppingCart myCart = cart as MyHLShoppingCart;
                    if (!string.IsNullOrEmpty(myCart.VolumeInCart.ToString()))
                    {
                        cartVolume = myCart.VolumeInCart;
                    }

                    NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity;

                    if (cartVolume + NewVolumePoints > MaxVolPoints)
                    {
                        Result.AddMessage(
                            string.Format(
                                HttpContext.GetGlobalResourceObject(
                                    string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceeds")
                                .ToString(), cart.CurrentItems[0].SKU));
                        Result.Result = RulesResult.Failure;
                        cart.RuleResults.Add(Result);
                        return(Result);
                    }
                    else
                    {
                        return(Result);
                    }
                }
            }

            return(Result);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <TaxIdentification> tinList = DistributorOrderingProfile.TinList;

            if (!IsPostBack)
            {
                if (ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)
                {
                    trOrderType.Visible            = false;
                    trRemainingVal.Visible         = false;
                    ShoppingCart.SelectedDSSubType = "NA";
                    PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO");
                    return;
                }

                if (tinList == null || tinList.Where(t => t.IDType.Key == "GRVT").Count() == 0)
                {
                    trOrderType.Visible            = false;
                    trRemainingVal.Visible         = true;
                    ShoppingCart.SelectedDSSubType = "PC";
                    DisplayRemainingValues(ShoppingCart.SelectedDSSubType);
                }
                else
                {
                    if (tinList.Where(t => t.IDType.Key == "GRVT" || t.IDType.Key == "GRTN" || t.IDType.Key == "GRSS" || t.IDType.Key == "GRBL").Count() == 4)
                    {
                        trRemainingVal.Visible = false;
                        trOrderType.Visible    = true;
                    }
                    else
                    {
                        trRemainingVal.Visible = true;
                        trOrderType.Visible    = true;
                    }

                    if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType))
                    {
                        ddl_DSSubType.ClearSelection();
                        ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType);
                        if (null != item)
                        {
                            item.Selected        = true;
                            lblOrderTypeVal.Text = item.Text;
                        }
                        else
                        {
                            if (ddl_DSSubType.Items.Count > 0)
                            {
                                item                           = ddl_DSSubType.Items[0];
                                item.Selected                  = true;
                                lblOrderTypeVal.Text           = item.Text;
                                ShoppingCart.SelectedDSSubType = item.Value;
                            }
                        }
                        DisplayRemainingValues(ShoppingCart.SelectedDSSubType);
                    }
                    else
                    {
                        //User Story 102057: INC2676705: Default 'Προσωπικό όριο αγορών' (Personal limit)
                        ListItem item = ddl_DSSubType.Items.FindByValue("PC");
                        item.Selected                  = true;
                        lblOrderTypeVal.Text           = item.Text;
                        ShoppingCart.SelectedDSSubType = item.Value;

                        ShoppingCart.Calculate();
                        OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(item.Value, true, false, true));
                    }

                    if (DisplayStatic)
                    {
                        ddl_DSSubType.Visible   = false;
                        lblOrderTypeVal.Visible = true;
                    }
                    else
                    {
                        ddl_DSSubType.Visible   = true;
                        lblOrderTypeVal.Visible = false;
                    }
                }
                lblMessageZeroPercent.Visible = false;
                if (ddl_DSSubType.Visible == true)
                {
                    if (ddl_DSSubType.SelectedValue != null && ddl_DSSubType.SelectedValue == "RE")
                    {
                        lblMessageZeroPercent.Visible = true;
                    }
                }
            }
        }