Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        public static Intuit.Ipp.Data.JournalEntry CreateJournalEntry()
        {
            var journalEntry = new Intuit.Ipp.Data.JournalEntry();

            journalEntry.Adjustment          = true;
            journalEntry.AdjustmentSpecified = true;

            journalEntry.DocNumber             = "DocNu1";
            journalEntry.TxnDate               = DateTime.UtcNow.Date;
            journalEntry.TxnDateSpecified      = true;
            journalEntry.HomeTotalAmt          = 100;
            journalEntry.HomeTotalAmtSpecified = true;
            journalEntry.TotalAmt              = 100;
            journalEntry.TotalAmtSpecified     = true;
            journalEntry.PrivateNote           = "This is the test Journal Entry";
            List <Line> lineList = new List <Line>();

            Line debitLine = new Line();

            debitLine.Description         = "That is the first line description";
            debitLine.Amount              = new Decimal(100.00);
            debitLine.AmountSpecified     = true;
            debitLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
            debitLine.DetailTypeSpecified = true;
            JournalEntryLineDetail journalEntryLineDetail = new JournalEntryLineDetail();

            journalEntryLineDetail.PostingType          = PostingTypeEnum.Debit;
            journalEntryLineDetail.PostingTypeSpecified = true;
            journalEntryLineDetail.AccountRef           = new ReferenceType()
            {
                name = "Accumulated Depreciation", Value = "36"
            };
            debitLine.AnyIntuitObject = journalEntryLineDetail;
            lineList.Add(debitLine);

            Line creditLine = new Line();

            creditLine.Description         = "That is the second line description";
            creditLine.Amount              = new Decimal(100.00);
            creditLine.AmountSpecified     = true;
            creditLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
            creditLine.DetailTypeSpecified = true;
            JournalEntryLineDetail journalEntryLineDetailCredit = new JournalEntryLineDetail();

            journalEntryLineDetailCredit.PostingType          = PostingTypeEnum.Credit;
            journalEntryLineDetailCredit.PostingTypeSpecified = true;
            journalEntryLineDetailCredit.AccountRef           = new ReferenceType()
            {
                name = "Accumulated Depreciation", Value = "36"
            };
            creditLine.AnyIntuitObject = journalEntryLineDetailCredit;
            lineList.Add(creditLine);

            journalEntry.Line = lineList.ToArray();
            return(journalEntry);
        }
Esempio n. 3
0
        /// <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);
        }
        /// <summary>
        /// creates Journal Entries by creating/updating Bank & Credit Card accounts
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JournalEntry CreateJournalEntry(ServiceContext context)
        {
            //Initializing the Dataservice object with ServiceContext
            DataService service = new DataService(context);

            //Create JournalEntry Request
            JournalEntry journalEntry = new JournalEntry();

            journalEntry.Adjustment          = true;
            journalEntry.AdjustmentSpecified = true;
            journalEntry.DocNumber           = "Tharak_DocNumber" + Guid.NewGuid().ToString("N").Substring(0, 5);
            journalEntry.TxnDate             = DateTime.UtcNow.Date;
            journalEntry.TxnDateSpecified    = true;

            // creating lines for a JournalEntry
            List <Line> lineList = new List <Line>();

            // Create debit line
            Line debitLine = new Line();

            debitLine.Description         = "April portion of rider insurance";
            debitLine.Amount              = new Decimal(100.00);
            debitLine.AmountSpecified     = true;
            debitLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
            debitLine.DetailTypeSpecified = true;

            #region Create Debit Bank Account
            //Find or create account
            Account debitAccount = new Account();
            //Find existing account by accounttype from database
            QueryService <Account> querySvc = new QueryService <Account>(context);
            Account existingAccount         = querySvc.ExecuteIdsQuery("select * from Account where AccountType='Bank'").FirstOrDefault();

            // Update Account
            if (existingAccount != null)
            {
                if (existingAccount.AccountType == AccountTypeEnum.Bank && existingAccount.Classification == AccountClassificationEnum.Asset && existingAccount.status != EntityStatusEnum.SyncError)
                {
                    debitAccount = existingAccount;
                }
            }
            // Create new Account if debit existing account not found
            if (debitAccount == null)
            {
                debitAccount      = new Account();
                debitAccount.Name = "Tharak_" + Guid.NewGuid().ToString("N");
                debitAccount.FullyQualifiedName      = debitAccount.Name;
                debitAccount.Classification          = AccountClassificationEnum.Asset;
                debitAccount.ClassificationSpecified = true;
                debitAccount.AccountType             = AccountTypeEnum.Bank;
                debitAccount.AccountTypeSpecified    = true;
                debitAccount.CurrencyRef             = new ReferenceType()
                {
                    name  = "United States Dollar",
                    Value = "USD"
                };

                // Calling create account service api call
                Account addedAccount = service.Add <Account>(debitAccount);
                debitAccount = addedAccount;
            }
            #endregion

            //Add JE debit line
            JournalEntryLineDetail journalEntryLineDetail = new JournalEntryLineDetail();
            journalEntryLineDetail.PostingType          = PostingTypeEnum.Debit;
            journalEntryLineDetail.PostingTypeSpecified = true;
            journalEntryLineDetail.AccountRef           = new ReferenceType()
            {
                name = debitAccount.Name, Value = debitAccount.Id
            };
            debitLine.AnyIntuitObject = journalEntryLineDetail;
            lineList.Add(debitLine);

            #region Create CreditCard Account
            // Create Credit Card line
            Line creditLine = new Line();
            creditLine.Description         = "April portion of rider insurance";
            creditLine.Amount              = new Decimal(100.00);
            creditLine.AmountSpecified     = true;
            creditLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
            creditLine.DetailTypeSpecified = true;

            //Find or create account
            Account creditAccount = null;
            //Find existing account by accounttype
            querySvc        = new QueryService <Account>(context);
            existingAccount = null;
            existingAccount = querySvc.ExecuteIdsQuery("select * from Account where AccountType='Credit Card'").FirstOrDefault();

            if (existingAccount != null)
            {
                if (existingAccount.AccountType == AccountTypeEnum.CreditCard && existingAccount.Classification == AccountClassificationEnum.Liability && existingAccount.status != EntityStatusEnum.SyncError)
                {
                    //Existing account
                    creditAccount = existingAccount;
                }
            }
            // Create new Credit Card Account if existing account not found
            if (creditAccount == null)
            {
                creditAccount      = new Account();
                creditAccount.Name = "Tharak_" + Guid.NewGuid().ToString("N");
                creditAccount.FullyQualifiedName      = creditAccount.Name;
                creditAccount.Classification          = AccountClassificationEnum.Liability;
                creditAccount.ClassificationSpecified = true;
                creditAccount.AccountType             = AccountTypeEnum.CreditCard;
                creditAccount.AccountTypeSpecified    = true;
                creditAccount.CurrencyRef             = new ReferenceType()
                {
                    name  = "United States Dollar",
                    Value = "USD"
                };

                //Creating new Credit Card account by calling API call
                Account addedAccount = service.Add <Account>(creditAccount);
                creditAccount = addedAccount;
            }
            #endregion

            //Add JE credit line
            JournalEntryLineDetail journalEntryLineDetailCredit = new JournalEntryLineDetail();
            journalEntryLineDetailCredit.PostingType          = PostingTypeEnum.Credit;
            journalEntryLineDetailCredit.PostingTypeSpecified = true;
            journalEntryLineDetailCredit.AccountRef           = new ReferenceType()
            {
                name = creditAccount.Name, Value = creditAccount.Id
            };
            creditLine.AnyIntuitObject = journalEntryLineDetailCredit;
            lineList.Add(creditLine);

            // Added both Debit & Credit Lines to journal
            journalEntry.Line = lineList.ToArray();

            //Return the journal request
            return(journalEntry);
        }
