public void AddToPriceGroup(int priceGroupId, IList <PriceBase> priceBaseToAdd) { PriceGroup priceGroup = GetById(priceGroupId); List <CurrencyRateView> currencyRateViews = ControllerManager.CurrencyRate.GetAllRates() as List <CurrencyRateView>; this.BeginTransaction(); foreach (PriceBase priceBase in priceBaseToAdd) { PriceAttribute priceAttribute = new PriceAttribute(); priceAttribute.PriceGroup = priceGroup; priceAttribute.PriceBase = priceBase; CurrencyRateView cr = currencyRateViews.Find(delegate(CurrencyRateView record) { if (record.FromCurrency == priceBase.PriceListCurrency && record.ToCurrency == priceGroup.Currency) { return(true); } return(false); }); priceAttribute.Price = priceBase.PriceList * cr.Rate; priceAttribute.PriceCurrency = priceGroup.Currency; priceAttribute.CurrencyRate = cr.ToCurrencyRate; priceAttribute.PricePurchaseCurrencyRate = priceBase.PricePurchaseCurrencyRate; priceAttribute.PriceSuggestCurrencyRate = priceBase.PriceSuggestCurrencyRate; NHibernateSession.Save(priceAttribute); } CommitChanges(); }
public bool RollBack(PriceAttributeHistory pah) { pah = GetById(pah.ID); PriceAttribute pa = ControllerManager.PriceAttribute.GetPriceAttribute(pah.PriceGroup, pah.PriceBase); if (pa == null) { return(false); } pa.Price = pah.Price; pa.PriceCurrency = pah.PriceCurrency; pa.CurrencyRate = pah.CurrencyRate; ControllerManager.PriceAttribute.Save(pa); CommitChanges(); return(true); }
private bool AddItem(Quote q, PriceBase priceBase, string observation) { bool added = true; List <QuoteItem> tmplst = new List <QuoteItem>(q.QuoteItems); if (tmplst.Exists(delegate(QuoteItem record) { if (record.PriceBase.ID == priceBase.ID) { return(true); } return(false); })) { return(true); } QuoteItem qi = new QuoteItem(); qi.Observation = observation; qi.Quote = q; PublishItem pi = ControllerManager.PublishList.GetPublishItem(q.Distributor, priceBase); PriceAttribute pa = null; if (pi != null) { // Lista de Precio (Publicada) qi.PriceBase = priceBase; qi.Price = pi.Price; qi.PriceCurrency = pi.PriceCurrency; qi.CurrencyRate = pi.CurrencyRate; qi.Source = pi.PublishList.PriceList.Name; } else { if (q.Distributor.PriceList != null) { pa = ControllerManager.PriceAttribute.GetPriceAttribute(q.Distributor.PriceList.PriceGroup, priceBase); if (pa != null) { // Pais qi.PriceBase = priceBase; qi.Price = pa.Price; qi.PriceCurrency = pa.PriceCurrency; qi.CurrencyRate = pa.CurrencyRate; qi.Source = Resource.Business.GetString("Country"); } } if (pa == null) { // Base decimal?factor = null; if (q.Distributor.PriceList != null) { if (q.Distributor.PriceList.PriceGroup.Adjust != null) { factor = q.Distributor.PriceList.PriceGroup.Adjust; } } if (factor == null || factor == 0) { factor = 1; } qi.PriceBase = priceBase; qi.Price = priceBase.PriceList / Convert.ToDecimal(factor); qi.PriceCurrency = priceBase.PriceListCurrency; qi.CurrencyRate = priceBase.CurrencyRate; if (priceBase.Status == PriceBaseStatus.Verified) { qi.Source = Resource.Business.GetString("Base"); } else if (priceBase.Status == PriceBaseStatus.NotVerified) { qi.Source = Resource.Business.GetString("OutOfList"); } } } if (qi.Price > 0) { q.QuoteItems.Add(qi); } else { added = false; } return(added); }
public static KeyValuePair <string, List <ProductValue> > CreateValue(this PriceAttribute attribute, IEnumerable <PriceProductValue> data, string locale = null, string scope = null) { return(attribute.CreateValue((object)data, locale, scope)); }
public static KeyValuePair <string, List <ProductValue> > CreateValue(this PriceAttribute attribute, PriceProductValue data, string locale = null, string scope = null) { return(attribute.CreateValue(new List <PriceProductValue> { data }, locale, scope)); }
public static KeyValuePair <string, List <ProductValue> > CreateValue(this PriceAttribute attribute, float amount, string currency, string locale = null, string scope = null) { return(attribute.CreateValue(new PriceProductValue { Amount = amount, Currency = currency }, locale, scope)); }
private bool ValidateQuoteItem(Quote q, PriceBase priceBase, QuoteItem qi, out decimal pL, out Currency plCurrency) { plCurrency = null; pL = 0; PublishItem pi = ControllerManager.PublishList.GetPublishItem(q.Distributor, priceBase); PriceAttribute pa = null; if (pi != null) { // Lista de Precio (Publicada) qi.PriceBase = priceBase; pL = pi.Price; plCurrency = pi.PriceCurrency; qi.Source = pi.PublishList.PriceList.Name; } else { if (q.Distributor.PriceList != null) { pa = ControllerManager.PriceAttribute.GetPriceAttribute(q.Distributor.PriceList.PriceGroup, priceBase); if (pa != null) { // Pais qi.PriceBase = priceBase; pL = pa.Price; plCurrency = pa.PriceCurrency; qi.Source = Resource.Business.GetString("Country"); } } if (pa == null) { // Base o Fuera de Lista decimal?factor = null; if (q.Distributor.PriceList != null) { if (q.Distributor.PriceList.PriceGroup.Adjust != null) { factor = q.Distributor.PriceList.PriceGroup.Adjust; } } if (factor == null || factor == 0) { factor = 1; } qi.PriceBase = priceBase; pL = priceBase.PriceList / Convert.ToDecimal(factor); plCurrency = priceBase.PriceListCurrency; if (priceBase.Status == PriceBaseStatus.Verified) { qi.Source = Resource.Business.GetString("Base"); } else if (priceBase.Status == PriceBaseStatus.NotVerified) { qi.Source = Resource.Business.GetString("OutOfList"); } } } decimal lastPrice = qi.Price; if (plCurrency != null) { qi.Price = Math.Round(pL * lstRates[plCurrency.ID - 1, q.Currency.ID - 1].Rate, 3); qi.PriceCurrency = q.Currency; qi.CurrencyRate = ControllerManager.CurrencyRate.GetLast(q.Currency); } return(lastPrice == qi.Price); }