Пример #1
0
        public ActionResult Index()
        {
            var model = new ExchangeModel();

            model.CurrencyCodes = ExchangeRateManager.GetRateCodes();

            return(PartialView(model));
        }
Пример #2
0
        public void SelectExchangeRate()
        {
            ExchangeRateManager exchangeRateManager  = (ExchangeRateManager)container["ExchangeRateManager"];
            ExchangeRate        selectedExchangeRate = exchangeRateManager.Select(new DateTime(2008, 8, 8), new Currency {
                Id = 2
            });

            Assert.AreEqual(2, selectedExchangeRate.Rate);
        }
Пример #3
0
        public void testDirectLookup()
        {
            ExchangeRateManager rateManager = ExchangeRateManager.Instance;

            rateManager.clear();

            Currency EUR = new EURCurrency(), USD = new USDCurrency();

            ExchangeRate eur_usd1 = new ExchangeRate(EUR, USD, 1.1983);
            ExchangeRate eur_usd2 = new ExchangeRate(USD, EUR, 1.0 / 1.2042);

            rateManager.add(eur_usd1, new Date(4, Month.August, 2004));
            rateManager.add(eur_usd2, new Date(5, Month.August, 2004));

            Money m1 = 50000.0 * EUR;
            Money m2 = 100000.0 * USD;

            Money.conversionType = Money.ConversionType.NoConversion;

            ExchangeRate eur_usd    = rateManager.lookup(EUR, USD, new Date(4, Month.August, 2004), ExchangeRate.Type.Direct);
            Money        calculated = eur_usd.exchange(m1);
            Money        expected   = new Money(m1.value * eur_usd1.rate, USD);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            eur_usd    = rateManager.lookup(EUR, USD, new Date(5, Month.August, 2004), ExchangeRate.Type.Direct);
            calculated = eur_usd.exchange(m1);
            expected   = new Money(m1.value / eur_usd2.rate, USD);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            ExchangeRate usd_eur = rateManager.lookup(USD, EUR, new Date(4, Month.August, 2004), ExchangeRate.Type.Direct);

            calculated = usd_eur.exchange(m2);
            expected   = new Money(m2.value / eur_usd1.rate, EUR);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            usd_eur = rateManager.lookup(USD, EUR, new Date(5, Month.August, 2004), ExchangeRate.Type.Direct);

            calculated = usd_eur.exchange(m2);
            expected   = new Money(m2.value * eur_usd2.rate, EUR);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }
        }
Пример #4
0
        public void testTriangulatedLookup()
        {
            ExchangeRateManager rateManager = ExchangeRateManager.Instance;

            rateManager.clear();

            Currency EUR = new EURCurrency(), USD = new USDCurrency(), ITL = new ITLCurrency();

            ExchangeRate eur_usd1 = new ExchangeRate(EUR, USD, 1.1983);
            ExchangeRate eur_usd2 = new ExchangeRate(EUR, USD, 1.2042);

            rateManager.add(eur_usd1, new Date(4, Month.August, 2004));
            rateManager.add(eur_usd2, new Date(5, Month.August, 2004));

            Money m1 = 50000000.0 * ITL;
            Money m2 = 100000.0 * USD;

            Money.conversionType = Money.ConversionType.NoConversion;

            ExchangeRate itl_usd    = rateManager.lookup(ITL, USD, new Date(4, Month.August, 2004));
            Money        calculated = itl_usd.exchange(m1);
            Money        expected   = new Money(m1.value * eur_usd1.rate / 1936.27, USD);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            itl_usd    = rateManager.lookup(ITL, USD, new Date(5, Month.August, 2004));
            calculated = itl_usd.exchange(m1);
            expected   = new Money(m1.value * eur_usd2.rate / 1936.27, USD);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            ExchangeRate usd_itl = rateManager.lookup(USD, ITL, new Date(4, Month.August, 2004));

            calculated = usd_itl.exchange(m2);
            expected   = new Money(m2.value * 1936.27 / eur_usd1.rate, ITL);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            usd_itl = rateManager.lookup(USD, ITL, new Date(5, Month.August, 2004));

            calculated = usd_itl.exchange(m2);
            expected   = new Money(m2.value * 1936.27 / eur_usd2.rate, ITL);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }
        }
