public void ProcessCartTestGlobal_DuplicateSKUs_Fail() { string DsId = "1111111111"; string Local = "en-IN"; var testSettings = new OrderingTestSettings(Local, DsId); var target = new Ordering.Rules.CartIntegrity.Global.CartIntegrityRules(); var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3)); HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor); var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart( DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem> { ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local), ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local) }, OrderCategoryType.ETO); var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartCalculated); if (result.Count > 0 && result[0].Messages.Count > 0) { Assert.AreEqual(result[0].Messages[0], "Duplicate sku found. DS: 1111111111, CART: 0, SKU 1248 removed from cart."); } else { Assert.Fail("SKU 1248 is dupliacte.it should be removed from the cart"); } }
private bool CanPurchase(string distributorID) { bool canPurchase = true; var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, false, true); var now = DateUtils.GetCurrentLocalTime(COUNTRY_TIME); var idTIN = RetrieveIDTinCode(tins); bool isDummyTIN = IsDummyTin(idTIN); bool isIDCOP = IsIDCountryOfProcessing(); if (idTIN != null) { if (!isDummyTIN) { if (isIDCOP && idTIN.IDType.ExpirationDate < now) //ID Member with expired TIN { canPurchase = false; } } } else //no TINs found { if (isIDCOP) //ID members can't purchase without TINs { canPurchase = false; } } return(canPurchase); }
public override InvoiceModel CalculateDistributorPriceOnCustomerSection(InvoiceModel invoice, string memberId, string locale, string countryCode) { var address = !invoice.InvoiceShipToAddress ? (invoice.MemberAddress != null && !string.IsNullOrEmpty(invoice.MemberAddress.City) && !string.IsNullOrEmpty(invoice.MemberAddress.State)) ? GetAddressFromInvoice(invoice.MemberAddress) : DistributorOrderingProfileProvider.GetAddress(AddressType.Mailing, memberId, countryCode) : GetAddressFromInvoice(invoice.Address); var warehouseCode = _invoiceShipping.GetWarehouseCode(ObjectMappingHelper.Instance.GetToShipping(address as Address_V01), locale); var shippingMethodId = _invoiceShipping.GetShippingMethodId(ObjectMappingHelper.Instance.GetToShipping(address as Address_V01), locale); var order = ConvertToDistributorrOrder(invoice, memberId, countryCode, address, warehouseCode, shippingMethodId, invoice.InvoicePrice.DiscountPercentage); order.UseSlidingScale = true; var response = CallDistributorPricing(order, true); if (null == response) { LoggerHelper.Error("Invoice CalculateDistributorPriceOnCustomerSection Pricing error"); return(invoice); } CalculateDiscountedAmount(invoice, response); CalculateShippingAmount(invoice, response); CalculateTaxAmount(invoice, response); CalculateTotalDue(invoice); CalculateProfit(invoice); return(invoice); }
public Dictionary <string, bool> GetEventsByDistributor() { if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.EventId)) { var distributorProfileModel = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); var cacheKey = string.Format("distributorEvents_{0}", distributorProfileModel.Value.Id); var distributorEvents = HttpRuntime.Cache[cacheKey] as Dictionary <string, bool>; if (distributorEvents == null || distributorEvents.Count == 0) { var eventIds = HLConfigManager.Configurations.DOConfiguration.EventId.Split('|'); foreach (var id in eventIds) { var eventId = 0; if (int.TryParse(id, out eventId) && eventId > 0) { var dsWithTicket = false; var isQualified = DistributorOrderingProfileProvider.IsEventQualified(eventId, "ru-RU", out dsWithTicket); if (distributorEvents == null) { distributorEvents = new Dictionary <string, bool>(); } distributorEvents.Add(id, isQualified && dsWithTicket); } } HttpRuntime.Cache.Insert(cacheKey, distributorEvents, null, DateTime.Now.AddMinutes(RU_SHIPPINGINFO_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } return(distributorEvents); } return(null); }
public override Dictionary <int, PurchasingLimits_V01> GetPurchasingLimits(string distributorId, string TIN) { var currentLimits = base.GetPurchasingLimits(distributorId, TIN); var limitsType = PurchaseLimitType.ProductCategory; if (!DistributorIsExemptFromPurchasingLimits(distributorId)) { List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true); if ((tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "HROI", "HRNA", "HRRP" }).Count() == 3) || (tins != null && tins.Select(c => c.IDType.Key).Intersect(new[] { "HROI", "HRNA", "HRPI" }).Count() == 3) ) { limitsType = PurchaseLimitType.None; } else { limitsType = PurchaseLimitType.Volume; } } else { limitsType = PurchaseLimitType.None; } currentLimits.Values.AsQueryable().ToList().ForEach(pl => pl.PurchaseLimitType = limitsType); return(currentLimits); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (ForFControlValidation()) { var sessionInfo = SessionInfo.GetSessionInfo(ShoppingCart.DistributorID, ShoppingCart.Locale); if (!string.IsNullOrEmpty(sessionInfo.BRPF)) { var digits = sessionInfo.BRPF.Split('-'); txtCPF.Text = digits[0]; txtVCode.Text = digits[1]; } divCPF.Visible = true; divCPFStatic.Visible = false; } else { pnlCPF.Visible = false; } if (string.IsNullOrEmpty(ShoppingCart.TaxPersonalId)) { // Getting the CPF from the distributor properties ShoppingCart.TaxPersonalId = DistributorOrderingProfileProvider.GetTaxIdentificationId(ShoppingCart.DistributorID, "BRPF"); } }
public bool CanPurchase(string distributorID, string countryCode) { bool canPurchase = false; var codes = new List <string>(CountryType.PE.HmsCountryCodes); codes.Add(CountryType.PE.Key); if (codes.Contains(DistributorProfileModel.ProcessingCountryCode)) { var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); //Must have PEID TinCode to purchase //CR-GDO-PE-64 - Must have either PEID or PETX to purchase if (tins.Count > 0) { var requiredTins = new List <string>(new[] { "PEID", "PETX" }); var tin = (from t in tins from r in requiredTins where t.IDType.Key == r select t).ToList(); if (tin != null && tin.Count > 0) { canPurchase = true; } } } else { canPurchase = true; } return(canPurchase); }
private ShoppingCartRuleResult CheckQualifiedEventSkus(ShoppingCart_V01 shoppingCart, ShoppingCartRuleResult ruleResult) { if (shoppingCart != null) { List <string> ConfigSKUList = HLConfigManager.Configurations.DOConfiguration.SkuForCurrentEvent.Split(',').ToList(); var SKUList = GetExtravaganza2017Skus(); if (SKUList != null && ConfigSKUList != null) { SKUList.AddRange(from s in ConfigSKUList where !SKUList.Contains(s) select s); } var cart = shoppingCart as MyHLShoppingCart; if (SKUList.Any() && SKUList.Contains(cart.CurrentItems[0].SKU)) { bool memberWithTicket; var memberQualified = DistributorOrderingProfileProvider.IsEventQualified(EventId, Locale, out memberWithTicket); if (!memberQualified) { var message = "SKUNotAvailableForNonQualified"; var globalResourceObject = PlatformResources.GetGlobalResourceString("ErrorMessage", message); if (!string.IsNullOrEmpty(globalResourceObject)) { message = string.Format(globalResourceObject.ToString(), cart.CurrentItems[0].SKU); } ruleResult.AddMessage(message); ruleResult.Result = RulesResult.Failure; } } } return(ruleResult); }
public override List <DeliveryOption> GetDeliveryOptions(DeliveryOptionType type, ShippingAddress_V01 address) { if (type == DeliveryOptionType.Pickup) { var baseList = base.GetDeliveryOptions(type, address); // US 262457: Check for Prague Extravaganza pickup location var eventId = 0; if (int.TryParse(HLConfigManager.Configurations.DOConfiguration.EventId, out eventId) && eventId > 0 && baseList != null) { if (!string.IsNullOrEmpty(HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse)) { var memberWithTicket = false; var memberQualified = DistributorOrderingProfileProvider.IsEventQualified(eventId, "cs-CZ", out memberWithTicket); if (!memberQualified || !memberWithTicket) { baseList = baseList.Where(x => x.Description != HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse).ToList(); } } } return(baseList); } return(base.GetDeliveryOptions(type, address)); }
public ShoppingCartRuleResult checkForConfigBlockedSKU(ShoppingCart_V01 shoppingCart, ShoppingCartRuleResult ruleResult) { if (EventId > 0 && !DistributorOrderingProfileProvider.IsEventQualified(EventId, shoppingCart.Locale)) { var cart = shoppingCart as MyHLShoppingCart; List <string> listToHide = HLConfigManager.Configurations.DOConfiguration.SkuToNoDisplayForNonQualifyMembers.Split(',').ToList(); if (cart != null && listToHide.Contains(cart.CurrentItems[0].SKU)) { var message = "SKUNotAvailable"; var globalResourceObject = HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "SKUNotAvailable"); if (globalResourceObject != null) { message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU); } ruleResult.AddMessage(message); ruleResult.Result = RulesResult.Failure; } } return(ruleResult); }
private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult result) { if (reason == ShoppingCartRuleReason.CartCalculated) { result = CheckForInvalidSKUs(cart, result); result = CheckForDuplicateSKUs(cart, result); result = CheckForInvalidQuantities(cart, result); if (result.Result == RulesResult.Failure) { LoggerHelper.Error(string.Join("\r\n", result.Messages.ToArray())); } } //prevent to able to add products blocked by the skuToNoDisplayForNonQualifyMembers and EventId config key if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { var DSType = DistributorOrderingProfileProvider.CheckDsLevelType(cart.DistributorID, cart.Locale.Substring(3, 2)); if (DSType == ServiceProvider.DistributorSvc.Scheme.Member) { string errormessage = HttpContext.GetGlobalResourceObject("MyHL_ErrorMessage", "PMTypeRestrictOrdering").ToString(); result.AddMessage(errormessage); result.Result = RulesResult.Failure; } else { result = checkForConfigBlockedSKU(cart, result); } } return(result); }
private bool HasMemberVPLimitations() { bool hasLimitations = true; var processingCountryCode = DistributorProfileModel.ProcessingCountryCode; if (processingCountryCode == "BG") { var now = DateUtils.GetCurrentLocalTime("BG"); var tins = DistributorOrderingProfileProvider.GetTinList(DistributorProfileModel.Id, false); var bgTin = tins.Find(t => t.IDType.Key == "BGBL"); if (bgTin != null && bgTin.IDType != null && bgTin.IDType.ExpirationDate > now && string.IsNullOrEmpty(ddl_OrderType.SelectedValue)) { hasLimitations = false; } else if (bgTin != null && bgTin.IDType != null && bgTin.IDType.ExpirationDate > now && ddl_OrderType.SelectedValue != "PC") { hasLimitations = false; trRemainingVal.Visible = false; } } return(hasLimitations); }
public bool CanPurchase(string distributorID, string countryCode) { bool canPurchase = false; var codes = new List <string>(CountryType.CL.HmsCountryCodes); codes.Add(CountryType.CL.Key); if (codes.Contains(DistributorProfileModel.ProcessingCountryCode)) { var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); //HMS made up the country code //Must have CIID TinCode to purchase if (tins.Count > 0) { var tin = (from t in tins where t.IDType.Key == "CIID" select t).FirstOrDefault(); if (tin != null) { canPurchase = true; } } } else { canPurchase = true; } return(canPurchase); }
private List <MyHLShoppingCartView> GetOrdersByOrderNumber(string memberId, string locale, string orderNumber, DateTime startDate, DateTime endDate) { var shoppingCartViews = new List <MyHLShoppingCartView>(); if (!string.IsNullOrEmpty(orderNumber)) { var customerProfileId = DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID; var shoppingCartView = new MyHLShoppingCartView(); var proposedStartDate = DateTime.Now.AddMonths(-12); //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00 //DateTime endDate = DateTime.Now; shoppingCartViews = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, startDate, endDate, OrderStatusFilterType.All, "", "", false, false, orderNumber); if (shoppingCartViews.Count > 0) { return(shoppingCartViews.FindAll(oi => oi.OrderNumber == orderNumber)); } } return(shoppingCartViews); }
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(); }
private string getShippingInfoForInvoiceToFirm(MyHLShoppingCart shoppingCart) { List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(shoppingCart.DistributorID, true); TaxIdentification tid = null; if ((tid = tins.Find(t => t.IDType.Key == "MKTX")) != null && shoppingCart.InvoiceOption == InvoiceHandlingType.RecycleInvoice.ToString()) { var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("InvoiceOptions"); foreach (var entry in entries) { var key = entry.Key; if (key == shoppingCart.InvoiceOption) { var parts = key.Split('_'); if (parts.Length > 1) { key = parts[0]; } shoppingCart.InvoiceOption = InvoiceHandlingType.WithPackage.ToString(); return(" " + entry.Value); } } } return(string.Empty); }
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; } }
public override bool DistributorIsExemptFromPurchasingLimits(string distributorId) { //bool isExempt = base.DistributorIsExemptFromPurchasingLimits(distributorId); //if (!isExempt) //{ // return false; //} List <string> codes = new List <string>(CountryType.MN.HmsCountryCodes); codes.Add(CountryType.MN.Key); bool isCOPMN = codes.Contains(DistributorProfileModel.ProcessingCountryCode); if (!isCOPMN) { return(false); } bool isExempt = false; List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true); var now = DateUtils.GetCurrentLocalTime("MN"); foreach (TaxIdentification taxId in tins) { if (taxId.IDType != null && (taxId.IDType.Key == "MGTX" && taxId.IDType.ExpirationDate > now)) { isExempt = true; break; } } return(isExempt); }
public void PerformTaxationRules(Order_V01 order, string locale) { try { if (order != null) { Message message = new Message(); message.MessageType = "Perception"; order.Messages = order.Messages == null ? new MessageCollection() : order.Messages; List <TaxIdentification> tinList = DistributorOrderingProfileProvider.GetTinList(order.DistributorID, true); var CIID = (tinList.Find(t => t.IDType.Key == "CIID") != null); var CIEW = (tinList.Find(t => t.IDType.Key == "CIWE") != null); if (CIID && !CIEW) { message.MessageValue = "Perception"; order.Messages.Add(message); } } } catch (Exception ex) { LoggerHelper.Error( string.Format("CL Taxation Rules failed for Distributor {0}. Exception details \r\n{1}", order.DistributorID, ex.Message)); } }
public override bool DistributorIsExemptFromPurchasingLimits(string distributorId) { bool isExempt = base.DistributorIsExemptFromPurchasingLimits(distributorId); if (!isExempt) { return(false); } //Must have PETX TinCode to don't have volume limited //CR-GDO-PE-64 - Must have either PEID or PETX to purchase List <string> codes = new List <string>(CountryType.PE.HmsCountryCodes); codes.Add(CountryType.PE.Key); List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true); if (codes.Contains(DistributorProfileModel.ProcessingCountryCode)) { return(tins.Find(p => p.IDType.Key == "PETX") != null); } else { var required = (from t in tins from r in new List <string>(new string[] { "PEID", "PETX" }) where t.IDType.Key == r select t).ToList(); return(null != required && required.Count == 2); } }
public override bool DistributorIsExemptFromPurchasingLimits(string distributorId) { List <string> codes = new List <string>(CountryType.KZ.HmsCountryCodes); codes.Add(CountryType.KZ.Key); bool isCOPKZ = codes.Contains(DistributorProfileModel.ProcessingCountryCode); if (!isCOPKZ) { return(true); } bool isExempt = false; List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true); var now = DateUtils.GetCurrentLocalTime("KZ"); int numberTins = 0; foreach (TaxIdentification taxId in tins) { if (taxId.IDType != null && ((taxId.IDType.Key == "KZTX" || taxId.IDType.Key == "KZBL") && taxId.IDType.ExpirationDate > now)) { numberTins++; if (numberTins == 2) //DS should have both tins and active { isExempt = true; break; } } } return(isExempt); }
private bool CheckDSMailingAddress(bool check, ShippingAddress_V01 address) { if (check) { //if (address.Address.Country != this.CountryCode) //{ // this.errDRFraud.Text = GetLocalResourceObject("MailingAddNotBR") as string; // this.errDRFraud.Visible = true; // return false; //} var mailingaddress = DistributorOrderingProfileProvider.GetAddress(ServiceProvider.OrderSvc.AddressType.Mailing, DistributorID, CountryCode); if (mailingaddress != null) { if (mailingaddress.Country != CountryCode) { errDRFraud.Text = GetLocalResourceObject("MailingAddNotBR") as string; errDRFraud.Visible = true; return(false); } } } errDRFraud.Visible = false; errDRFraud.Text = string.Empty; return(true); }
public bool CanPurchase(string distributorID, string countryCode) { bool canPurchase = false; List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); //HMS made up the country code //Must have POTX TinCode to purchase foreach (TaxIdentification t in tins) { if (t.IDType.Key == "POTX") { canPurchase = true; } } if (!canPurchase) { //If they don't have the TinCode, they can only purchase if their mailing address is not in Portugal. var mailingAddress = DistributorOrderingProfileProvider.GetAddress(ServiceProvider.OrderSvc.AddressType.Mailing, distributorID, countryCode); if (null != mailingAddress) { if (!string.IsNullOrEmpty(mailingAddress.Country) && mailingAddress.Country != "PT") { canPurchase = true; } } } return(canPurchase); }
/// <summary> /// used to determine if a distributor can purshase or not. /// </summary> /// <param name="distributor">Distributor to evaluate.</param> /// <returns>True if can purshase.</returns> public bool CanPurchase(string distributorID, string countryCode) { bool canPurchase = false; var codes = new List <string>(CountryType.EC.HmsCountryCodes); codes.Add(CountryType.EC.Key); if (codes.Contains(DistributorProfileModel.ProcessingCountryCode)) { var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); //Must have ECID or ECTX TinCode to purchase if (tins.Count > 0) { var requiredTins = new List <string>(new[] { "ECID", "ECTX " }); var tin = (from t in tins from r in requiredTins where t.IDType.Key == r select t).ToList(); if (tin != null && tin.Count > 0) { canPurchase = true; } } } else { //No restriction for EC or foreign DS.(Orders without Tin code will error out and business will have to rekey these orders canPurchase = true; } return(canPurchase); }
protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartItemsAdded) { 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); } List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); if (tins != null && tins.Find(t => t.IDType.Key == "OBRT") != null) { ///Poštovani - ukoliko imate registriran OBRT, možete platisa sa vašom Business karticom ili vašom osobnom kreditnom karticom ukoliko kupnja ne prelazi 5000 HRK. U slučaju da plaćate bankovnim transferom možete platiti sa vašeg Business transakcijskog računa vezanog uz vaš Obrt ili sa vašeg osobnog računa ukoliko kupnja ne prelazi 5000 HRK Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "Croatia_SpecialMessage").ToString())); cart.RuleResults.Add(Result); } } return(base.PerformRules(cart, reason, Result)); }
public override bool DistributorIsExemptFromPurchasingLimits(string distributorId) { var tins = (from t in DistributorOrderingProfileProvider.GetTinList(distributorId, true) select t.IDType.Key); return(IndiaRestrictedPurchaseTINs.Intersect(tins).ToList().Count == 0); }
private bool CanPurchasePType(string distributorID) { bool canPurchasePType = true; var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, false, true); var now = DateUtils.GetCurrentLocalTime(COUNTRY_TIME); var idTIN = RetrieveIDTinCode(tins); bool isDummyTIN = IsDummyTin(idTIN); bool isIDCOP = IsIDCountryOfProcessing(); if (!isIDCOP) //restriction only for foreign members only { if (idTIN == null) { canPurchasePType = false; } else { if (!isDummyTIN && idTIN.IDType.ExpirationDate < now) { canPurchasePType = false; } } } return(canPurchasePType); }
/// <summary> /// this is called when cart created or when cache expires /// </summary> /// <param name="purchaseRestrictionManager"></param> /// <param name="locale"></param> /// <param name="orderMonth"></param> /// <param name="distributorId"></param> /// <param name="orderSubType"></param> public virtual void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager) { //if (manager.PurchasingLimits == null) // return; if (manager.ApplicableLimits == null) { return; } string processingCountryCode = DistributorProfileModel.ProcessingCountryCode; if ((manager.CanPurchase = CanPurchase(tins, processingCountryCode, Country)) == true) { manager.CanPurchasePType = CanPurchasePType(tins, processingCountryCode, Country); } else { manager.CanPurchasePType = false; } if (manager.CanPurchasePType == true && Settings.GetRequiredAppSetting <bool>("CheckGBNewMember", false)) { if (processingCountryCode == "GB" && Country != "GB") { DateTime currentLocalDatetime = HL.Common.Utilities.DateUtils.ConvertToLocalDateTime(DateTime.Now, Country); if (currentLocalDatetime.Subtract(DistributorOrderingProfileProvider.GetProfile(distributorId, Country).ApplicationDate).TotalDays < 7) { manager.CanPurchase = false; } } } if (processingCountryCode == "IN") { manager.ExtendRestrictionErrorMessage = new[] { "FB01", "FB02", "FB03", "FB04", "FB05", "FBL1", "FBL2", "FBL3", "FBL4", "FBL5", "FBOR" }.Intersect(from t in tins select t.IDType.Key).ToList().Count == 0; } }
public override InvoiceModel CalculateCustomerPrice(InvoiceModel invoice, string memberId, string locale, string countryCode) { if (null == invoice || string.IsNullOrEmpty(memberId)) { return(invoice); } var address = !invoice.InvoiceShipToAddress ? (invoice.MemberAddress != null && !string.IsNullOrEmpty(invoice.MemberAddress.City) && !string.IsNullOrEmpty(invoice.MemberAddress.State)) ? GetAddressFromInvoice(invoice.MemberAddress) : DistributorOrderingProfileProvider.GetAddress(AddressType.Mailing, memberId, countryCode) : GetAddressFromInvoice(invoice.Address); var warehouseCode = _invoiceShipping.GetWarehouseCode(ObjectMappingHelper.Instance.GetToShipping(address as Address_V01), locale); var shippingMethodId = string.IsNullOrEmpty(invoice.ShippingMethod) ? _invoiceShipping.GetShippingMethodId(ObjectMappingHelper.Instance.GetToShipping(address as Address_V01), locale) : invoice.ShippingMethod; CalculateDiscountedAmount(invoice); CalculateShippingAmount(invoice); foreach (var invoiceLine in invoice.InvoiceLines) { CalculateLineDiscountedAmmount(invoiceLine, invoice.InvoicePrice); CaculateFreightCharge(invoice, invoiceLine); } CalculateTaxAmount(invoice, memberId, countryCode, address, warehouseCode, shippingMethodId, locale); CalculateTotalDue(invoice); CalculateProfit(invoice); return(invoice); }
public void ProcessCartTesten_US_CheckForHFFSKU_Fail() { const string DsId = "1111111111"; const string Local = "en-US"; var testSettings = new OrderingTestSettings(Local, DsId); var target = new Ordering.Rules.CartIntegrity.en_US.CartIntegrityRules(); var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3)); HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor); var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart( DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem> { ShoppingCartItemHelper.GetCatalogItems(1, 1, "F356", Local) }, OrderCategoryType.ETO); var result = target.ProcessCart( cart, ShoppingCartRuleReason.CartWarehouseCodeChanged); if (result.Count > 0 && result[0].Messages.Count > 0) { Assert.AreEqual(result[0].Messages[0], "Invalid sku found. DS: 1111111111, CART: 0, SKU F356 : removed from cart."); } else { Assert.Fail("Distributor can not add HFF Sku F356."); } }