Exemplo n.º 1
0
 public Account(Guid id, Guid userAccountId, AccountCurrency currency, List <AccountEntry> entries)
 {
     Id       = id;
     UserId   = userAccountId;
     Currency = currency;
     _entries = entries;
 }
        public async Task <decimal?> GetExchangeRate(AccountCurrency from, AccountCurrency to)
        {
            var rates = await _nbuCurrencyExchangeClient.GetExchangeRates();

            var fromBaseRate = from != BASE_CURRENCY?rates.SingleOrDefault(x => x.Code == from.ToString())?.Rate : 1;

            var toBaseRate = to != BASE_CURRENCY?rates.SingleOrDefault(x => x.Code == to.ToString())?.Rate : 1;

            return(fromBaseRate / toBaseRate);
        }
Exemplo n.º 3
0
        private void ParseAccountData(XmlNode accountsData, DataRowCollection orders, Dictionary <Guid, Transaction> exectuedTransactions,
                                      out AccountBalance[] accountBalances, out AccountCurrency[] accountCurrencies, out Contract[] contracts)
        {
            accountBalances   = null;
            accountCurrencies = null;
            contracts         = null;

            if (accountsData != null)
            {
                accountBalances = new AccountBalance[accountsData.ChildNodes.Count];
                List <AccountCurrency> accountCurrencyList = new List <AccountCurrency>();
                List <Contract>        contractList        = new List <Contract>();

                int index = 0;
                foreach (XmlElement account in accountsData.ChildNodes)
                {
                    AccountBalance accountBalance = new AccountBalance();
                    accountBalance.Initialize(account);
                    accountBalances[index++] = accountBalance;

                    foreach (XmlElement xmlChild in account.ChildNodes)
                    {
                        if (xmlChild.Name == "Currency")
                        {
                            AccountCurrency accountCurrency = new AccountCurrency();
                            accountCurrency.AccountId = accountBalance.AccountId;
                            accountCurrency.Initialize(xmlChild);
                            accountCurrencyList.Add(accountCurrency);
                        }
                        else if (xmlChild.Name == "Orders")
                        {
                            foreach (XmlElement orderNode in xmlChild.ChildNodes)
                            {
                                Guid    orderId  = XmlConvert.ToGuid(orderNode.Attributes["ID"].Value);
                                DataRow orderRow = orders.Find(new object[] { orderId });
                                if (orderRow != null)
                                {
                                    Guid transactionId = (Guid)(orderRow["TransactionID"]);
                                    if (exectuedTransactions.ContainsKey(transactionId))
                                    {
                                        Contract contract = new Contract();
                                        contract.Initialize(orderRow);
                                        contract.Initialize(orderNode);
                                        contractList.Add(contract);
                                    }
                                }
                            }
                        }
                    }
                }

                contracts         = contractList.ToArray();
                accountCurrencies = accountCurrencyList.ToArray();
            }
        }
Exemplo n.º 4
0
 // Constructors
 public BankAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
     long accountNumber)
 {
     this.Type = type;
     this.Currency = currency;
     this.Period = period;
     this.Owner = owner;
     this.CurrentBalance = 0;
     this.accountNumber = accountNumber;
     this.CalculateInterestRate();
 }
Exemplo n.º 5
0
 // Constructors
 public BankAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
                    long accountNumber)
 {
     this.Type           = type;
     this.Currency       = currency;
     this.Period         = period;
     this.Owner          = owner;
     this.CurrentBalance = 0;
     this.accountNumber  = accountNumber;
     this.CalculateInterestRate();
 }
        private void Transfer(decimal value, decimal commission, AccountCurrency toAccountCurrency,
                              AccountCurrency fromAccountCurrency)
        {
            value += commission;

            fromAccountCurrency.Value -= value;

            value -= commission;

            toAccountCurrency.Value += value;
        }
Exemplo n.º 7
0
        private async Task AddAccountCurrencyAsync(Account account, Currency currency)
        {
            var accountCurrency = new AccountCurrency
            {
                Id       = Guid.NewGuid(),
                Account  = account,
                Currency = currency,
                Value    = 0
            };

            await AccountCurrencies.AddAsync(accountCurrency);
        }
