/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(ISalesOrder salesOrder, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) { myRate = myExchangeRate.Rate.GetValueOrDefault(1); } curDiscount.CurrentCode = salesOrder.CurrencyCode; curDiscount.ExchangeRate = exchangeRate; curMyDiscount.CurrentCode = myCurrencyCode; curMyDiscount.ExchangeRate = myRate; curSubTotal.CurrentCode = String.IsNullOrEmpty(lueCurrencyCode.LookupResultValue.ToString()) ? salesOrder.CurrencyCode : lueCurrencyCode.LookupResultValue.ToString(); curTotal.CurrentCode = curSubTotal.CurrentCode; curTotal.ExchangeRate = exchangeRate; curMyTotal.CurrentCode = myCurrencyCode; curMyTotal.ExchangeRate = myRate; curSubTotal.CurrentCode = salesOrder.CurrencyCode; curSubTotal.ExchangeRate = exchangeRate; curMySubTotal.CurrentCode = myCurrencyCode; curMySubTotal.ExchangeRate = myRate; curTax.CurrentCode = salesOrder.CurrencyCode; curTax.ExchangeRate = exchangeRate; curMyTax.CurrentCode = myCurrencyCode; curMyTax.ExchangeRate = myRate; curShipping.CurrentCode = salesOrder.CurrencyCode; curShipping.ExchangeRate = exchangeRate; curMyShipping.CurrentCode = myCurrencyCode; curMyShipping.ExchangeRate = myRate; }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(IOpportunity opportunity, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) { myRate = myExchangeRate.Rate.GetValueOrDefault(1); } string currentCode = opportunity.ExchangeRateCode; curOpenSalesPotential.CurrentCode = currentCode; curOpenSalesPotential.ExchangeRate = exchangeRate; curMyCurSalesPotential.CurrentCode = myCurrencyCode; curMyCurSalesPotential.ExchangeRate = myRate; curActualWon.CurrentCode = currentCode; curActualWon.ExchangeRate = exchangeRate; curMyCurActualWon.CurrentCode = myCurrencyCode; curMyCurActualWon.ExchangeRate = myRate; curPotentialLost.CurrentCode = currentCode; curPotentialLost.ExchangeRate = exchangeRate; curMyCurPotentialLost.CurrentCode = myCurrencyCode; curMyCurPotentialLost.ExchangeRate = myRate; curWeighted.CurrentCode = currentCode; curWeighted.ExchangeRate = exchangeRate; curMyCurWeighted.CurrentCode = myCurrencyCode; curMyCurWeighted.ExchangeRate = myRate; }
private void GetExchageRateData(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType, out string exchangeRateCode, out double exchangeRate) { string _exchangeRateCode = string.Empty; double?_exchangeRate = 0.0; if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate) { IOpportunity opp = BindingSource.Current as IOpportunity; _exchangeRateCode = opp.ExchangeRateCode; _exchangeRate = opp.ExchangeRate; } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.MyRate) { _exchangeRateCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); if (myExchangeRate != null) { _exchangeRate = myExchangeRate.Rate.GetValueOrDefault(1); } } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.BaseRate) { var optionSvc = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true); _exchangeRateCode = optionSvc.BaseCurrency; IExchangeRate er = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); _exchangeRate = er.Rate.GetValueOrDefault(1); if (_exchangeRate.Equals(0)) { _exchangeRate = 1; } } exchangeRateCode = _exchangeRateCode; exchangeRate = Convert.ToDouble(_exchangeRate); }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(IOpportunity opportunity, double exchangeRate) { var systemInfo = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true); string baseCode = ""; if (!string.IsNullOrEmpty(systemInfo.BaseCurrency)) { baseCode = systemInfo.BaseCurrency; } var currencyCode = EntityFactory.GetById <IExchangeRate>(lueCurrencyCode.LookupResultValue); string exhangeCode = currencyCode != null ? currencyCode.CurrencyCode : opportunity.ExchangeRateCode; string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); var myExchangeRate = EntityFactory.GetRepository <IExchangeRate>() .FindFirstByProperty("CurrencyCode", String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) { myRate = myExchangeRate.Rate.GetValueOrDefault(1); } curOpenBaseSalesPotential.CurrentCode = baseCode; curBaseActualWon.CurrentCode = baseCode; curBasePotentialLost.CurrentCode = baseCode; curBaseWeighted.CurrentCode = baseCode; curOpenSalesPotential.CurrentCode = exhangeCode; //curOpenSalesPotential.ExchangeRate = exchangeRate; curActualWon.CurrentCode = exhangeCode; //curActualWon.ExchangeRate = exchangeRate; curPotentialLost.CurrentCode = exhangeCode; //curPotentialLost.ExchangeRate = exchangeRate; curWeighted.CurrentCode = exhangeCode; curWeighted.ExchangeRate = exchangeRate; curMyCurSalesPotential.CurrentCode = myCurrencyCode; curMyCurSalesPotential.ExchangeRate = myRate; curMyCurActualWon.CurrentCode = myCurrencyCode; curMyCurActualWon.ExchangeRate = myRate; curMyCurPotentialLost.CurrentCode = myCurrencyCode; curMyCurPotentialLost.ExchangeRate = myRate; curMyCurWeighted.CurrentCode = myCurrencyCode; curMyCurWeighted.ExchangeRate = myRate; opportunity.DocSalesPotential = (opportunity.SalesPotential ?? 0) * exchangeRate; }