Inheritance: System.Web.UI.Page
示例#1
0
文件: Currency.cs 项目: heber/FreeOQ
		static Currency()
		{
			Currency.Converter = new CurrencyConverter();
			Currency.ARS = new Currency("ARS", "Argentine peso");
			Currency.ATS = new Currency("ATS", "Austrian Schilling");
			Currency.AUD = new Currency("AUD", "Australian dollar");
			Currency.BEF = new Currency("BEF", "Belgian Francs");
			Currency.BRL = new Currency("BRL", "Brazilian real");
			Currency.CAD = new Currency("CAD", "Canadian dollar");
			Currency.CHF = new Currency("CHF", "Swiss franc");
			Currency.DEM = new Currency("DEM", "German Mark");
			Currency.ESP = new Currency("ESP", "Spanish Peseta");
			Currency.EUR = new Currency("EUR", "EU euro");
			Currency.FRF = new Currency("FRF", "French Franc");
			Currency.GBP = new Currency("GBP", "British pound");
			Currency.HKD = new Currency("HKD", "Hong Kong SAR dollar");
			Currency.INR = new Currency("INR", "Indian rupee");
			Currency.ITL = new Currency("ITL", "Italian Lira");
			Currency.JPY = new Currency("JPY", "Japanese yen");
			Currency.KRW = new Currency("KRW", "South Korean won");
			Currency.NLG = new Currency("NLG", "Dutch Guilder");
			Currency.PTE = new Currency("PTE", "Portuguese Escudo");
			Currency.RUR = new Currency("RUR", "Russian Ruble");
			Currency.SGD = new Currency("SGD", "Singapore dollar");
			Currency.USD = new Currency("USD", "US dollar");
			Currency.XBA = new Currency("XBA", "European Composite Unit");
			Currency.XEU = new Currency("XEU", "European Currency Unit");
			Currency.PLN = new Currency("PLN", "Polish zloty");
			Currency.NOK = new Currency("NOK", "Norwegian krone");
			Currency.DKK = new Currency("DKK", "Danish krone");
			Currency.SEK = new Currency("SEK", "Swedish krona");
			Currency.CNY = new Currency("CNY", "Chinese yuan renminbi");
		}
示例#2
0
        public void CreateCountries()
        {
            PrepareRepositories(false);

            Currency lebCurrency = new Currency() { Id = "LEB", Symbol = "LB", Name = "Lebanese Pound", Rate = 1500 };
            _context.Currencies.Add(lebCurrency);
            Currency saCurrency = new Currency() { Id = "SAR", Symbol = "SR", Name = "Saudi Ryal", Rate = 3.67 };
            _context.Currencies.Add(saCurrency);
            Currency egCurrency = new Currency() { Id = "EGY", Symbol = "EG", Name = "Egyptian Jeneh", Rate = 7 };
            _context.Currencies.Add(egCurrency);

            Country country = new Country();
            country.Id = "LEB";
            country.Name = "Lebanon";
            country.Currency = lebCurrency;
            _context.Countries.Add(country);

            country = new Country();
            country.Id = "SAR";
            country.Name = "Saudi Arabia";
            country.Currency = saCurrency;
            _context.Countries.Add(country);

            country = new Country();
            country.Id = "EGY";
            country.Name = "Egypt";
            country.Currency = egCurrency;
            _context.Countries.Add(country);

            _context.SaveChanges();

            Console.WriteLine("");
            _context.Dispose();
        }
        public static Store GetTestStore()
        {
            var currency = new Currency
            {
                Name = "US Dollar",
                CurrencyCode = "USD",
                Rate = 1.1M,
                DisplayLocale = "en-US",
                CustomFormatting = "CustomFormatting 1",
                LimitedToStores = true,
                Published = true,
                DisplayOrder = 2,
                CreatedOnUtc = new DateTime(2010, 01, 01),
                UpdatedOnUtc = new DateTime(2010, 01, 02),
            };

            var store = new Store
            {
                Name = "Computer store",
                Url = "http://www.yourStore.com",
                Hosts = "yourStore.com,www.yourStore.com",
                LogoPictureId = 0,
                DisplayOrder = 1,
                PrimaryStoreCurrency = currency,
                PrimaryExchangeRateCurrency = currency
            };

            return store;
        }
 public void ReEntry(Currency currencyForPosition, Currency baseCurrency, DateTime dateTime)
 {
     Status = PositionRuntimeStatus.Active;
     // create a new trade record
     _currentPositionRecord = new PositionRecord(dateTime, currencyForPosition, baseCurrency, PositionType, this);
     PositionRecords.Add(_currentPositionRecord);
 }
