public bool AddTransaction(ITransactionInterface oTrans) { /*make sure the transaction is allowed * if withdrawal/transfer from customers account, the amount of availble funds must cover the amount of the transaction * if puchase of securites, the amount of availble funds must cover the amount of the transaction */ try { List <IMoney> AvailableFunds = GetAvailableFunds().Where(t => t.CurrencyCode.Equals(oTrans.DebitAmount.CurrencyCode)).ToList(); IMoney AvailableFundsCurrency = ImperaturGlobal.GetMoney(0m, oTrans.CreditAmount.CurrencyCode); if (AvailableFunds.Where(a => a.CurrencyCode.Equals(oTrans.CreditAmount.CurrencyCode)).Count() > 0) { AvailableFundsCurrency = AvailableFunds.Where(a => a.CurrencyCode.Equals(oTrans.CreditAmount.CurrencyCode)).First(); } if ((oTrans.TransactionType == TransactionType.Withdrawal || oTrans.TransactionType == TransactionType.Transfer || oTrans.TransactionType == TransactionType.Buy) && oTrans.DebitAccount == this.Identifier && oTrans.DebitAmount.Amount > AvailableFundsCurrency.Amount ) { //abort transaction LastErrorMessage = "Not enough available funds to cover this transaction!"; throw new Exception("Not enough available funds to cover this transaction!"); } m_oTransactions.Add(oTrans); } catch (Exception ex) { ImperaturGlobal.GetLog().Error(string.Format("[Account.AddTransaction] Couldn't create transaction on account {0}", this.Identifier), ex); LastErrorMessage = ex.Message; } return(true); }
public bool AddTransactionToAccount(Guid Identifier, ITransactionInterface NewTransaction) { m_oAccounts.Single(a => a.Identifier.Equals(Identifier)).AddTransaction(NewTransaction); return(true); }