示例#1
0
        public void AddJournalEntry(JournalEntryHeader journalEntry)
        {
            var glEntry = new GeneralLedgerHeader()
            {
                Date = journalEntry.Date,
                DocumentType = Core.Domain.DocumentTypes.JournalEntry,
                Description = journalEntry.Memo,
                CreatedBy = journalEntry.CreatedBy,
                CreatedOn = journalEntry.CreatedOn,
                ModifiedBy = journalEntry.ModifiedBy,
                ModifiedOn = journalEntry.ModifiedOn,
            };

            foreach (var je in journalEntry.JournalEntryLines)
            {
                glEntry.GeneralLedgerLines.Add(new GeneralLedgerLine()
                {
                    AccountId = je.AccountId,
                    DrCr = je.DrCr,
                    Amount = je.Amount,
                    CreatedBy = journalEntry.CreatedBy,
                    CreatedOn = journalEntry.CreatedOn,
                    ModifiedBy = journalEntry.ModifiedBy,
                    ModifiedOn = journalEntry.ModifiedOn,
                });
            }

            if (ValidateGeneralLedgerEntry(glEntry))
            {
                journalEntry.GeneralLedgerHeader = glEntry;
                _journalEntryRepo.Insert(journalEntry);
            }
        }
示例#2
0
        public void UpdateJournalEntry(JournalEntryHeader journalEntry, bool posted = false)
        {
            if (posted)
            {
                journalEntry.Posted = posted;

                if (journalEntry.GeneralLedgerHeaderId == 0)
                {
                    var glEntry = new GeneralLedgerHeader()
                    {
                        Date = DateTime.Now,
                        DocumentType = Core.Domain.DocumentTypes.JournalEntry,
                        Description = journalEntry.Memo,
                    };

                    foreach (var je in journalEntry.JournalEntryLines)
                    {
                        glEntry.GeneralLedgerLines.Add(new GeneralLedgerLine()
                        {
                            Account = GetAccounts().Where(a => a.Id == je.AccountId).FirstOrDefault(),
                            AccountId = je.AccountId,
                            DrCr = je.DrCr,
                            Amount = je.Amount,
                        });
                    }

                    if (ValidateGeneralLedgerEntry(glEntry))
                    {
                        journalEntry.GeneralLedgerHeader = glEntry;
                    }
                }
            }

            _journalEntryRepo.Update(journalEntry);

            //var glEntry = _generalLedgerRepository.Table.Where(gl => gl.Id == journalEntry.GeneralLedgerHeaderId).FirstOrDefault();

            //glEntry.Date = journalEntry.Date;

            //foreach (var je in journalEntry.JournalEntryLines)
            //{
            //    if (glEntry.GeneralLedgerLines.Any(l => l.AccountId == je.AccountId))
            //    {
            //        var existingLine = glEntry.GeneralLedgerLines.Where(l => l.AccountId == je.AccountId).FirstOrDefault();
            //        existingLine.Amount = je.Amount;
            //        existingLine.DrCr = je.DrCr;
            //    }
            //    else
            //    {
            //        glEntry.GeneralLedgerLines.Add(new GeneralLedgerLine()
            //        {
            //            AccountId = je.AccountId,
            //            DrCr = je.DrCr,
            //            Amount = je.Amount,
            //        });
            //    }
            //}

            //if (ValidateGeneralLedgerEntry(glEntry) && glEntry.ValidateAccountingEquation())
            //{
            //    journalEntry.GeneralLedgerHeader = glEntry;
            //    _journalEntryRepo.Update(journalEntry);
            //}
        }
示例#3
0
        public void AddJournalEntry(JournalEntryHeader journalEntry)
        {
            journalEntry.Posted = false;

            _journalEntryRepo.Insert(journalEntry);
        }
 public ActionResult SaveJournalEntry(Models.ViewModels.Financials.AddJournalEntry model)
 {
     if(model.AddJournalEntryLines.Count < 2)
         return View(model);
     var journalEntry = new JournalEntryHeader()
     {
         Date = model.Date,
         Memo = model.Memo,
         ReferenceNo = model.ReferenceNo,
         CreatedBy = User.Identity.Name,
         CreatedOn = DateTime.Now,
         ModifiedBy = User.Identity.Name,
         ModifiedOn = DateTime.Now,
     };
     foreach(var line in model.AddJournalEntryLines)
     {
         journalEntry.JournalEntryLines.Add(new JournalEntryLine()
         {
             AccountId = line.AccountId,
             DrCr = line.DrCr,
             Amount = line.Amount,
             Memo = line.Memo
         });
     }
     _financialService.AddJournalEntry(journalEntry);
     return RedirectToAction("JournalEntries");
 }
