public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable <AccountData> accountDataList) { var transaction = AccountTransaction.Create(template, accountDataList); AccountTransactions.Add(transaction); return(transaction); }
public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable <AccountData> accountDataList, decimal amount, decimal exchangeRate) { var transaction = AccountTransaction.Create(template, accountDataList); transaction.UpdateAmount(amount, exchangeRate); AccountTransactions.Add(transaction); return(transaction); }
public AccountTransactionDocument CreateDocument(Account account, string description, decimal amount, decimal exchangeRate, IList <AccountData> accounts, IList <ForeignCurrency> currencies) { var result = new AccountTransactionDocument { Name = Name, DocumentTypeId = Id }; foreach (var accountTransactionType in TransactionTypes) { var transaction = AccountTransaction.Create(accountTransactionType); var amountRate = GetExchangeRate(accountTransactionType.ForeignCurrencyId, currencies); amount = amount * amountRate; transaction.UpdateAmount(amount, exchangeRate, accounts); transaction.UpdateAccount(MasterAccountTypeId, account.Id); if (accounts != null && accounts.Count > 0) { if (transaction.SourceAccountTypeId != MasterAccountTypeId && transaction.SourceTransactionValue.AccountId == 0) { var ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.SourceAccountTypeId); if (ac != null) { transaction.SetSourceAccount(ac.AccountTypeId, ac.AccountId); } } if (transaction.TargetAccountTypeId != MasterAccountTypeId && transaction.TargetTransactionValue.AccountId == 0) { var ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.TargetAccountTypeId); if (ac != null) { transaction.SetTargetAccount(ac.AccountTypeId, ac.AccountId); } } } if (!string.IsNullOrEmpty(description)) { transaction.UpdateDescription(description); } result.AccountTransactions.Add(transaction); } return(result); }