private AccountToFrom GetFromToAccount(Transaction element) { Account fromAccount = null; // Debiting Account Account toAccount = null; // Crediting Account var au = new AccountUtils(); switch (element.Side.ToLowerInvariant()) { case "debit": { if (element.Symbol.Equals("ZZ_INVESTOR_WITHDRAWALS")) { var fromTags = new List <Tag> { Tag.Find("CustodianCode") }; var toTags = new List <Tag> { Tag.Find("CustodianCode") }; fromAccount = au.CreateAccount(AccountType.Find("CONTRIBUTED CAPITAL"), fromTags, element); toAccount = au.CreateAccount(AccountType.Find("Settled Cash"), toTags, element); } else if (element.Symbol.Equals("ZZ_CASH_DIVIDENDS")) { var fromTags = new List <Tag> { Tag.Find("CustodianCode") }; var toTags = new List <Tag> { Tag.Find("CustodianCode") }; fromAccount = au.CreateAccount(AccountType.Find("DIVIDENDS RECEIVABLE"), fromTags, element); toAccount = au.CreateAccount(AccountType.Find("DIVIDEND INCOME"), toTags, element); } else { var symbol = element.Symbol; symbol = _codeMap.ContainsKey(symbol) ? _codeMap[symbol] : symbol; var paidAccount = AccountType.Find("Expenses Paid"); var payableAccount = AccountType.Find("ACCRUED EXPENSES"); fromAccount = new AccountUtils().CreateAccount(paidAccount, symbol, element); toAccount = new AccountUtils().CreateAccount(payableAccount, symbol + " Payable", element); } break; } case "credit": // Contribution if (element.Symbol.Equals("ZZ_INVESTOR_CONTRIBUTIONS")) { var fromTags = new List <Tag> { Tag.Find("CustodianCode") }; var toTags = new List <Tag> { Tag.Find("CustodianCode") }; fromAccount = new AccountUtils().CreateAccount(AccountType.Find("Settled Cash"), fromTags, element); toAccount = new AccountUtils().CreateAccount(AccountType.Find("CONTRIBUTED CAPITAL"), toTags, element); } else if (element.Symbol.Equals("ZZ_CASH_DIVIDENDS")) { var fromTags = new List <Tag> { Tag.Find("CustodianCode") }; var toTags = new List <Tag> { Tag.Find("CustodianCode") }; fromAccount = new AccountUtils().CreateAccount(AccountType.Find("DIVIDENDS RECEIVABLE"), fromTags, element); toAccount = new AccountUtils().CreateAccount(AccountType.Find("DIVIDEND INCOME"), toTags, element); } else // Default Action { var symbol = element.Symbol; symbol = _codeMap.ContainsKey(symbol) ? _codeMap[symbol] : symbol; var paidAccount = AccountType.Find("Expenses Paid"); var payableAccount = AccountType.Find("ACCRUED EXPENSES"); fromAccount = new AccountUtils().CreateAccount(paidAccount, symbol, element); toAccount = new AccountUtils().CreateAccount(payableAccount, symbol + " Payable", element); } break; } return(new AccountToFrom { From = fromAccount, To = toAccount }); }