private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { //45479, SG:Foreign ds with SNID and foreign DS with dummy tinid are both able to add more than 12 p type products to cart. if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); TaxIdentification tid = null; if (tins != null && (tid = tins.Find(t => t.IDType.Key == "SNID")) != null) // have national ID { if (tid.ID == "S0000000S" || !DistributorProfileModel.ProcessingCountryCode.Equals(CountryType.SG.Key)) // dummy TIN and foreign DS { if (getPTypeSKUCount(cart.CartItems, cart.CurrentItems[0]) > ForeingDSLines) { Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "AnySKUQuantityExceeds") .ToString(), ForeingDSLines.ToString())); cart.RuleResults.Add(Result); return(Result); } } } } return(Result); }
private MessageCollection addTinMessage(MessageCollection messageCollection, TaxIdentification id) { Message message = new Message(); message.MessageType = "TinCode"; message.MessageValue = id.IDType.Key; messageCollection.Add(message); return(messageCollection); }
private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); try { List <string> codes = new List <string>(CountryType.TH.HmsCountryCodes); codes.Add(CountryType.TH.Key); bool isCOPThai = codes.Contains(DistributorProfileModel.ProcessingCountryCode); TaxIdentification tid = null; var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); tid = tins.Find(t => t.IDType.Key == "THID"); //Simulate the dummy tin with an foreign DS //TaxIdentification ti = new TaxIdentification() { CountryCode = "TH", ID = "dummy", IDType = new TaxIdentificationType(dummyTin) }; //ods.Value.TinList.Add(ti); if (CanPurchase(cart.DistributorID, Country)) { //Additional Check to allow DS COP = Thai Tin = No TIN, Can place only L and A items if (IsWithOutTinCode) { if (currentItem.ProductType == ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString()); cart.RuleResults.Add(Result); } } } else { if (IsWithOutTinCode) { if (currentItem.ProductType == ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString()); cart.RuleResults.Add(Result); } } } } catch (Exception ex) { LoggerHelper.Error(string.Format("Error while performing Add to Cart Rule for Singapore distributor: {0}, Cart Id:{1}, \r\n{2}", cart.DistributorID, cart.ShoppingCartID, ex.ToString())); } } return(Result); }
public void PerformTaxationRules(Order_V01 order, string locale) { try { Message message = new Message(); message.MessageType = "OrderType"; message.MessageValue = "RSO"; Message messageBoleta = new Message(); messageBoleta.MessageType = "TypePerceptions"; messageBoleta.MessageValue = "Boleta"; if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType)) { var sessionInfo = SessionInfo.GetSessionInfo(order.DistributorID, locale); if (null != sessionInfo) { message.MessageValue = sessionInfo.IsEventTicketMode ? "ETO" : "RSO"; } if ("RSO" == message.MessageValue) { List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(order.DistributorID, true); TaxIdentification tid = null; var isPeid = (tid = tins.Find(t => t.IDType.Key == "PEID")) != null; var isPetx = (tid = tins.Find(t => t.IDType.Key == "PETX")) != null; if ((isPEDs && isPetx && isPeid) || (isPEDs && isPetx)) { messageBoleta.MessageValue = "Factura"; } } } if (order.Messages == null) { order.Messages = new MessageCollection(); } order.Messages.Add(message); bool enable = Settings.GetRequiredAppSetting <bool>("PEperceptionsEnable", true); if (enable) { order.Messages.Add(messageBoleta); } } catch (Exception ex) { LoggerHelper.Error( string.Format("PE Taxation Rules failed for Distributor {0}. Exception details \r\n{1}", order.DistributorID, ex.Message)); } }
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); }
public void PerformTaxationRules(Order_V01 order, string locale) { try { List <TaxIdentification> tinList = DistributorOrderingProfileProvider.GetTinList(order.DistributorID, true); order.Messages = new MessageCollection(); TaxIdentification id = null; if (tinList == null || (tinList != null && (id = tinList.Find(t => t.IDType.Key.Equals("HRBL"))) != null) || (tinList != null && (id = tinList.Find(t => t.IDType.Key.Equals("HRRP"))) != null)) { order.Messages = addTinMessage(order.Messages, id); } } catch (Exception ex) { LoggerHelper.Error( string.Format("HR Taxation Rules failed for Distributor {0}. Exception details \r\n{1}", order.DistributorID, ex.Message)); } }
public override bool DistributorIsExemptFromPurchasingLimits(string distributorId) { bool isExempt = true; List <string> codes = new List <string>(CountryType.SG.HmsCountryCodes); codes.Add(CountryType.SG.Key); //if (codes.Contains(ods.Value.ProcessingCountry.Key)) //{ var tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true); TaxIdentification tid = null; if ((tid = tins.Find(t => t.IDType.Key == "SNID")) != null) { if (tid.ID == "S0000000S") { isExempt = false; } } //} return(isExempt); }
public bool CanPurchase(string distributorID, string countryCode) { bool canPurchase = false; List <string> codes = new List <string>(CountryType.TH.HmsCountryCodes); codes.Add(CountryType.TH.Key); bool isCOPThai = codes.Contains(DistributorProfileModel.ProcessingCountryCode); var tins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); TaxIdentification tid = null; tid = tins == null ? null : tins.Find(t => t.IDType.Key == "THID"); IsWithOutTinCode = tid == null; //COP = Thai, Tin = THID – Can place any item without any limit. if (isCOPThai && !IsWithOutTinCode) { canPurchase = true; } //Foreign DS else { //with Thai Tin Code, Can place all items without any limitation. //COP Not Thai, Tin =Dummy tin Code – Can place any item (P,L, A and Volume limitation is set 1050 VP per order.) if (tins != null && tins.Find(t => t.ID == dummyTin) != null) //have dummyTIN { IsWithOutTinCode = false; canPurchase = true; } else if (!IsWithOutTinCode && codes.Contains(tid.ID)) { canPurchase = true; } } return(canPurchase); }
private bool IsDummyTin(TaxIdentification tin) { return((tin != null && tin.ID == DUMMY_TIN_CODE) ? true : false); }
/// <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) { if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { if (cart.CurrentItems == null || cart.CurrentItems.Count == 0) { Result.Result = RulesResult.Failure; return(Result); } CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); List <string> codes = new List <string>(CountryType.TH.HmsCountryCodes); decimal NewVolumePoints = 0m; decimal cartVolume = 0m; TaxIdentification tid = null; string dummyTin = "TH00000000000"; bool isCOPThai = codes.Contains(DistributorProfileModel.ProcessingCountryCode); var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); isDummyTin = tins.Find(t => t.ID == dummyTin) != null; codes.Add(CountryType.TH.Key); tid = tins.Find(t => t.IDType.Key == "THID"); //COP = Thai Tin = No TIN, Can place only L and A items //COP Not Thai, No Tin- Can place L & A item if ((isCOPThai && tid == null) || (!isCOPThai && tid == null && !isDummyTin)) { if (currentItem.ProductType == ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase") as string); cart.RuleResults.Add(Result); } } // marketing plan if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(cart.DistributorID)) { return(base.PerformRules(cart, reason, Result)); } if (isCOPThai) //COP Thai { if (isDummyTin) //have dummyTIN { 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.ToString())); Result.Result = RulesResult.Failure; cart.RuleResults.Add(Result); } } } else { //COP Not Thai, Tin =Dummy tin Code – Can place any item (P,L, A and Volume limitation is set 1050 VP per order.) if (isDummyTin)//have dummyTIN { 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.ToString())); Result.Result = RulesResult.Failure; cart.RuleResults.Add(Result); } } } } return(Result); }