示例#5
0
 public LevelInfo(Dictionary<PlantType, int> target, Currency startingFunds, PlantType[] disabled)
 {
     this.target = target;
     this.startingFunds = startingFunds;
     isComplete = false;
     this.disabled = new List<PlantType>(disabled);
 }
 public SettlementTerms(XmlNode xmlNode)
 {
     XmlNode settlementCurrencyNode = xmlNode.SelectSingleNode("settlementCurrency");
     
     if (settlementCurrencyNode != null)
     {
         if (settlementCurrencyNode.Attributes["href"] != null || settlementCurrencyNode.Attributes["id"] != null) 
         {
             if (settlementCurrencyNode.Attributes["id"] != null) 
             {
                 settlementCurrencyIDRef_ = settlementCurrencyNode.Attributes["id"].Value;
                 Currency ob = new Currency(settlementCurrencyNode);
                 IDManager.SetID(settlementCurrencyIDRef_, ob);
             }
             else if (settlementCurrencyNode.Attributes["href"] != null)
             {
                 settlementCurrencyIDRef_ = settlementCurrencyNode.Attributes["href"].Value;
             }
             else
             {
                 settlementCurrency_ = new Currency(settlementCurrencyNode);
             }
         }
         else
         {
             settlementCurrency_ = new Currency(settlementCurrencyNode);
         }
     }
     
 
 }
 public PositiveAmountSchedule(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNode currencyNode = xmlNode.SelectSingleNode("currency");
     
     if (currencyNode != null)
     {
         if (currencyNode.Attributes["href"] != null || currencyNode.Attributes["id"] != null) 
         {
             if (currencyNode.Attributes["id"] != null) 
             {
                 currencyIDRef_ = currencyNode.Attributes["id"].Value;
                 Currency ob = new Currency(currencyNode);
                 IDManager.SetID(currencyIDRef_, ob);
             }
             else if (currencyNode.Attributes["href"] != null)
             {
                 currencyIDRef_ = currencyNode.Attributes["href"].Value;
             }
             else
             {
                 currency_ = new Currency(currencyNode);
             }
         }
         else
         {
             currency_ = new Currency(currencyNode);
         }
     }
     
 
 }
        protected void GetCurrency_Click(object sender, EventArgs e)
        {
            DataAccess db = new DataAccess();

            cb.DailyInfoSoapClient client = new cb.DailyInfoSoapClient();

            DataTableReader reader = client.GetCursOnDate(DateTime.Now).CreateDataReader();

            while (reader.Read())
            {
                var code = reader[4].ToString();
                if (code == "EUR" || code == "USD" || code == "CNY")
                {
                    Currency currency = new Currency();

                    currency.Name = reader[0].ToString();
                    currency.Curs = reader[2].ToString();
                    currency.chCode = reader[4].ToString();
                    currency.updated_at = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now).AddHours(4.0);

                    if (list.Count < 3)
                    {
                        db.Insert(currency);
                    }
                    else
                    {
                        db.Update(currency);
                    }

                }
            }
        }
 public AmountSchedule(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNodeList currencyNodeList = xmlNode.SelectNodes("currency");
     if (currencyNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in currencyNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 currencyIDRef = item.Attributes["id"].Name;
                 Currency ob = Currency();
                 IDManager.SetID(currencyIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 currencyIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 currency = new Currency(item);
             }
         }
     }
     
 
 }
示例#10
0
 public static PaymentGroup Create (Organization organization, DateTime timestamp, Currency currency, Person createdByPerson)
 {
     return
         FromIdentity(SwarmDb.GetDatabaseForWriting().CreatePaymentGroup(organization.Identity, timestamp,
                                                                currency.Identity,
                                                                System.DateTime.Now, createdByPerson.Identity));
 }
示例#11
0
 /// <summary>
 /// the rate r  is given with the convention that a
 /// unit of the source is worth r units of the target.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="rate"></param>
 public ExchangeRate(Currency source, Currency target, double rate)
 {
     source_ = source;
      target_ = target;
      rate_ = rate;
      type_ = Type.Direct;
 }
 /// <summary>
 /// Represents a money.
 /// </summary>
 /// <param name="value">Value for the money.</param>
 public MoneyForExercise2(decimal value, Currency currency)
 {
     this.value = value;
     this.MinValue = 6;
     //
     this.currency = currency;
 }
示例#13
0
 public void Can_formatPrice_with_distinct_currencyDisplayLocale()
 {
     var usd_currency = new Currency()
     {
         Id = 1,
         Name = "US Dollar",
         CurrencyCode = "USD",
         DisplayLocale = "en-US",
     };
     var rub_currency = new Currency()
     {
         Id = 2,
         Name = "Russian Ruble",
         CurrencyCode = "RUB",
         DisplayLocale = "ru-RU",
     };
     var language = new Language()
     {
         Id = 1,
         Name = "English",
         LanguageCulture = "en-US"
     };
     _priceFormatter.FormatPrice(1234.5M, false, usd_currency, language, false, false).ShouldEqual("$1,234.50");
     _priceFormatter.FormatPrice(1234.5M, false, rub_currency, language, false, false).ShouldEqual("1 234,50р.");
 }
示例#14
0
 public CurrencyRate(Currency left, Currency right, decimal rate, int leftCount = 1)
 {
     Left = left;
     Right = right;
     Rate = rate;
     LeftCount = leftCount;
 }
示例#15
0
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     NavigationService ns;
     ns = NavigationService.GetNavigationService(this);
     Currency nextPage = new Currency();
     ns.Navigate(nextPage);
 }
示例#16
0
		public async Task<Currency> GetRates()
		{
			try
			{
				var httpClient = new HttpClient();
				HttpResponseMessage response = await httpClient.GetAsync(ClientUrl);
				if (response.IsSuccessStatusCode)
				{
					var res = await response.Content.ReadAsStringAsync();
					var openExchangeData = JsonConvert.DeserializeObject<OpenExchangeModel>(res);

					var currency = new Currency();
					currency.BaseCurrency = openExchangeData.Base;
					foreach (var key in openExchangeData.Rates.Keys)
					{
						currency.Currencys.Add(new CurrencyRate
						{
							Id = key,
							Rate = openExchangeData.Rates[key]
						});
					}

					return currency;

				}
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex.ToString());
			}
			return null;
		}
示例#17
0
        /// <summary>
        /// Gets currency string
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="showCurrency">A value indicating whether to show a currency</param>
        /// <param name="targetCurrency">Target currency</param>
        /// <returns>Currency string without exchange rate</returns>
        protected virtual string GetCurrencyString(decimal amount,
            bool showCurrency, Currency targetCurrency)
        {
            if (targetCurrency == null)
                throw new ArgumentNullException("targetCurrency");

            string result;
            if (!String.IsNullOrEmpty(targetCurrency.CustomFormatting))
            {
                //custom formatting specified by a store owner
                result = amount.ToString(targetCurrency.CustomFormatting);
            }
            else
            {
                if (!String.IsNullOrEmpty(targetCurrency.DisplayLocale))
                {
                    //default behavior
                    result = amount.ToString("C", new CultureInfo(targetCurrency.DisplayLocale));
                }
                else
                {
                    //not possible because "DisplayLocale" should be always specified
                    //but anyway let's just handle this behavior
                    result = String.Format("{0} ({1})", amount.ToString("N"), targetCurrency.CurrencyCode);
                    return result;
                }
            }

            //display currency code?
            if (showCurrency && _currencySettings.DisplayCurrencyLabel)
                result = String.Format("{0} ({1})", result, targetCurrency.CurrencyCode);
            return result;
        }