Пример #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ExchangeRateManager.LoadFromServer();
        }
Пример #6
0
        public void SelectMostRecentlyExchangeRate_NoCurrency()
        {
            ExchangeRateManager exchangeRateManager = (ExchangeRateManager)container["ExchangeRateManager"];
            double selectedRate = exchangeRateManager.GetMostRecentlyRate(TimeProvider.Today, new Currency {
                Id = 0
            });

            Assert.AreEqual(0, selectedRate);
        }
Пример #7
0
        public void AddExchangeRate()
        {
            ExchangeRateManager exchangeRateManager = (ExchangeRateManager)container["ExchangeRateManager"];


            exchangeRateManager.Add(new DateTime(2009, 1, 1), 2, new Currency {
                Id = 1
            });
        }
Пример #8
0
        public static ExchangeRateManager instance()
        {
            ExchangeRateManager ret = new ExchangeRateManager(NQuantLibcPINVOKE.ExchangeRateManager_instance(), false);

            if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
            {
                throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static bool Deposit(string AccNo, double Amount, string Currency)
        {
            var account    = CustomerManager.FindAccount(AccNo);
            var depositAmt = ExchangeRateManager.CurrencyConvert(Currency, Amount);

            account.AccountBalance = account.AccountBalance + depositAmt;
            var update = CustomerManager.UpdateAccount(AccNo, account.AccountBalance);

            return(update);
        }
Пример #10
0
        public void SelectExchangeRate_Null()
        {
            ExchangeRateManager exchangeRateManager = (ExchangeRateManager)container["ExchangeRateManager"];

            ExchangeRate selectedExchangeRate = exchangeRateManager.Select(new DateTime(3333, 2, 2), new Currency {
                Id = 1
            });

            Assert.IsNull(selectedExchangeRate);
        }
Пример #11
0
        public void InitManager()
        {
            TechnicalSettings.CheckSettings();

            LoanProductManager           loanProductManager           = new LoanProductManager(DataUtil.TESTDB);
            AccountingTransactionManager accountingTransactionManager = new AccountingTransactionManager(DataUtil.TESTDB);
            EventManager            eventManager            = new EventManager(DataUtil.TESTDB);
            ExchangeRateManager     exchangeRateManager     = new ExchangeRateManager(DataUtil.TESTDB);
            ProvisioningRuleManager provisioningRuleManager = new ProvisioningRuleManager(DataUtil.TESTDB);
            AccountManager          accountManager          = new AccountManager(DataUtil.TESTDB);
            InstallmentTypeManager  installmentTypeManager  = new InstallmentTypeManager(DataUtil.TESTDB);
            UserManager             userManager             = new UserManager(DataUtil.TESTDB);
            EconomicActivityManager economicActivityManager = new EconomicActivityManager(DataUtil.TESTDB);
            InstallmentManager      installmentManager      = new InstallmentManager(DataUtil.TESTDB);
            FundingLineManager      fundingLineManager      = new FundingLineManager(DataUtil.TESTDB);
            ClientManager           clientManager           = new ClientManager(DataUtil.TESTDB);
            LocationsManager        locationsManager        = new LocationsManager(DataUtil.TESTDB);
            LoanManager             loanManager             = new LoanManager(DataUtil.TESTDB);
            ProjectManager          projectManager          = new ProjectManager(DataUtil.TESTDB);
            MFIManager            mfiManager            = new MFIManager(DataUtil.TESTDB);
            SavingManager         savingManager         = new SavingManager(DataUtil.TESTDB);
            SavingProductManager  savingProductManager  = new SavingProductManager(DataUtil.TESTDB);
            SavingEventManager    savingEventManager    = new SavingEventManager(DataUtil.TESTDB);
            CurrencyManager       currencyManager       = new CurrencyManager(DataUtil.TESTDB);
            AccountingRuleManager accountingRuleManager = new AccountingRuleManager(DataUtil.TESTDB);
            FundingLineServices   fundingLineServices   = new FundingLineServices(DataUtil.TESTDB);

            container = new Hashtable
            {
                { "LoanProductManager", loanProductManager },
                { "AccountingTransactionManager", accountingTransactionManager },
                { "EventManager", eventManager },
                { "ExchangeRateManager", exchangeRateManager },
                { "ProvisioningRuleManager", provisioningRuleManager },
                { "AccountManager", accountManager },
                { "InstallmentTypeManager", installmentTypeManager },
                { "UserManager", userManager },
                { "FundingLineManager", fundingLineManager },
                { "LoanManager", loanManager },
                { "ClientManager", clientManager },
                { "LocationsManager", locationsManager },
                { "ProjectManager", projectManager },
                { "EconomicActivityManager", economicActivityManager },
                { "InstallmentManager", installmentManager },
                { "MFIManager", mfiManager },
                { "SavingManager", savingManager },
                { "SavingProductManager", savingProductManager },
                { "SavingEventManager", savingEventManager },
                { "CurrencyManager", currencyManager },
                { "FundingLineServices", fundingLineServices },
                { "AccountingRuleManager", accountingRuleManager }
            };
        }
        public void SelectExportableBooking_AllBookingsHasBeenSelected_ExchangeRate()
        {
            ExchangeRateManager          exchangeRateManager          = (ExchangeRateManager)container["ExchangeRateManager"];
            AccountingTransactionManager accountingTransactionManager = (AccountingTransactionManager)container["AccountingTransactionManager"];

            exchangeRateManager.Add(new DateTime(2009, 1, 1), 3, new Currency {
                Id = 2
            });
            DataTable idTable;
            DataTable table = accountingTransactionManager.SelectBookingsToExport("ExportAccounting_Transactions", null, out idTable);

            Assert.AreEqual(0, table.Rows.Count);
        }
Пример #13
0
        public JsonResult Calculate(string code, string amount)
        {
            try
            {
                var amountDecimal = Convert.ToDecimal(amount, System.Globalization.CultureInfo.InvariantCulture);

                decimal?result = ExchangeRateManager.ConvertTo(amountDecimal, code);
                if (result == null)
                {
                    return(Json(new ResponseModel(false)));
                }

                return(Json(new ResponseModel(true, result.Value)));
            }
            catch (Exception)
            {
                return(Json(false));
            }
        }
Пример #14
0
        public void testSmartLookup()
        {
            Currency EUR = new EURCurrency(), USD = new USDCurrency(), GBP = new GBPCurrency(),
                     CHF = new CHFCurrency(), SEK = new SEKCurrency(), JPY = new JPYCurrency();

            ExchangeRateManager rateManager = ExchangeRateManager.Instance;

            rateManager.clear();

            ExchangeRate eur_usd1           = new ExchangeRate(EUR, USD, 1.1983);
            ExchangeRate eur_usd2           = new ExchangeRate(USD, EUR, 1.0 / 1.2042);

            rateManager.add(eur_usd1, new Date(4, Month.August, 2004));
            rateManager.add(eur_usd2, new Date(5, Month.August, 2004));

            ExchangeRate eur_gbp1 = new ExchangeRate(GBP, EUR, 1.0 / 0.6596);
            ExchangeRate eur_gbp2 = new ExchangeRate(EUR, GBP, 0.6612);

            rateManager.add(eur_gbp1, new Date(4, Month.August, 2004));
            rateManager.add(eur_gbp2, new Date(5, Month.August, 2004));

            ExchangeRate usd_chf1 = new ExchangeRate(USD, CHF, 1.2847);
            ExchangeRate usd_chf2 = new ExchangeRate(CHF, USD, 1.0 / 1.2774);

            rateManager.add(usd_chf1, new Date(4, Month.August, 2004));
            rateManager.add(usd_chf2, new Date(5, Month.August, 2004));

            ExchangeRate chf_sek1 = new ExchangeRate(SEK, CHF, 0.1674);
            ExchangeRate chf_sek2 = new ExchangeRate(CHF, SEK, 1.0 / 0.1677);

            rateManager.add(chf_sek1, new Date(4, Month.August, 2004));
            rateManager.add(chf_sek2, new Date(5, Month.August, 2004));

            ExchangeRate jpy_sek1 = new ExchangeRate(SEK, JPY, 14.5450);
            ExchangeRate jpy_sek2 = new ExchangeRate(JPY, SEK, 1.0 / 14.6110);

            rateManager.add(jpy_sek1, new Date(4, Month.August, 2004));
            rateManager.add(jpy_sek2, new Date(5, Month.August, 2004));

            Money m1 = 100000.0 * USD;
            Money m2 = 100000.0 * EUR;
            Money m3 = 100000.0 * GBP;
            Money m4 = 100000.0 * CHF;
            Money m5 = 100000.0 * SEK;
            Money m6 = 100000.0 * JPY;

            Money.conversionType = Money.ConversionType.NoConversion;

            // two-rate chain

            ExchangeRate usd_sek    = rateManager.lookup(USD, SEK, new Date(4, Month.August, 2004));
            Money        calculated = usd_sek.exchange(m1);
            Money        expected   = new Money(m1.value * usd_chf1.rate / chf_sek1.rate, SEK);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            usd_sek    = rateManager.lookup(SEK, USD, new Date(5, Month.August, 2004));
            calculated = usd_sek.exchange(m5);
            expected   = new Money(m5.value * usd_chf2.rate / chf_sek2.rate, USD);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            // three-rate chain

            ExchangeRate eur_sek = rateManager.lookup(EUR, SEK, new Date(4, Month.August, 2004));

            calculated = eur_sek.exchange(m2);
            expected   = new Money(m2.value * eur_usd1.rate * usd_chf1.rate / chf_sek1.rate, SEK);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            eur_sek    = rateManager.lookup(SEK, EUR, new Date(5, Month.August, 2004));
            calculated = eur_sek.exchange(m5);
            expected   = new Money(m5.value * eur_usd2.rate * usd_chf2.rate / chf_sek2.rate, EUR);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            // four-rate chain

            ExchangeRate eur_jpy = rateManager.lookup(EUR, JPY, new Date(4, Month.August, 2004));

            calculated = eur_jpy.exchange(m2);
            expected   = new Money(m2.value * eur_usd1.rate * usd_chf1.rate * jpy_sek1.rate / chf_sek1.rate, JPY);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            eur_jpy    = rateManager.lookup(JPY, EUR, new Date(5, Month.August, 2004));
            calculated = eur_jpy.exchange(m6);
            expected   = new Money(m6.value * jpy_sek2.rate * eur_usd2.rate * usd_chf2.rate / chf_sek2.rate, EUR);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            // five-rate chain

            ExchangeRate gbp_jpy = rateManager.lookup(GBP, JPY, new Date(4, Month.August, 2004));

            calculated = gbp_jpy.exchange(m3);
            expected   = new Money(m3.value * eur_gbp1.rate * eur_usd1.rate * usd_chf1.rate * jpy_sek1.rate / chf_sek1.rate, JPY);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }

            gbp_jpy    = rateManager.lookup(JPY, GBP, new Date(5, Month.August, 2004));
            calculated = gbp_jpy.exchange(m6);
            expected   = new Money(m6.value * jpy_sek2.rate * eur_usd2.rate * usd_chf2.rate * eur_gbp2.rate / chf_sek2.rate, GBP);

            if (!Utils.close(calculated, expected))
            {
                Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated);
            }
        }
Пример #15
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ExchangeRateManager obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #16
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ExchangeRateManager obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Пример #17
0
 public static ExchangeRateManager instance() {
   ExchangeRateManager ret = new ExchangeRateManager(NQuantLibcPINVOKE.ExchangeRateManager_instance(), false);
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #18
0
 public ExchangeRateServices(string pTestDb)
 {
     _rateManager     = new ExchangeRateManager(pTestDb);
     _currencyManager = new CurrencyManager(pTestDb);
 }
Пример #19
0
 public ExchangeRateServices(User pUser)
 {
     _rateManager     = new ExchangeRateManager(pUser);
     _currencyManager = new CurrencyManager(pUser);
     _user            = pUser;
 }