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); } }
public new int CommitJournalEntries(string sDescription, List<QBJournalEntryLine> jelEntries) { if (jelEntries == null) return 0; if (jelEntries.Count() == 0) return 0; JournalEntryLine[] entries = new JournalEntryLine[jelEntries.Count()]; for (int iX = 0; iX < jelEntries.Count(); iX++) { entries[iX] = TranslateJournalEntry(jelEntries[iX], jelEntries[iX].bCredit); } JournalEntry jeNew = new JournalEntry(); JournalEntryHeader jeh = new JournalEntryHeader(); jeh.Note = sDescription; jeNew.Header = jeh; jeNew.Line = entries; JournalEntry jeMade = getDataService().Add(jeNew) as JournalEntry; if (jeMade.Id.Value.ToInt() > 0 && jeMade.SyncToken.ToInt() > -1) return jeMade.Id.Value.ToInt(); else return 0; }
public void UpdateJournalEntry(JournalEntryHeader journalEntry, bool posted = false) { if (posted) { journalEntry.Posted = posted; if (journalEntry.GeneralLedgerHeaderId == null || journalEntry.GeneralLedgerHeaderId == 0) { var glEntry = new GeneralLedgerHeader() { Date = DateTime.Now, DocumentType = 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); }
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")); }
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, VoucherType = model.JournalVoucherType }; 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")); }
public JournalEntryHeader SaveJournalEntry(JournalEntryHeader journalEntry) { var dbObject = GetJournalEntry(journalEntry.Id); #region UPDATE if (dbObject != null) { dbObject.Date = journalEntry.Date; dbObject.Memo = journalEntry.Memo; dbObject.ReferenceNo = journalEntry.ReferenceNo; dbObject.IsActive = journalEntry.IsActive; var toUpdateIds = dbObject.JournalEntryLines.Select(c => c.Id).ToList(); foreach (var lineItem in journalEntry.JournalEntryLines) { var existingLineItem = dbObject.JournalEntryLines.FirstOrDefault(c => c.Id == lineItem.Id); if (existingLineItem != null) { existingLineItem.AccountId = lineItem.AccountId; existingLineItem.DrCr = lineItem.DrCr; existingLineItem.Memo = lineItem.Memo; existingLineItem.Amount = lineItem.Amount; existingLineItem.IsActive = lineItem.IsActive; toUpdateIds.Remove(existingLineItem.Id); } else { dbObject.JournalEntryLines.Add(new JournalEntryLine() { AccountId = lineItem.AccountId, DrCr = lineItem.DrCr, Memo = lineItem.Memo, Amount = lineItem.Amount, }); } } _journalEntryRepo.Update(dbObject); journalEntry = dbObject; } #endregion #region INSERT else { _journalEntryRepo.Insert(journalEntry); } #endregion return(journalEntry); }
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); }
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); } }
public int CommitJournalEntries(string sDescription, List <QBJournalEntryLine> jelEntries) { if (jelEntries == null) { return(0); } if (jelEntries.Count() == 0) { return(0); } JournalEntryLine[] entries = new JournalEntryLine[jelEntries.Count()]; for (int iX = 0; iX < jelEntries.Count(); iX++) { entries[iX] = TranslateJournalEntry(jelEntries[iX], jelEntries[iX].bCredit); } JournalEntry jeNew = new JournalEntry(); JournalEntryHeader jeh = new JournalEntryHeader(); jeh.Note = sDescription; jeNew.Header = jeh; jeNew.Line = entries; JournalEntry jeMade = getDataService().Add(jeNew) as JournalEntry; if (jeMade.Id.Value.ToInt() > 0 && jeMade.SyncToken.ToInt() > -1) { return(jeMade.Id.Value.ToInt()); } else { return(0); } }
public void AddJournalEntry(JournalEntryHeader journalEntry) { journalEntry.Posted = false; _journalEntryRepo.Insert(journalEntry); }
public async Task <IActionResult> SaveJournal([FromBody] JournalEntryHeaderDto journalEntryDto) { var anyDuplicate = journalEntryDto.Lines.GroupBy(x => x.AccountId).Any(g => g.Count() > 1); if (anyDuplicate) { return(BadRequest("One or more journal entry lines has duplicate account.")); } var isNew = journalEntryDto.Id == 0; JournalEntryHeader journalEntry = null; if (isNew) { //inserting journalEntry = new JournalEntryHeader(); } else { //editing journalEntry = await _db.JournalEntryHeaders .Where(j => j.Id == journalEntryDto.Id) .Include(j => j.JournalEntryLines) .FirstOrDefaultAsync(); //get all oldLines var oldLines = await _db.JournalEntryLines .Where(l => l.JournalEntryHeaderId == journalEntryDto.Id) .ToListAsync(); //Remove these lines _db.JournalEntryLines.RemoveRange(oldLines); //Save to db await _db.SaveChangesAsync(); } //mapping - master journalEntry.Date = journalEntryDto.Date; journalEntry.ReferenceNo = journalEntryDto.ReferenceNo; journalEntry.Memo = journalEntryDto.Memo; //lines foreach (var line in journalEntryDto.Lines) { var journalLine = new JournalEntryLine { AccountId = line.AccountId, DrCr = (DrOrCrSide)line.DrCrId, Amount = line.Amount, Memo = line.Memo }; journalEntry.JournalEntryLines.Add(journalLine); } //save to db if (isNew) { _db.JournalEntryHeaders.Add(journalEntry); } else { _db.JournalEntryHeaders.Update(journalEntry); } await _db.SaveChangesAsync(); return(Ok(journalEntry)); }
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); //} }
public static FinancialJournal.JournalModel ToModel(this JournalEntryHeader entity) { return(entity.MapTo <JournalEntryHeader, FinancialJournal.JournalModel>()); }