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); }
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(); } }
// 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; }
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); }
// 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"); } }
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); }
// 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"); } }
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; } } }
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; }
public SystemAccount(Guid id, AccountCurrency currency) { Id = id; Currency = currency; }
public static SystemAccount FromCurrency(AccountCurrency currency) { return(_accountMap[currency]); }
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; }
private static void Initialize(AccountCurrency item, DataRow dataRow) { item.AccountId = (Guid)dataRow["AccountID"]; item.CurrencyId = (Guid)dataRow["CurrencyID"]; item.UnclearAmount = (decimal)dataRow["UnclearAmount"]; }
public void Delete(AccountCurrency entity) { Repository.Delete(entity); }
public void AddAccountCurrency(AccountCurrency accountCurrency) { accountCurrencies.Add(accountCurrency); }
// Constructors public DepositAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner, long accountNumber) : base(type, currency, period, owner, accountNumber) { }
public void Add(AccountCurrency entity) { Repository.Add(entity); }