public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId) { var transaction = AccountTransaction.Create(template, accountTypeId, accountId); AccountTransactions.Add(transaction); return(transaction); }
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 AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId, Account account, decimal amount, decimal exchangeRate) { var transaction = AccountTransaction.Create(template, accountTypeId, accountId); transaction.UpdateAccounts(account.AccountTypeId, account.Id); transaction.UpdateAmount(amount, exchangeRate); AccountTransactions.Add(transaction); return(transaction); }
public AccountTransactionDocument CreateDocument(Account account, string description, decimal amount, decimal exchangeRate, IList <Account> accounts) { // <pex> if (account == null) { throw new ArgumentNullException("account"); } if (account.AccountTypeId != MasterAccountTypeId) { throw new ArgumentException("Account Type should match Master Account Type"); } // </pex> var result = new AccountTransactionDocument { Name = Name }; foreach (var accountTransactionType in TransactionTypes) { var transaction = AccountTransaction.Create(accountTransactionType); transaction.Name = description; transaction.UpdateAmount(amount, exchangeRate); transaction.UpdateAccounts(MasterAccountTypeId, account.Id); if (accounts != null && accounts.Count > 0) { if (transaction.SourceAccountTypeId != MasterAccountTypeId && transaction.SourceTransactionValue.AccountId == 0) { Account ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.SourceAccountTypeId); if (ac != null) { transaction.SetSourceAccount(ac.AccountTypeId, ac.Id); } } if (transaction.TargetAccountTypeId != MasterAccountTypeId && transaction.TargetTransactionValue.AccountId == 0) { Account ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.TargetAccountTypeId); if (ac != null) { transaction.SetTargetAccount(ac.AccountTypeId, ac.Id); } } } result.AccountTransactions.Add(transaction); } return(result); }
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); }