/// <summary> /// Converts JournalEntry to StandardAccountingTransactionDTO object /// </summary> /// <param name="JournalEntry"></param> /// <returns>JournalEntry</returns> public StandardAccountingTransactionDTO GetAccountingTransactionData(Intuit.Ipp.Data.JournalEntry journalEntry) { var curFinLineDTOList = new List <FinancialLineDTO>(); foreach (var curLine in journalEntry.Line) { var curFinLineToAdd = new FinancialLineDTO(); //The way to extract Journal Entry Line Detail type object from the Line JournalEntryLineDetail curJournalEntryLineDetail = (JournalEntryLineDetail)curLine.AnyIntuitObject; //Add Debit or Credit type curFinLineToAdd.DebitOrCredit = curJournalEntryLineDetail.PostingType.ToString(); //Add Amount curFinLineToAdd.Amount = curLine.Amount.ToString(); //Add Account Name curFinLineToAdd.AccountName = curJournalEntryLineDetail.AccountRef.name; //Add Account Id curFinLineToAdd.AccountId = curJournalEntryLineDetail.AccountRef.Value; //Add Description curFinLineToAdd.Description = curLine.Description; //Add the prepared line to the list curFinLineDTOList.Add(curFinLineToAdd); } var curAccountTransactionDTO = new StandardAccountingTransactionDTO() { Name = journalEntry.DocNumber, TransactionDate = journalEntry.TxnDate, FinancialLines = curFinLineDTOList, Memo = journalEntry.PrivateNote }; return(curAccountTransactionDTO); }
private static void ValidateFinancialLineDTO(FinancialLineDTO finLineDTO) { if (finLineDTO.AccountId == null || finLineDTO.AccountName == null) { throw new Exception("Some Account Data is Missing"); } if (finLineDTO.Amount == null) { throw new Exception("Amount is missing"); } if (finLineDTO.DebitOrCredit == null) { throw new Exception("Debit/Credit information is missing"); } }
public static StandardAccountingTransactionCM GetAccountingTransactionCM() { var curFinLineDTOList = new List <FinancialLineDTO>(); var curFirstLineDTO = new FinancialLineDTO() { Amount = "100", AccountId = "1", AccountName = "Account-A", DebitOrCredit = "Debit", Description = "Move money to Accout-B" }; var curSecondLineDTO = new FinancialLineDTO() { Amount = "100", AccountId = "2", AccountName = "Account-B", DebitOrCredit = "Credit", Description = "Move money from Accout-A" }; curFinLineDTOList.Add(curFirstLineDTO); curFinLineDTOList.Add(curSecondLineDTO); var curAccoutingTransactionDTO = new StandardAccountingTransactionDTO() { Memo = "That is the test crate", FinancialLines = curFinLineDTOList, Name = "Code1", TransactionDate = DateTime.Parse("2015-12-15") }; var curCrate = new StandardAccountingTransactionCM() { AccountingTransactions = new List <StandardAccountingTransactionDTO>() { curAccoutingTransactionDTO } }; return(curCrate); }