Esempio n. 5
0
        /// <summary>
        /// CReate Journal Entry
        /// </summary>
        /// <param name="creditDT"></param>
        /// <param name="debitDT"></param>
        /// <param name="transDate"></param>
        public void CreateJournalEntry(DataTable creditDT, DataTable debitDT, DateTime transDate)
        {
            JournalEntry journalEntry = new JournalEntry();

            journalEntry.Adjustment          = true;
            journalEntry.AdjustmentSpecified = true;

            journalEntry.DocNumber = "DocNumber" + Helper.GetGuid().Substring(0, 5);
            if (transDate == null)
            {
                journalEntry.TxnDate = DateTime.UtcNow.Date;
            }
            else
            {
                journalEntry.TxnDate = transDate;
            }
            journalEntry.TxnDateSpecified = true;

            List <Line> lineList = new List <Line>();

            foreach (DataRow creditRow in creditDT.Rows)
            {
                Line creditLine = new Line();
                creditLine.Description         = ((string)creditRow["Memo"]);
                creditLine.Amount              = decimal.Round((decimal)creditRow["Amount"], 2);
                creditLine.AmountSpecified     = true;
                creditLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
                creditLine.DetailTypeSpecified = true;
                JournalEntryLineDetail journalEntryLineDetailCredit = new JournalEntryLineDetail();
                journalEntryLineDetailCredit.PostingType          = PostingTypeEnum.Credit;
                journalEntryLineDetailCredit.PostingTypeSpecified = true;
                //Account assetAccount = Helper.FindOrAddAccount(servicecontext, AccountTypeEnum.OtherCurrentAsset, AccountClassificationEnum.Asset);
                journalEntryLineDetailCredit.AccountRef = new ReferenceType()
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
                    name = (string)creditRow["GLAccount"]
                           //Value = assetAccount.Id
                };
                journalEntryLineDetailCredit.ClassRef = new ReferenceType()
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Class),
                    name = ((string)creditRow["ClassName"])
                };
                creditLine.AnyIntuitObject = journalEntryLineDetailCredit;
                lineList.Add(creditLine);
            }
            foreach (DataRow debitRow in debitDT.Rows)
            {
                Line debitLine = new Line();
                debitLine.Description         = ((string)debitRow["Memo"]);
                debitLine.Amount              = decimal.Round((decimal)debitRow["Amount"], 2);
                debitLine.AmountSpecified     = true;
                debitLine.DetailType          = LineDetailTypeEnum.JournalEntryLineDetail;
                debitLine.DetailTypeSpecified = true;
                JournalEntryLineDetail journalEntryLineDetail = new JournalEntryLineDetail();
                journalEntryLineDetail.PostingType          = PostingTypeEnum.Debit;
                journalEntryLineDetail.PostingTypeSpecified = true;
                Account expenseAccount = Helper.FindOrAddAccount(servicecontext, AccountTypeEnum.Expense, AccountClassificationEnum.Expense);
                journalEntryLineDetail.AccountRef = new ReferenceType()
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
                    name = (string)debitRow["GLAccount"]
                           //Value = expenseAccount.Id
                };
                journalEntryLineDetail.ClassRef = new ReferenceType()
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Class),
                    name = ((string)debitRow["ClassName"])
                };
                debitLine.AnyIntuitObject = journalEntryLineDetail;
                lineList.Add(debitLine);
            }

            journalEntry.Line = lineList.ToArray();
            services.Add(journalEntry);
        }