Exemplo n.º 8
0
 // Constructors
 public LoanAccount(AccountType type, AccountCurrency currency, AccountPeriod period, decimal loanAmount, Customer owner,
     long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     if (loanAmount > 0)
     {
         this.loanAmount = loanAmount;
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
Exemplo n.º 9
0
 // Constructors
 public LoanAccount(AccountType type, AccountCurrency currency, AccountPeriod period, decimal loanAmount, Customer owner,
                    long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     if (loanAmount > 0)
     {
         this.loanAmount = loanAmount;
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
Exemplo n.º 10
0
        private void AddAccountCurrency(Account account, Currency currency)
        {
            var accountCurrency = new AccountCurrency
            {
                Id           = Guid.NewGuid(),
                Account      = account,
                Currency     = currency,
                Value        = 0,
                AccountId    = account.Id,
                CurrencyName = currency.Name
            };

            account.AccountCurrencies.Add(accountCurrency);

            accountCurrencies.Add(accountCurrency);
        }
Exemplo n.º 11
0
 // Constructors
 public MortgageAccount(AccountType type, AccountCurrency currency, AccountPeriod period, RealEstate ownerProperty, decimal loanAmount,
                        Customer owner, long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     this.ownerProperty = ownerProperty;
     if (loanAmount > 0)
     {
         if (this.ownerProperty.Price >= loanAmount)
         {
             this.loanAmount = loanAmount;
         }
         else
         {
             throw new ArgumentException(String.Format("Loan amount cannot exceed: {0}", this.ownerProperty.Price));
         }
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
Exemplo n.º 12
0
 // Constructors
 public MortgageAccount(AccountType type, AccountCurrency currency, AccountPeriod period, RealEstate ownerProperty, decimal loanAmount,
     Customer owner, long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     this.ownerProperty = ownerProperty;
     if (loanAmount > 0)
     {
         if (this.ownerProperty.Price >= loanAmount)
         {
             this.loanAmount = loanAmount;
         }
         else
         {
             throw new ArgumentException(String.Format("Loan amount cannot exceed: {0}", this.ownerProperty.Price));
         }
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
Exemplo n.º 13
0
        public static void Initialize(this AccountCurrency accountCurrency, XmlNode xmlNode)
        {
            foreach (XmlAttribute xmlAttribute in xmlNode.Attributes)
            {
                String nodeName  = xmlAttribute.Name;
                String nodeValue = xmlAttribute.Value;

                if (nodeName == "AccountID")
                {
                    accountCurrency.AccountId = new Guid(nodeValue);
                    continue;
                }
                if (nodeName == "ID")
                {
                    accountCurrency.CurrencyId = new Guid(nodeValue);
                    continue;
                }
                else if (nodeName == "Balance")
                {
                    accountCurrency.Balance = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "UnclearAmount")
                {
                    accountCurrency.UnclearAmount = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "Necessary")
                {
                    accountCurrency.Necessary = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "InterestPLNotValued")
                {
                    accountCurrency.InterestPLNotValued = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "StoragePLNotValued")
                {
                    accountCurrency.StoragePLNotValued = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "TradePLNotValued")
                {
                    accountCurrency.TradePLNotValued = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "InterestPLFloat")
                {
                    accountCurrency.InterestPLFloat = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "StoragePLFloat")
                {
                    accountCurrency.StoragePLFloat = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "TradePLFloat")
                {
                    accountCurrency.TradePLFloat = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "ValueAsMargin")
                {
                    accountCurrency.PedgeAmount = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "FrozenFund")
                {
                    accountCurrency.FrozenFund = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "TotalPaidAmount")
                {
                    accountCurrency.TotalPaidAmount = decimal.Parse(nodeValue);
                    continue;
                }
                else if (nodeName == "PartialPaymentPhysicalNecessary")
                {
                    accountCurrency.PartialPaymentPhysicalNecessary = decimal.Parse(nodeValue);
                    continue;
                }
            }
        }
Exemplo n.º 14
0
 public Account(Guid id, Guid userAccountId, AccountCurrency currency)
     : this(id, userAccountId, currency, new List <AccountEntry>())
 {
 }
 public void Write(GamePacketWriter writer)
 {
     AccountCurrency.Write(writer);
     writer.Write(Unknown0);
     writer.Write(Unknown1);
 }
        private void Deposit(decimal value, decimal commission, AccountCurrency accountCurrency)
        {
            value -= commission;

            accountCurrency.Value += value;
        }
Exemplo n.º 17
0
 public SystemAccount(Guid id, AccountCurrency currency)
 {
     Id       = id;
     Currency = currency;
 }
Exemplo n.º 18
0
 public static SystemAccount FromCurrency(AccountCurrency currency)
 {
     return(_accountMap[currency]);
 }
Exemplo n.º 19
0
 public Task <decimal?> GetExchangeRate(AccountCurrency from, AccountCurrency to)
 {
     return(Task.FromResult <decimal?>(1m));
 }
        private void Withdraw(decimal value, decimal commission, AccountCurrency accountCurrency)
        {
            value += commission;

            accountCurrency.Value -= value;
        }
Exemplo n.º 21
0
 private static void Initialize(AccountCurrency item, DataRow dataRow)
 {
     item.AccountId     = (Guid)dataRow["AccountID"];
     item.CurrencyId    = (Guid)dataRow["CurrencyID"];
     item.UnclearAmount = (decimal)dataRow["UnclearAmount"];
 }
Exemplo n.º 22
0
 public void Delete(AccountCurrency entity)
 {
     Repository.Delete(entity);
 }
Exemplo n.º 23
0
 private static void Initialize(AccountCurrency item, DataRow dataRow)
 {
     item.AccountId = (Guid)dataRow["AccountID"];
     item.CurrencyId = (Guid)dataRow["CurrencyID"];
     item.UnclearAmount = (decimal)dataRow["UnclearAmount"];
 }
Exemplo n.º 24
0
 public void AddAccountCurrency(AccountCurrency accountCurrency)
 {
     accountCurrencies.Add(accountCurrency);
 }
Exemplo n.º 25
0
 // Constructors
 public DepositAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
                       long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
 }
Exemplo n.º 26
0
 // Constructors
 public DepositAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
     long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
 }
Exemplo n.º 27
0
 public void Add(AccountCurrency entity)
 {
     Repository.Add(entity);
 }