/// <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); }
public static void ValidateAccountingTransation(StandardAccountingTransactionDTO curAccountingTransactionDtoTransactionDTO) { if (curAccountingTransactionDtoTransactionDTO == null) { throw new ArgumentNullException("No StandardAccountingTransationDTO provided"); } if (curAccountingTransactionDtoTransactionDTO.FinancialLines == null || curAccountingTransactionDtoTransactionDTO.FinancialLines.Count == 0 || curAccountingTransactionDtoTransactionDTO.TransactionDate == null) { throw new Exception("No Financial Lines or Transaction Date Provided"); } foreach (var curFinLineDTO in curAccountingTransactionDtoTransactionDTO.FinancialLines) { ValidateFinancialLineDTO(curFinLineDTO); } }
/// <summary> /// Creates Journal Entry in the developers account in Sandbox in Intuit https://sandbox.qbo.intuit.com/app/journal /// </summary> public void Create( StandardAccountingTransactionDTO curAccountingTransactionDto, AuthorizationToken authToken, IHubCommunicator hubCommunicator) { var curJournalEntry = CreateQbJournalEntry(curAccountingTransactionDto); var curDataService = _serviceWorker.GetDataService(authToken, hubCommunicator); try { curDataService.Add(curJournalEntry); } catch (Exception curException) { throw curException; } }
/// <summary> /// Converts StandardAccountingTransactionDTO to JournalEntry object /// </summary> /// <param name="StandardAccountingTransactionCM"></param> /// <returns>JournalEntry</returns> public Intuit.Ipp.Data.JournalEntry CreateQbJournalEntry(StandardAccountingTransactionDTO curAccountTransactionDTO) { //Pack Standard Accounting Transaction DTO with data var curJournalEntry = new Intuit.Ipp.Data.JournalEntry { DocNumber = curAccountTransactionDTO.Name, TxnDate = curAccountTransactionDTO.TransactionDate, PrivateNote = curAccountTransactionDTO.Memo }; var curFinancialLines = curAccountTransactionDTO.FinancialLines; var curTransactionList = new List <Line>(); foreach (var curTransaction in curFinancialLines) { var curLineToAdd = new Line { Description = curTransaction.Description, Id = curTransaction.AccountId }; //Add Debit or Credit type var curJournalEntryLineDetail = new JournalEntryLineDetail { PostingType = ParseEnum <PostingTypeEnum>(curTransaction.DebitOrCredit) }; //Add AccountRef and add name var curAccountRef = new ReferenceType { name = curTransaction.AccountName }; curJournalEntryLineDetail.AccountRef = curAccountRef; curLineToAdd.AnyIntuitObject = curJournalEntryLineDetail; //Add Amount curLineToAdd.Amount = decimal.Parse(curTransaction.Amount); //Pack the line to the array curTransactionList.Add(curLineToAdd); } Line[] curLineArray = curTransactionList.ToArray(); curJournalEntry.Line = curLineArray; return(curJournalEntry); }
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); }