private void CheckForPricesBelowZero(UserSpecificPrice price) { decimal final = price.PriceWithAdjustments(); if (final < 0) { decimal tweak = -1 * final; price.AddAdjustment(tweak, "Price can not be below zero"); } }
private void AdjustProductPriceForUser(UserSpecificPrice price, Catalog.Product p, Membership.CustomerAccount currentUser) { if (currentUser == null) return; if (currentUser.Bvin == string.Empty) return; if (currentUser.PricingGroupId == string.Empty) return; if (p == null) return; if (price == null) return; decimal startingPrice = price.PriceWithAdjustments(); Contacts.PriceGroup pricingGroup = ContactServices.PriceGroups.Find(currentUser.PricingGroupId); if (pricingGroup == null) return; decimal nonGroupPrice = price.BasePrice; decimal groupPrice = nonGroupPrice; groupPrice = pricingGroup.GetAdjustedPriceForThisGroup(p.SitePrice, p.ListPrice, p.SiteCost); decimal amountOfDiscount = groupPrice - nonGroupPrice; price.AddAdjustment(amountOfDiscount, "Price Group"); }
private void ApplySales(UserSpecificPrice price, Catalog.Product p, Membership.CustomerAccount currentUser, List<Marketing.Promotion> sales) { if (sales == null) return; foreach (Marketing.Promotion promo in sales) { promo.ApplyToProduct(this, p, price, currentUser, DateTime.UtcNow); } }
public UserSpecificPrice PriceProduct(Catalog.Product p, Membership.CustomerAccount currentUser, OptionSelectionList selections, List<Marketing.Promotion> currentSales) { var profiler = MiniProfiler.Current; if (p == null) return null; UserSpecificPrice result = new UserSpecificPrice(p, selections); using (profiler.Step("Adjust Price for User")) { AdjustProductPriceForUser(result, p, currentUser); } using (profiler.Step("Apply Sales")) { ApplySales(result, p, currentUser, currentSales); } using (profiler.Step("Check for < 0 prices")) { CheckForPricesBelowZero(result); } return result; }
public UserSpecificPrice PriceProduct(Catalog.Product p, Membership.CustomerAccount currentUser, OptionSelectionList selections) { if (p == null) return null; UserSpecificPrice result = new UserSpecificPrice(p, selections); AdjustProductPriceForUser(result, p, currentUser); ApplySales(result, p, currentUser); CheckForPricesBelowZero(result); return result; }
private void ApplySales(UserSpecificPrice price, Catalog.Product p, Membership.CustomerAccount currentUser) { List<Marketing.Promotion> sales = MarketingServices.Promotions.FindAllPotentiallyActiveSales(DateTime.UtcNow); foreach (Marketing.Promotion promo in sales) { promo.ApplyToProduct(this, p, price, currentUser, DateTime.UtcNow); } }