示例#5
0
        public void UpdateJournalEntry(JournalEntryHeader journalEntry)
        {
            var glEntry = _generalLedgerRepository.Table.Where(gl => gl.Id == journalEntry.GeneralLedgerHeaderId).FirstOrDefault();
            
            glEntry.Date = journalEntry.Date;
            glEntry.ModifiedBy = journalEntry.ModifiedBy;
            glEntry.ModifiedOn = journalEntry.ModifiedOn;

            foreach (var je in journalEntry.JournalEntryLines)
            {
                if (glEntry.GeneralLedgerLines.Any(l => l.AccountId == je.AccountId))
                {
                    var existingLine = glEntry.GeneralLedgerLines.Where(l => l.AccountId == je.AccountId).FirstOrDefault();
                    existingLine.Amount = je.Amount;
                    existingLine.DrCr = je.DrCr;
                    existingLine.ModifiedBy = journalEntry.ModifiedBy;
                    existingLine.ModifiedOn = journalEntry.ModifiedOn;
                }
                else
                {
                    glEntry.GeneralLedgerLines.Add(new GeneralLedgerLine()
                    {
                        AccountId = je.AccountId,
                        DrCr = je.DrCr,
                        Amount = je.Amount,
                        CreatedBy = journalEntry.CreatedBy,
                        CreatedOn = journalEntry.CreatedOn,
                        ModifiedBy = journalEntry.ModifiedBy,
                        ModifiedOn = journalEntry.ModifiedOn,
                    });
                }
            }

            if (ValidateGeneralLedgerEntry(glEntry) && glEntry.ValidateAccountingEquation())
            {
                journalEntry.GeneralLedgerHeader = glEntry;
                _journalEntryRepo.Update(journalEntry);
            }
        }
示例#6
0
        public JournalEntryHeader CloseAccountingPeriod()
        {
            /*
            Example:

            The following example shows the closing entries based on the adjusted trial balance of Company A.

            Note

            Date	        Account	                Debit	        Credit
            1	Jan 31	    Service Revenue	        85,600
                            Income Summary		                    85,600
            2	Jan 31	    Income Summary	        77,364
                            Wages Expense		                    38,200
                            Supplies Expense	                    18,480
                            Rent Expense		                    12,000
                            Miscellaneous Expense	                3,470
                            Electricity Expense		                2,470
                            Telephone Expense		                1,494
                            Depreciation Expense	                1,100
                            Interest Expense		                150
            3	Jan 31	    Income Summary	        8,236
                            Retained Earnings		                8,236
            4	Jan 31	    Retained Earnings	    5,000
                            Dividend		                        5,000

            Notes

            1. Service revenue account is debited and its balance it credited to income summary account. If a business has other income accounts, for example gain on sale account, then the debit side of the first closing entry will also include the gain on sale account and the income summary account will be credited for the sum of all income accounts.
            2. Each expense account is credited and the income summary is debited for the sum of the balances of expense accounts. This will reduce the balance in income summary account.
            3. Income summary account is debited and retained earnings account is credited for the an amount equal to the excess of service revenue over total expenses i.e. the net balance in income summary account after posting the first two closing entries. In this case $85,600 − $77,364 = $8,236. Please note that, if the balance in income summary account is negative at this stage, this closing entry will be opposite i.e. debit to retained earnings and credit to income summary.
            4. The last closing entry transfers the dividend or withdrawal account balance to the retained earnings account. Since dividend and withdrawal accounts are contra to the retained earnings account, they reduce the balance in the retained earnings.
            */

            var glSetting = _generalLedgerSettingRepo.Table.FirstOrDefault();

            var journalEntry = new JournalEntryHeader();
            journalEntry.Memo = "Closing entries";
            journalEntry.Date = DateTime.Now;
            journalEntry.Posted = false;
            journalEntry.VoucherType = JournalVoucherTypes.ClosingEntries;

            return journalEntry;
        }