示例#18
0
        public static Boolean CreateCurrency(Currency cuurency)
        {
            Boolean flag = false;
            if (!(IsExistingCurrency(cuurency)))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (var context = new SycousCon())
                    {
                        try
                        {
                            context.Currencies.AddObject(cuurency);
                            context.SaveChanges();
                            scope.Complete();
                            context.AcceptAllChanges();
                            flag = true;
                        }
                        catch (Exception ex)
                        {
                            context.Dispose();
                            throw;
                        }
                    }//
                }// using
            }//if

            return flag;
        }
        public void Can_save_and_load_currency()
        {
            var currency = new Currency
            {
                Name = "US Dollar",
                CurrencyCode = "USD",
                Rate = 1.1M,
                DisplayLocale = "en-US",
                CustomFormatting = "CustomFormatting 1",
                Published = true,
                DisplayOrder = 2,
                CreatedOnUtc = new DateTime(2010, 01, 01),
                UpdatedOnUtc = new DateTime(2010, 01, 02),
            };

            var fromDb = SaveAndLoadEntity(currency);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("US Dollar");
            fromDb.CurrencyCode.ShouldEqual("USD");
            fromDb.Rate.ShouldEqual(1.1M);
            fromDb.DisplayLocale.ShouldEqual("en-US");
            fromDb.CustomFormatting.ShouldEqual("CustomFormatting 1");
            fromDb.Published.ShouldEqual(true);
            fromDb.DisplayOrder.ShouldEqual(2);
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
            fromDb.UpdatedOnUtc.ShouldEqual(new DateTime(2010, 01, 02));
        }
示例#20
0
 public RateComparison(Currency currency, decimal percent, decimal difference, RateComparasionType rateComparasionType)
 {
     Currency = currency;
     Percent = percent;
     Difference = difference;
     RateComparasionType = rateComparasionType;
 }
示例#21
0
        /// <summary>
        /// Gets currency string
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="showCurrency">A value indicating whether to show a currency</param>
        /// <param name="targetCurrency">Target currency</param>
        /// <returns>Currency string without exchange rate</returns>
        protected virtual string GetCurrencyString(decimal amount,
            bool showCurrency, Currency targetCurrency)
        {
            if (targetCurrency == null)
                throw new ArgumentNullException("targetCurrency");

            string result = "";
            if (!String.IsNullOrEmpty(targetCurrency.CustomFormatting))
            {
                result = amount.ToString(targetCurrency.CustomFormatting);
            }
            else
            {
                if (!String.IsNullOrEmpty(targetCurrency.DisplayLocale))
                {
                    result = amount.ToString("C", new CultureInfo(targetCurrency.DisplayLocale));
                }
                else
                {
                    result = String.Format("{0} ({1})", amount.ToString("N"), targetCurrency.CurrencyCode);
                    return result;
                }
            }

            if (showCurrency && _currencySettings.DisplayCurrencyLabel)
                result = String.Format("{0} ({1})", result, targetCurrency.CurrencyCode);
            return result;
        }
		public Money(string currencyCode, decimal amount) {
            _currency = new Currency();
            if (currencyCode != null) {//sometimes a null currencyCode is passed. This might be a bug somewhere
                _currency.CurrencyCode = currencyCode;
            }
			Amount = amount;
		}
示例#23
0
        public static double[] GetExchangeRates(Currency transactionCurrency, Currency pivotCurrency, Currency globalPivotCurrency)
        {
            double[] rates = new double[2];

            if (transactionCurrency.Id == pivotCurrency.Id)
                rates[0] = 1.00;
            else
            {
                if (transactionCurrency.Rate != 0)
                    rates[0] = pivotCurrency.Rate * transactionCurrency.Rate;
                else
                    rates[0] = 0;
            }

            if (transactionCurrency.Id == globalPivotCurrency.Id)
                rates[1] = 1.00;
            else
            {
                if (transactionCurrency.Rate != 0)
                    rates[1] = globalPivotCurrency.Rate * transactionCurrency.Rate;
                else
                    rates[1] = 0;
            }

            return rates;
        }
示例#24
0
        static void Main()
        {
            try
             {
            Currency balance = new Currency(50,35);
            Console.WriteLine(balance);
            Console.WriteLine("balance is " + balance);
            Console.WriteLine("balance is (using ToString()) " + balance.ToString());

            float balance2= balance;
            Console.WriteLine("After converting to float, = " + balance2);
            balance = (Currency) balance2;
            Console.WriteLine("After converting back to Currency, = " + balance);

            Console.WriteLine(
               "Now attempt to convert out of range value of -$100.00 to a Currency:");
            checked
            {
               balance = (Currency) (-50.5);
               Console.WriteLine("Result is " + balance.ToString());
            }
             }
             catch(Exception e)
             {
            Console.WriteLine("Exception occurred: " + e.Message);
             }
        }
示例#25
0
        public static decimal ConvertTo(decimal fromAmount, CurrencyType fromCurrencyType, CurrencyType toCurrencyType, Currency[] currencies)
        {
            if (fromCurrencyType == toCurrencyType)
                return fromAmount;

            if ((fromCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != fromCurrencyType)) ||
                toCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != toCurrencyType))
            {
                throw new Exception(String.Format(ValidationResource.Currency_CannotProccessCurrencyChange_ErrorMessage, fromCurrencyType, toCurrencyType));
            }

            decimal amountTo = fromAmount;
            Currency currency;

            // Převod konta na CZK
            if (fromCurrencyType != CurrencyType.CZK)
            {
                currency = currencies.Single(c => c.CurrencyType == fromCurrencyType);
                amountTo = amountTo * currency.ExchangeRateToCZK;
            }

            // Převod konta na aktuální měnu
            if (toCurrencyType != CurrencyType.CZK)
            {
                currency = currencies.Single(c => c.CurrencyType == toCurrencyType);
                amountTo = amountTo / currency.ExchangeRateToCZK;
            }

            return amountTo;
        }
示例#26
0
        public async Task<CartBuilder> GetOrCreateNewTransientCartAsync(Store store, Customer customer, Language language, Currency currency)
        {
            _store = store;
            _customer = customer;
            _currency = currency;
            _language = language;
            _cartCacheKey = GetCartCacheKey(store.Id, customer.Id);

            _cart = await _cacheManager.GetAsync(_cartCacheKey, _cartCacheRegion, async () =>
            {
                ShoppingCart retVal;

                var cartSearchResult = await _cartApi.CartModuleGetCurrentCartAsync(_store.Id, _customer.Id);
                if (cartSearchResult == null)
                {
                    retVal = CreateNewTransientCart();
                }
                else
                {
                    var detalizedCart = await _cartApi.CartModuleGetCartByIdAsync(cartSearchResult.Id);
                    retVal = detalizedCart.ToWebModel(_currency, _language);
                }

                return retVal;
            });

            await EvaluatePromotionsAsync();

            return this;
        }
示例#27
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string redirectPage = null;
            try
            {
                Currency info = new Currency();

                info.UnitAr = txtUnitAr.Text.Trim();
                info.UnitEn = txtUnitEn.Text.Trim();

                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    info.ID = Convert.ToInt32(Request.QueryString[CommonStrings.ID]);

                    if (currencysOperator.Update(info))
                        redirectPage = Utility.AppendQueryString(PagesPathes.ConfirmUpdate, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
                }
                else
                {
                    if (currencysOperator.Add(info))
                        redirectPage = Utility.AppendQueryString(PagesPathes.ConfirmInsert, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
                }
            }
            catch
            {
                redirectPage = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
            }
            finally
            {
                Response.Redirect(redirectPage);
            }
        }
    }
示例#28
0
        public bool CreateRecord(Object Currency)
        {
            Boolean flag = false;
            CurrencyMaster currency = (CurrencyMaster)Currency;
            try
            {
                Currency _currency = new Currency();

                if (currency.CurrencyName != null)
                {
                    _currency.Name = currency.CurrencyName.ToUpper().Trim();
                }
                if (currency.Symbol != null)
                {
                    _currency.Symbol = currency.Symbol;
                }
                _currency.CreateBy = currency.CreateBy;
                _currency.CreateDate = DateTime.Now;

                if (_currency.Name != null)
                {
                    flag = DAL.DALCurrency.CreateCurrency(_currency);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
        public void OpenPosition(Currency currencyForPosition, Currency baseCurrency,  DateTime dateTime)
        {

            Status = PositionRuntimeStatus.Active;
            _currentPositionRecord = new PositionRecord(dateTime, currencyForPosition, baseCurrency, PositionType, this);
            PositionRecords.Add(_currentPositionRecord);
        }
 public void Can_formatPrice_with_distinct_currencyDisplayLocale()
 {
     var usd_currency = new Currency()
     {
         Id = 1,
         Name = "US Dollar",
         CurrencyCode = "USD",
         DisplayLocale = "en-US",
     };
     var rub_currency = new Currency()
     {
         Id = 2,
         Name = "British Pound",
         CurrencyCode = "GBP",
         DisplayLocale = "en-GB",
     };
     var language = new Language()
     {
         Id = 1,
         Name = "English",
         LanguageCulture = "en-US"
     };
     _priceFormatter.FormatPrice(1234.5M, true, usd_currency, language, false, false).ShouldEqual("$1,234.50");
     _priceFormatter.FormatPrice(1234.5M, true, rub_currency, language, false, false).ShouldEqual("£1,234.50");
 }
示例#31
0
        ///<summary>
        /// Gets all the Discount curve name.
        ///</summary>
        ///<returns></returns>
        public static string GetDiscountCurveName(Currency currency)
        {
            var result = GetDiscountCurveName(currency.Value);

            return(result);
        }
示例#32
0
        public new void SetUp()
        {
            _workContext = new Mock <IWorkContext>();
            _workContext.Setup(w => w.WorkingCurrency).Returns(new Currency {
                RoundingType = RoundingType.Rounding001
            });

            _currencySettings = new CurrencySettings();
            var currency1 = new Currency
            {
                Id               = 1,
                Name             = "Euro",
                CurrencyCode     = "EUR",
                DisplayLocale    = "",
                CustomFormatting = "€0.00",
                DisplayOrder     = 1,
                Published        = true,
                CreatedOnUtc     = DateTime.UtcNow,
                UpdatedOnUtc     = DateTime.UtcNow
            };
            var currency2 = new Currency
            {
                Id               = 1,
                Name             = "US Dollar",
                CurrencyCode     = "USD",
                DisplayLocale    = "en-US",
                CustomFormatting = "",
                DisplayOrder     = 2,
                Published        = true,
                CreatedOnUtc     = DateTime.UtcNow,
                UpdatedOnUtc     = DateTime.UtcNow
            };

            _currencyRepo = new Mock <IRepository <Currency> >();
            _currencyRepo.Setup(x => x.Table).Returns(new List <Currency> {
                currency1, currency2
            }.AsQueryable());

            _storeMappingService = new Mock <IStoreMappingService>();
            _measureService      = new Mock <IMeasureService>();

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            var pluginService = new FakePluginService();

            _exchangeRatePluginManager = new ExchangeRatePluginManager(_currencySettings, new FakeCacheKeyService(), new Mock <ICustomerService>().Object, pluginService);
            _currencyService           = new CurrencyService(_currencySettings,
                                                             new FakeCacheKeyService(),
                                                             null,
                                                             _exchangeRatePluginManager,
                                                             _currencyRepo.Object,
                                                             _storeMappingService.Object);

            _taxSettings = new TaxSettings();

            _localizationService = new Mock <ILocalizationService>();
            _localizationService.Setup(x => x.GetResource("Products.InclTaxSuffix", 1, false, string.Empty, false)).Returns("{0} incl tax");
            _localizationService.Setup(x => x.GetResource("Products.ExclTaxSuffix", 1, false, string.Empty, false)).Returns("{0} excl tax");

            _priceFormatter = new PriceFormatter(_currencySettings, _currencyService, _localizationService.Object,
                                                 _measureService.Object, _workContext.Object, _taxSettings);

            var nopEngine = new Mock <NopEngine>();

            nopEngine.Setup(x => x.ServiceProvider).Returns(new TestServiceProvider());
            EngineContext.Replace(nopEngine.Object);
        }
示例#33
0
        public IResponseResult DeleteCurrency(Currency model)
        {
            var result = Biz.DeleteCurrency(UserModel, model, out var msg);

            return(ReturnResult(result, msg));
        }
示例#34
0
        public IResponseResult UpdateCurrency(Currency model)
        {
            var result = Biz.UpdateCurrency(UserModel, model);

            return(ReturnResult(result));
        }
示例#35
0
        public Stream Save(Stream stream)
        {
            XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);

            writer.Formatting = Formatting.Indented;

            writer.WriteStartDocument();

            #region Header
            writer.WriteStartElement("rsm:CrossIndustryDocument");
            writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
            writer.WriteAttributeString("xmlns", "rsm", null, "urn:ferd:CrossIndustryDocument:invoice:1p0");
            writer.WriteAttributeString("xmlns", "ram", null, "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12");
            writer.WriteAttributeString("xmlns", "udt", null, "urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15");
            #endregion

            #region SpecifiedExchangedDocumentContext
            writer.WriteStartElement("rsm:SpecifiedExchangedDocumentContext");
            writer.WriteStartElement("ram:TestIndicator");
            writer.WriteElementString("udt:Indicator", "true");
            writer.WriteEndElement();
            writer.WriteStartElement("ram:GuidelineSpecifiedDocumentContextParameter");
            writer.WriteElementString("ram:ID", "urn:ferd:CrossIndustryDocument:invoice:1p0:" + Profile.ToString().ToLower());
            writer.WriteEndElement();
            writer.WriteEndElement();

            #endregion

            WriteHeaderExchangeDocument(writer);

            writer.WriteStartElement("rsm:SpecifiedSupplyChainTradeTransaction");

            writer.WriteStartElement("ram:ApplicableSupplyChainTradeAgreement");

            //Seller details.
            WriteUserDetails(writer, "ram:SellerTradeParty", Seller);

            //Buyer details
            WriteUserDetails(writer, "ram:BuyerTradeParty", Buyer);

            //End of ApplicableSupplyChainTradeAgreement
            writer.WriteEndElement();

            writer.WriteStartElement("ram:ApplicableSupplyChainTradeSettlement");

            writer.WriteElementString("ram:InvoiceCurrencyCode", Currency.ToString("g"));

            writer.WriteStartElement("ram:SpecifiedTradeSettlementMonetarySummation");

            WriteOptionalAmount(writer, "ram:GrandTotalAmount", TotalAmount);

            writer.WriteEndElement();

            writer.WriteEndElement();

            AddTradeLineItems(writer);

            writer.WriteEndDocument();
            writer.Flush();
            stream.Position = 0;
            return(stream);
        }
 public void DropSubscriptionByName(Subscription subscription, SubscriptionType subscriptionType, Currency currency)
 {
     using (var context = new DataMapperContext())
     {
         var subType = context.SubscriptionTypes.Find(subscriptionType.SubscriptionTypeId);
         var cur     = context.Currencies.Find(currency.CurrencyId);
         var sub     = context.Subscriptions.Find(subscription.SubscriptionId);
         context.Entry(subType).Collection("Subscriptions").Load();
         context.Entry(cur).Collection("Subscriptions").Load();
         subType.Subscriptions.Remove(sub);
         cur.Subscriptions.Remove(sub);
         context.Subscriptions.Attach(sub);
         context.Subscriptions.Remove(sub);
         context.SaveChanges();
     }
 }
 public void AddSubscription(Subscription subscription, SubscriptionType subType, Currency currency)
 {
     using (var context = new DataMapperContext())
     {
         context.SubscriptionTypes.Attach(subType);
         context.Currencies.Attach(currency);
         context.Subscriptions.Attach(subscription);
         context.Entry(subType).Collection(c => c.Subscriptions).Load();
         context.Entry(currency).Collection(c => c.Subscriptions).Load();
         context.Subscriptions.Add(subscription);
         context.SaveChanges();
     }
 }
示例#38
0
 public Libor(string familyName, Period tenor, uint settlementDays, Currency currency, Calendar financialCenterCalendar, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_Libor__SWIG_1(familyName, Period.getCPtr(tenor), settlementDays, Currency.getCPtr(currency), Calendar.getCPtr(financialCenterCalendar), DayCounter.getCPtr(dayCounter)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#39
0
        public static bool placeBet(string user, string option, int amount)
        {
            if (Running && !Locked)
            {
                lock (bets)
                {
                    lock (FalseEntries)
                    {
                        lock (Options)
                        {
                            if (!FalseEntries.ContainsKey(user) && !bets.ContainsKey(user))
                            {
                                BetQueue.Change(10000, Timeout.Infinite);
                            }

                            if (Options.Contains(option))
                            {
                                if (amount >= MinBet && amount <= MaxBet)
                                {
                                    int paid = 0;
                                    if (bets.ContainsKey(user))
                                    {
                                        paid = bets[user].Value;
                                    }

                                    if (Currency.Check(user) + paid >= amount)
                                    {
                                        if (bets.ContainsKey(user))
                                        {
                                            bets.Remove(user);
                                        }

                                        Currency.Add(user, paid);
                                        Currency.Remove(user, amount);
                                        bets.Add(user, new KeyValuePair <string, int>(option, amount));

                                        if (FalseEntries.ContainsKey(user))
                                        {
                                            FalseEntries.Remove(user);
                                        }

                                        return(true);
                                    }
                                    else
                                    {
                                        if (!FalseEntries.ContainsKey(user))
                                        {
                                            FalseEntries.Add(user, 3);
                                        }
                                    }
                                }
                                else
                                {
                                    if (!FalseEntries.ContainsKey(user))
                                    {
                                        FalseEntries.Add(user, 2);
                                    }
                                }
                            }
                            else
                            {
                                if (!FalseEntries.ContainsKey(user))
                                {
                                    FalseEntries.Add(user, 1);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#40
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("md5Secret", "settings");
            settings.MustContainKey("instId", "settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
            order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
            order.Properties[settings["zipCodePropertyAlias"]].MustNotBeNullOrEmpty("zip code");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = settings.ContainsKey("testMode") && settings["testMode"] == "100" ? "https://secure-test.worldpay.com/wcc/purchase" : "https://secure.worldpay.com/wcc/purchase"
            };

            string[] settingsToExclude = new[] { "md5Secret", "callbackPW", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //cartId
            htmlForm.InputFields["cartId"] = order.CartNumber;

            //currency
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            //amount
            string amount = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = amount;

            htmlForm.InputFields["successURL"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelURL"]  = teaCommerceCancelUrl;

            //name
            htmlForm.InputFields["name"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            //email
            htmlForm.InputFields["email"] = order.PaymentInformation.Email;

            //country
            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);

            htmlForm.InputFields["country"] = country.RegionCode;

            //country region
            if (order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                htmlForm.InputFields["region"] = countryRegion.RegionCode;
            }

            //address1
            htmlForm.InputFields["address1"] = order.Properties[settings["streetAddressPropertyAlias"]];

            //town
            htmlForm.InputFields["town"] = order.Properties[settings["cityPropertyAlias"]];

            //postcode
            htmlForm.InputFields["postcode"] = order.Properties[settings["zipCodePropertyAlias"]];

            //UI settings
            htmlForm.InputFields["noLanguageMenu"] = string.Empty;
            htmlForm.InputFields["hideCurrency"]   = string.Empty;
            htmlForm.InputFields["fixContact"]     = string.Empty;
            htmlForm.InputFields["hideContact"]    = string.Empty;

            htmlForm.InputFields["signatureFields"] = "amount:currency:instId:cartId";
            htmlForm.InputFields["signature"]       = GenerateMD5Hash(settings["md5Secret"] + ":" + amount + ":" + currency.IsoCode + ":" + settings["instId"] + ":" + order.CartNumber);

            //WorldPay dont support to show order line information to the shopper

            return(htmlForm);
        }
示例#41
0
 private decimal GetConvertedRate(decimal rate, Currency source, Currency target) => (source.CurrencyCode == target.CurrencyCode) ? rate : _currencyService.ConvertCurrency(rate, source, target);
示例#42
0
        private static void Command_Gamble(string user, Command cmd, string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0].ToLower() == "open" && args.Length > 4)
                {
                    if (!Running)
                    {
                        int min, max, reward;
                        if (int.TryParse(args[1], out min) && int.TryParse(args[2], out max) && int.TryParse(args[3], out reward))
                        {
                            if (min > 0)
                            {
                                if (max >= min)
                                {
                                    if (reward >= 0)
                                    {
                                        List <string> lOptions = buildBetOptions(args, 4);
                                        if (lOptions.Count > 1)
                                        {
                                            LastUsedHelp = Api.GetUnixTimeNow();

                                            CreatePool(min, max, reward, lOptions);
                                            Chat.SendMessage("New Betting Pool opened! Min bet: " + MinBet + " " + Currency.Name + ", Max bet: " + MaxBet + " " + Currency.Name + ".");
                                            string temp = "Betting open for: ";
                                            for (int i = 0; i < lOptions.Count; i++)
                                            {
                                                temp += "(" + (i + 1).ToString() + ") " + lOptions[i];
                                                if (i + 1 < lOptions.Count)
                                                {
                                                    temp += ", ";
                                                }
                                            }
                                            Chat.SendMessage(temp + ".");
                                            Chat.SendMessage("Bet by typing \"!bet 50 #1\" to bet 50 " + Currency.Name + " on option 1, \"!bet 25 #2\" to bet 25 " + Currency.Name + " on option 2, etc.");
                                        }
                                        else
                                        {
                                            Chat.SendMessage("You need at least two betting options in order to start a betting pool!");
                                        }
                                    }
                                    else
                                    {
                                        Chat.SendMessage("WinReward can not be lower than 0!");
                                    }
                                }
                                else
                                {
                                    Chat.SendMessage("MaxBet can not be lower than MinBet!");
                                }
                            }
                            else
                            {
                                Chat.SendMessage("MinBet can not be lower than 1!");
                            }
                        }
                        else
                        {
                            Chat.SendMessage("Invalid syntax. Open a betting pool with: !gamble open {MinBet} {MaxBet} {WinReward} {option1} {option2} ... {optionN} (space delimited options)");
                        }
                    }
                    else
                    {
                        Chat.SendMessage("Betting Pool already opened. Close or cancel the current one before starting a new one.");
                    }
                }
                else if (args[0].ToLower() == "close")
                {
                    if (Running)
                    {
                        if (!Locked)
                        {
                            Locked = true;
                            BetQueue.Change(0, Timeout.Infinite);
                            Chat.SendMessage("Bets locked in. Good luck everyone!");
                            string temp = "The following options were open for betting: ";
                            lock (Options) for (int i = 0; i < Options.Count; i++)
                                {
                                    temp += "(" + (i + 1).ToString() + ") " + Options[i] + " - " + getNumberOfBets(Options[i]) + " bets (" + getTotalBetsOn(Options[i]) + " " + Currency.Name + ")" + (i + 1 < Options.Count ? ", " : "");
                                }
                            Chat.SendMessage(temp + ".");
                        }
                        else
                        {
                            Chat.SendMessage("Pool is already locked.");
                        }
                    }
                    else
                    {
                        Chat.SendMessage("The betting pool is not running.");
                    }
                }
                else if (args[0].ToLower() == "winner" && args.Length > 1)
                {
                    if (Running && Locked)
                    {
                        bool   inQuote = false;
                        string option  = "";
                        for (int i = 1; i < args.Length; i++)
                        {
                            if (args[i].StartsWith("\""))
                            {
                                inQuote = true;
                            }
                            if (!inQuote)
                            {
                                option = args[i];
                            }
                            if (inQuote)
                            {
                                option += args[i] + " ";
                            }
                            if (args[i].EndsWith("\""))
                            {
                                option  = option.Substring(1, option.Length - 3);
                                inQuote = false;
                            }
                        }
                        if (option.ToLower() == args[1].ToLower())
                        {
                            if (option.StartsWith("#"))
                            {
                                int optionnumber = 0;
                                if (int.TryParse(option.Substring(1), out optionnumber))
                                {
                                    option = GetOptionFromNumber(optionnumber);
                                }
                            }
                        }

                        lock (Options)
                        {
                            if (Options.Contains(option))
                            {
                                closePool(option);
                                Chat.SendMessage("Betting Pool closed! A total of " + getTotalBets() + " " + Currency.Name + " were bet.");
                                string output = "Bets for:";
                                for (int i = 0; i < Options.Count; i++)
                                {
                                    double x = ((double)getTotalBetsOn(Options[i]) / getTotalBets()) * 100;
                                    output += " " + Options[i] + " - " + getNumberOfBets(Options[i]) + " (" + Math.Round(x) + "%);";
                                    //Console.WriteLine("TESTING: getTotalBetsOn(" + i + ") = " + getTotalBetsOn(i) + " --- getTotalBets() = " + getTotalBets() + " ---  (double)betsOn(i)/totalBets() = " + (double)(getTotalBetsOn(i) / getTotalBets()) + " --- *100 = " + (double)(getTotalBetsOn(i) / getTotalBets()) * 100 + " --- Converted to a double = " + (double)((getTotalBetsOn(i) / getTotalBets()) * 100) + " --- Rounded double = " + Math.Round((double)((getTotalBetsOn(i) / getTotalBets()) * 100)));
                                }
                                Chat.SendMessage(output);
                                Dictionary <string, int> wins = Winners;
                                output = "Winners:";
                                if (wins.Count == 0)
                                {
                                    output += " No One!";
                                }

                                for (int i = 0; i < wins.Count; i++)
                                {
                                    Currency.Add(wins.ElementAt(i).Key, wins.ElementAt(i).Value);
                                    string msg = " " + wins.ElementAt(i).Key + " - " + wins.ElementAt(i).Value + " (Bet " + bets[wins.ElementAt(i).Key].Value + ")";
                                    if (output.Length + msg.Length > 996)
                                    {
                                        Chat.SendMessage(output);
                                        output = "";
                                    }
                                    output += msg;
                                }

                                Chat.SendMessage(output);

                                Clear();
                            }
                            else
                            {
                                Chat.SendMessage("The option you specified is not available in the current pool!");
                            }
                        }
                    }
                    else
                    {
                        Chat.SendMessage("Betting pool must be running and bets must be locked before you can specify a winner, lock the bets by using \"!gamble close\".");
                        Chat.SendMessage("Pick a winning option by typing \"!gamble winner #1\" if option 1 won, \"!gamble winner #2\" for option 2, etc.");
                        Chat.SendMessage("You can type \"!bet help\" to get a list of the options as a reminder.");
                    }
                }
                else if (args[0].ToLower() == "cancel")
                {
                    if (Running)
                    {
                        Cancel();
                        Chat.SendMessage("Betting Pool canceled. All bets refunded");
                    }
                    else
                    {
                        Chat.SendMessage("The betting pool is not running.");
                    }
                }
            }
        }
示例#43
0
 public bool IsWithinCreditLimitByMargin(Customer customer, Currency margin)
 {
     //TODO: contact back-end system for actual response
     return(true);
 }
示例#44
0
 public PriceToString(Currency currency)
 {
     this.currency = currency;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ccy1"></param>
        /// <param name="currency1Discountcurve"></param>
        /// <param name="ccy2"></param>
        /// <param name="currency2Discountcurve"></param>
        /// <param name="spotFX"></param>
        /// <param name="includeSettlementDateFlows"></param>
        /// <param name="settlementDate"></param>
        /// <param name="npvDate"></param>
        public DiscountingFxForwardEngine(Currency ccy1, Handle <YieldTermStructure> currency1Discountcurve, Currency ccy2, Handle <YieldTermStructure> currency2Discountcurve, Handle <Quote> spotFX, bool includeSettlementDateFlows, Date settlementDate, Date npvDate)
        {
            _ccy1 = ccy1;
            _currency1Discountcurve = currency1Discountcurve;
            _ccy2 = ccy2;
            _currency2Discountcurve = currency2Discountcurve;
            _spotFX = spotFX;
            _includeSettlementDateFlows = includeSettlementDateFlows;
            _settlementDate             = settlementDate;
            _npvDate = npvDate;

            _currency1Discountcurve.registerWith(update);
            _currency2Discountcurve.registerWith(update);
            _spotFX.registerWith(update);
        }
示例#46
0
 public Discount(Currency currency)
 {
     Amount = new Money(currency);
 }
示例#47
0
        /// <summary>
        /// Converts currency
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="sourceCurrencyCode">Source currency code</param>
        /// <param name="targetCurrencyCode">Target currency code</param>
        /// <returns>Converted value</returns>
        public virtual decimal ConvertCurrency(decimal amount, Currency sourceCurrencyCode, Currency targetCurrencyCode)
        {
            decimal result = amount;

            if (sourceCurrencyCode.Id == targetCurrencyCode.Id)
            {
                return(result);
            }
            if (result != decimal.Zero && sourceCurrencyCode.Id != targetCurrencyCode.Id)
            {
                result = ConvertToPrimaryExchangeRateCurrency(result, sourceCurrencyCode);
                result = ConvertFromPrimaryExchangeRateCurrency(result, targetCurrencyCode);
            }
            return(result);
        }
示例#48
0
 public OrderDigestTest()
 {
     _currency = new Currency("NCG", 2, minter: null);
 }
示例#49
0
        protected virtual ShoppingCart CreateCart(string cartName, Store store, CustomerInfo customer, Language language, Currency currency)
        {
            var cart = new ShoppingCart(currency, language);

            cart.CustomerId   = customer.Id;
            cart.Name         = "Default";
            cart.StoreId      = store.Id;
            cart.Language     = language;
            cart.IsAnonymous  = !customer.IsRegisteredUser;
            cart.CustomerName = customer.IsRegisteredUser ? customer.UserName : StorefrontConstants.AnonymousUsername;

            return(cart);
        }
示例#50
0
        /// <summary>
        /// Converts from primary exchange rate currency
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="targetCurrencyCode">Target currency code</param>
        /// <returns>Converted value</returns>
        public virtual decimal ConvertFromPrimaryExchangeRateCurrency(decimal amount, Currency targetCurrencyCode)
        {
            decimal result = amount;
            var     primaryExchangeRateCurrency = GetCurrencyById(_currencySettings.PrimaryExchangeRateCurrencyId);

            if (result != decimal.Zero && targetCurrencyCode.Id != primaryExchangeRateCurrency.Id)
            {
                decimal exchangeRate = targetCurrencyCode.Rate;
                if (exchangeRate == decimal.Zero)
                {
                    throw new NopException(string.Format("Exchange rate not found for currency [{0}]", targetCurrencyCode.Name));
                }
                result = result * exchangeRate;
            }
            return(result);
        }
 private void CreateCurrencies()
 {
     _defaultCurrency = CreateCurrency("EUR", 100);
     CreateCurrency("GBP", 88);
 }
示例#52
0
        public virtual async Task LoadOrCreateNewTransientCartAsync(string cartName, Store store, CustomerInfo customer, Language language, Currency currency)
        {
            var cacheKey       = GetCartCacheKey(store.Id, cartName, customer.Id, currency.Code);
            var needReevaluate = false;

            Cart = await _cacheManager.GetAsync(cacheKey, _cartCacheRegion, async() =>
            {
                needReevaluate = true;

                var cartSearchCriteria = CreateCartSearchCriteria(cartName, store, customer, language, currency);
                var cartSearchResult   = await _cartApi.CartModule.SearchAsync(cartSearchCriteria);

                var cartDto = cartSearchResult.Results.FirstOrDefault();
                var cart    = cartDto?.ToShoppingCart(currency, language, customer) ?? CreateCart(cartName, store, customer, language, currency);

                //Load cart payment plan with have same id
                if (store.SubscriptionEnabled)
                {
                    var paymentPlanIds = new string[] { cart.Id }.Concat(cart.Items.Select(x => x.ProductId).Distinct()).ToArray();

                    var paymentPlans = (await _subscriptionApi.SubscriptionModule.GetPaymentPlanByIdsAsync(paymentPlanIds)).Select(x => x.ToPaymentPlan());
                    cart.PaymentPlan = paymentPlans.FirstOrDefault(x => x.Id == cart.Id);
                    foreach (var lineItem in cart.Items)
                    {
                        lineItem.PaymentPlan = paymentPlans.FirstOrDefault(x => x.Id == lineItem.ProductId);
                    }
                }

                cart.Customer = customer;
                return(cart);
            });

            if (needReevaluate)
            {
                await EvaluatePromotionsAsync();
                await EvaluateTaxesAsync();
            }
        }
示例#53
0
 public Money(double amount, Currency currency)
     : this((decimal)amount, currency, false)
 {
 }
示例#54
0
 protected virtual cartModel.ShoppingCartSearchCriteria CreateCartSearchCriteria(string cartName, Store store, CustomerInfo customer, Language language, Currency currency)
 {
     return(new cartModel.ShoppingCartSearchCriteria
     {
         StoreId = store.Id,
         CustomerId = customer.Id,
         Name = cartName,
         Currency = currency.Code,
     });
 }
示例#55
0
 public Money(Currency currency)
     : this(0m, currency)
 {
 }
示例#56
0
 public Money(decimal amount, Currency currency)
     : this(amount, currency, false)
 {
 }
示例#57
0
        /// <summary>
        /// Calculates the zero rate point sensitivity at the specified year fraction specifying the currency of the sensitivity.
        /// <para>
        /// This returns a sensitivity instance referring to the zero hazard rate sensitivity of the
        /// points that were queried in the market data.
        /// The sensitivity typically has the value {@code (-survivalProbability * yearFraction)}.
        /// The sensitivity refers to the result of <seealso cref="#survivalProbability(LocalDate)"/>.
        /// </para>
        /// <para>
        /// This method allows the currency of the sensitivity to differ from the currency of the market data.
        ///
        /// </para>
        /// </summary>
        /// <param name="yearFraction">  the year fraction </param>
        /// <param name="sensitivityCurrency">  the currency of the sensitivity </param>
        /// <returns> the point sensitivity of the zero rate </returns>
        /// <exception cref="RuntimeException"> if the result cannot be calculated </exception>
        public CreditCurveZeroRateSensitivity zeroRatePointSensitivity(double yearFraction, Currency sensitivityCurrency)
        {
            ZeroRateSensitivity zeroRateSensitivity = survivalProbabilities.zeroRatePointSensitivity(yearFraction, sensitivityCurrency);

            return(CreditCurveZeroRateSensitivity.of(legalEntityId, zeroRateSensitivity));
        }
示例#58
0
 public Money(float amount, Currency currency)
     : this((decimal)amount, currency, false)
 {
 }
示例#59
0
        /// <summary>
        /// Calculates the zero rate point sensitivity at the specified date specifying the currency of the sensitivity.
        /// <para>
        /// This returns a sensitivity instance referring to the zero hazard rate sensitivity of the
        /// points that were queried in the market data.
        /// The sensitivity typically has the value {@code (-survivalProbability * yearFraction)}.
        /// The sensitivity refers to the result of <seealso cref="#survivalProbability(LocalDate)"/>.
        /// </para>
        /// <para>
        /// This method allows the currency of the sensitivity to differ from the currency of the market data.
        ///
        /// </para>
        /// </summary>
        /// <param name="date">  the date </param>
        /// <param name="sensitivityCurrency">  the currency of the sensitivity </param>
        /// <returns> the point sensitivity of the zero rate </returns>
        /// <exception cref="RuntimeException"> if the result cannot be calculated </exception>
        public CreditCurveZeroRateSensitivity zeroRatePointSensitivity(LocalDate date, Currency sensitivityCurrency)
        {
            ZeroRateSensitivity zeroRateSensitivity = survivalProbabilities.zeroRatePointSensitivity(date, sensitivityCurrency);

            return(CreditCurveZeroRateSensitivity.of(legalEntityId, zeroRateSensitivity));
        }
示例#60
0
        ///<summary>
        /// Gets all the Discount curve name.
        ///</summary>
        ///<returns></returns>
        public static string GetDiscountCurveName(Currency currency, bool isSimple)
        {
            var result = GetDiscountCurveName(currency.Value, isSimple);

            return(result);
        }