예제 #1
0
        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;
        }
예제 #2
0
        public JournalEntryLine TranslateJournalEntry(QBJournalEntryLine qbjel, bool bCredit)
        {
            JournalEntryLine jel = new JournalEntryLine();

            jel.Desc            = qbjel.sDescrition;
            jel.Amount          = qbjel.dAmount;
            jel.AmountSpecified = true;
            jel.AccountId       = new IdType()
            {
                Value = qbjel.sAccountID
            };

            if (bCredit)
            {
                jel.PostingType = PostingTypeEnum.Credit;
            }
            else
            {
                jel.PostingType = PostingTypeEnum.Debit;
            }

            jel.PostingTypeSpecified = true;

            return(jel);
        }
예제 #3
0
        public JournalEntryLine TranslateJournalEntry(QBJournalEntryLine qbjel, bool bCredit)
        {
            Account acct = GetAccountByID(qbjel.sAccountID);

            JournalEntryLine jel = new JournalEntryLine();

            jel.Desc            = qbjel.sDescrition;
            jel.Amount          = qbjel.dAmount;
            jel.AmountSpecified = true;
            jel.AccountName     = acct.Name;

            if (bCredit)
            {
                jel.PostingType = PostingTypeEnum.Credit;
            }
            else
            {
                jel.PostingType = PostingTypeEnum.Debit;
            }

            jel.PostingTypeSpecified = true;
            jel.AccountTypeSpecified = true;

            return(jel);
        }
예제 #4
0
        private List <JournalEntryLine> GenerateLineItems(List <GLBatchTotals> transactionItems)
        {
            var returnList = new List <JournalEntryLine>();

            foreach (var transaction in transactionItems)
            {
                var creditLine = new JournalEntryLine()
                {
                    CompanyNumber      = transaction.CompanyNumber,
                    RegionNumber       = transaction.RegionNumber,
                    SuperFundNumber    = transaction.SuperFundNumber,
                    FundNumber         = transaction.FundNumber,
                    LocationNumber     = transaction.LocationNumber,
                    CostCenterNumber   = transaction.CostCenterNumber,
                    DepartmentNumber   = transaction.DepartmentNumber,
                    AccountNumber      = transaction.CreditAccountNumber,
                    AccountSub         = transaction.AccountSub,
                    Amount             = transaction.Amount * -1,
                    Project            = transaction.Project,
                    JournalNumber      = transaction.JournalNumber,
                    JournalDescription = transaction.JournalDescription,
                    Date = transaction.Date,
                    Note = transaction.Note
                };

                returnList.Add(creditLine);

                var debitLine = new JournalEntryLine()
                {
                    CompanyNumber      = transaction.CompanyNumber,
                    RegionNumber       = transaction.RegionNumber,
                    SuperFundNumber    = transaction.SuperFundNumber,
                    FundNumber         = transaction.FundNumber,
                    LocationNumber     = transaction.LocationNumber,
                    CostCenterNumber   = transaction.CostCenterNumber,
                    DepartmentNumber   = "0",
                    AccountNumber      = transaction.DebitAccountNumber,
                    AccountSub         = transaction.AccountSub,
                    Amount             = transaction.Amount,
                    Project            = transaction.Project,
                    JournalNumber      = transaction.JournalNumber,
                    JournalDescription = transaction.JournalDescription,
                    Date = transaction.Date,
                    Note = transaction.Note
                };

                returnList.Add(debitLine);
            }

            return(returnList);
        }
예제 #5
0
        public JournalEntryLine TranslateJournalEntry(QBJournalEntryLine qbjel, bool bCredit)
        {
            JournalEntryLine jel = new JournalEntryLine();
            jel.Desc = qbjel.sDescrition;
            jel.Amount = qbjel.dAmount;
            jel.AmountSpecified = true;
            jel.AccountId = new IdType() { Value = qbjel.sAccountID };

            if (bCredit) jel.PostingType = PostingTypeEnum.Credit;
            else jel.PostingType = PostingTypeEnum.Debit;

            jel.PostingTypeSpecified = true;

            return jel;
        }
        public ActionResult SaveJournalEntry(AddJournalEntry model)
        {
            if (model.AddJournalEntryLines.Count < 2)
            {
                return(View(model));
            }
            var journalEntry = new JournalEntryLine()
            {
                Date        = model.Date,
                Memo        = model.Memo,
                ReferenceNo = model.ReferenceNo,
            };

            _financialService.AddJournalEntry(journalEntry);
            return(RedirectToAction("JournalEntries"));
        }
        public ActionResult AddJournalEntry(AddJournalEntry model)
        {
            JournalEntryLine journal = new JournalEntryLine()
            {
                AccountId     = model.AccountId,
                ReferenceNo   = model.ReferenceNo,
                DrCr          = model.DrCr,
                Date          = model.Date,
                Amount        = model.Amount,
                Memo          = model.Memo,
                SubCategoryId = model.SubCategoryId
            };

            _financialService.AddJournalEntry(journal);

            return(RedirectToAction("JournalEntries"));
        }
예제 #8
0
        //public void ListAccountSubCategory()
        //{
        //    _accountSubCategory.Table.ToList();
        //}
        //public void GetSubCategoryById(object id)
        //{
        //    _accountSubCategory.GetById(id);
        //}
        public void UpdateJournalEntry(JournalEntryLine journalEntry)
        {
            //if (posted)
            //{
            //    journalEntry.Posted = posted;


            var glEntry = new JournalEntryLine()
            {
                Date = DateTime.Now
            };


            //}

            _journalEntryLineRepo.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);
            //}
        }
예제 #9
0
        public async Task <IActionResult> GetJournalEntryLineById(Int64 JournalEntryLineId)
        {
            JournalEntryLine Items = new JournalEntryLine();

            try
            {
                Items = await _context.JournalEntryLine.Where(q => q.JournalEntryLineId == JournalEntryLineId).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
예제 #10
0
        public async Task <ActionResult <JournalEntryLine> > Insert([FromBody] JournalEntryLine _JournalEntryLine)
        {
            JournalEntryLine _JournalEntryLineq = new JournalEntryLine();

            try
            {
                _JournalEntryLineq = _JournalEntryLine;
                _context.JournalEntryLine.Add(_JournalEntryLineq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_JournalEntryLineq)));
        }
예제 #11
0
        public async Task <IActionResult> GetJournalEntryLineByDate(DateTime Date)
        {
            string           fecha = Date.ToString("yyyy-MM-dd");
            JournalEntryLine Items = new JournalEntryLine();

            try
            {
                Items = await _context.JournalEntryLine.Where(q => q.CreatedDate == Convert.ToDateTime(fecha)).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
예제 #12
0
        public JournalEntryLine TranslateJournalEntry(QBJournalEntryLine qbjel, bool bCredit)
        {
            Account acct = GetAccountByID(qbjel.sAccountID);

            JournalEntryLine jel = new JournalEntryLine();
            jel.Desc = qbjel.sDescrition;
            jel.Amount = qbjel.dAmount;
            jel.AmountSpecified = true;
            jel.AccountName = acct.Name;

            if( bCredit ) jel.PostingType = PostingTypeEnum.Credit;
            else jel.PostingType = PostingTypeEnum.Debit;

            jel.PostingTypeSpecified = true;
            jel.AccountTypeSpecified = true;

            return jel;
        }
예제 #13
0
        public JournalEntryLine 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 journalEntry = new JournalEntryLine();

            journalEntry.Memo   = "Closing entries";
            journalEntry.Date   = DateTime.Now;
            journalEntry.Posted = false;


            return(journalEntry);
        }
예제 #14
0
        public async Task <IActionResult> Delete([FromBody] JournalEntryLine _JournalEntryLine)
        {
            JournalEntryLine _JournalEntryLineq = new JournalEntryLine();

            try
            {
                _JournalEntryLineq = _context.JournalEntryLine
                                     .Where(x => x.JournalEntryLineId == (Int64)_JournalEntryLine.JournalEntryLineId)
                                     .FirstOrDefault();

                _context.JournalEntryLine.Remove(_JournalEntryLineq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_JournalEntryLineq)));
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
        public IActionResult JournalEntry(int id)
        {
            var je = _financialService.GetJournalEntry(id);

            var journalEntryDto = new JournalEntry()
            {
                Id          = je.Id,
                JournalDate = je.Date,
                Memo        = je.Memo,
                ReferenceNo = je.ReferenceNo,
                VoucherType = (int)je.VoucherType.GetValueOrDefault(),
                Posted      = je.Posted
            };

            foreach (var line in je.JournalEntryLines)
            {
                var lineDto = new JournalEntryLine()
                {
                    Id        = line.Id,
                    AccountId = line.AccountId,
                    Amount    = line.Amount,
                    DrCr      = (int)line.DrCr,
                    Memo      = line.Memo
                };

                journalEntryDto.JournalEntryLines.Add(lineDto);
            }

            // is this journal entry ready for posting?
            if (!journalEntryDto.Posted.GetValueOrDefault() &&
                journalEntryDto.JournalEntryLines.Count >= 2 &&
                (journalEntryDto.debitAmount == journalEntryDto.creditAmount))
            {
                journalEntryDto.ReadyForPosting = true;
            }

            return(new ObjectResult(journalEntryDto));
        }
예제 #17
0
        public async Task <ActionResult <JournalEntryLine> > Update([FromBody] JournalEntryLine _JournalEntryLine)
        {
            JournalEntryLine _JournalEntryLineq = _JournalEntryLine;

            try
            {
                _JournalEntryLineq = await(from c in _context.JournalEntryLine
                                           .Where(q => q.JournalEntryLineId == _JournalEntryLine.JournalEntryLineId)
                                           select c
                                           ).FirstOrDefaultAsync();

                _context.Entry(_JournalEntryLineq).CurrentValues.SetValues((_JournalEntryLine));

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_JournalEntryLineq)));
        }
예제 #18
0
        public IActionResult JournalEntries()
        {
            var journalEntries    = _financialService.GetJournalEntries();
            var journalEntriesDto = new List <JournalEntry>();

            foreach (var je in journalEntries)
            {
                var journalEntryDto = new JournalEntry()
                {
                    Id          = je.Id,
                    JournalDate = je.Date,
                    Memo        = je.Memo,
                    ReferenceNo = je.ReferenceNo,
                    VoucherType = (int)je.VoucherType.GetValueOrDefault(),
                    Posted      = je.Posted
                };

                foreach (var line in je.JournalEntryLines)
                {
                    var lineDto = new JournalEntryLine()
                    {
                        Id        = line.Id,
                        AccountId = line.AccountId,
                        Amount    = line.Amount,
                        DrCr      = (int)line.DrCr,
                        Memo      = line.Memo
                    };

                    journalEntryDto.JournalEntryLines.Add(lineDto);
                }

                journalEntriesDto.Add(journalEntryDto);
            }

            return(new ObjectResult(journalEntriesDto));
        }
예제 #19
0
        public bool Cancel(bool ignoreSizeNotZero)
        {
            const string defErr = "It is not possible to Cancel an inactive BondCouponPayment, use storno instead. ";
            if (!(this.Status == BondCouponPaymentStati.Active))
                throw new ApplicationException(defErr + "The payment is not active");

            if (HasSettled)
                throw new ApplicationException(defErr + "This interest payment already settled");

            if (!ignoreSizeNotZero)
            {
                InstrumentSize size = Position.PositionTransactions.Where(x => x.TransactionDate <= CouponHistory.EndAccrualDate).Select(x => x.Size).Sum();
                if (size.IsNotZero)
                    throw new ApplicationException(defErr + "The position size is not equal to zero");
            }

            Money cancelAmount = this.DailyCalculations.TotalAccruedInterest;
            if (cancelAmount.IsNotZero)
            {
                // Find day where Pos Size got zero
                DateTime posClosingDate = CouponHistory.EndAccrualDate;
                while (Position.PositionTransactions.Any(x => x.TransactionDate <= posClosingDate) && Position.PositionTransactions.Where(x => x.TransactionDate <= posClosingDate).Select(x => x.Size).Sum().IsZero)
                {
                    posClosingDate = posClosingDate.AddDays(-1);
                    if (posClosingDate < CouponHistory.StartAccrualDate)
                        throw new ApplicationException(defErr + "The position closing date could not be determined");
                }

                foreach (IJournalEntryLine line in this.GeneralOpsJournalEntry.Lines)
                {
                    JournalEntryLine newLine = new JournalEntryLine();
                    newLine.clientSettle(
                        GeneralOpsJournalEntry,
                        newLine,
                        line.GLAccount,
                        line.Balance.Negate(),
                        this.Components[0].Component,
                        line.GiroAccount);
                    newLine.ValueDate = line.ValueDate;
                    newLine.Description = string.Format("Cancellation {0}", line.ValueDate.ToString("dd-MM-yyyy"));
                }

                this.GeneralOpsJournalEntry.BookLines();
                this.Position.LastBondCouponCalcDate = posClosingDate;
            }
            this.Status = BondCouponPaymentStati.Cancelled;

            return !(this.Status == BondCouponPaymentStati.Active);
        }
예제 #20
0
        public void AddJournalEntry(JournalEntryLine journalEntry)
        {
            //journalEntry.Posted = false;

            _journalEntryLineRepo.Insert(journalEntry);
        }
예제 #21
0
        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));
        }
예제 #22
0
        public void AddLinesToComponent(Money componentValue, IGLLookupRecord lookupRecord,  IAccount accountA, IAccount accountB, DateTime? valueDate)
        {
            IGLAccount glAcctA = lookupRecord.MainAccount;
            IGLAccount glAcctB = lookupRecord.CounterAccount;

            IJournalEntryLine sideA = new JournalEntryLine();
            sideA.GLAccount = glAcctA;
            sideA.Balance = componentValue.Negate();
            if (sideA.GLAccount.RequiresGiroAccount) sideA.GiroAccount = (IAccountTypeInternal)accountA;
            if (valueDate.HasValue) sideA.ValueDate = valueDate.Value;
            this.JournalLines.AddJournalEntryLine(sideA);
            this.MainLine = sideA;

            IJournalEntryLine sideB = new JournalEntryLine();
            sideB.GLAccount = glAcctB;
            sideB.Balance = componentValue;
            if (sideB.GLAccount.RequiresGiroAccount) sideB.GiroAccount = (IAccountTypeInternal)accountB;
            if (valueDate.HasValue) sideB.ValueDate = valueDate.Value;
            this.JournalLines.AddJournalEntryLine(sideB);
        }
예제 #23
0
 public void SaveOrUpdate(JournalEntryLine pObjJournalEntryLine)
 {
     mObjJournalEntryLineDAO.SaveOrUpdateEntity(pObjJournalEntryLine);
 }
예제 #24
0
        public void SettleInterest(DateTime calcDate)
        {
            if (HasSettled)
                throw new ApplicationException("This interest payment already settled.");

            const string DefErr = "Can not settle the accrued interest. ";

            if (this.Status != BondCouponPaymentStati.ToBeSettled)
                throw new ApplicationException(DefErr + "The status does not equal to-be-settled.");

            if (this.DailyCalculations == null || this.DailyCalculations.Count == 0)
                throw new ApplicationException(DefErr + "No calculations.");

            if (this.CouponHistory.EndAccrualDate > calcDate)
                throw new ApplicationException(DefErr + "The date to sttle the interest is in the future.");

            Money accruedInterest = this.DailyCalculations.LastCalculation.CalculatedAccruedInterestUpToDate;
            IGLAccount glAccount = Components[0].MainLine.GLAccount;
            JournalEntryLine newLine1 = new JournalEntryLine();
            newLine1.BookDate = CouponHistory.EndAccrualDate;
            newLine1.clientSettle(GeneralOpsJournalEntry, newLine1, glAccount, accruedInterest, this.Components[0].Component, this.Account);
            newLine1.Description = "Settle Interest " + newLine1.BookDate.ToString("dd-MM-yyyy");

            JournalEntryLine newLine2 = new JournalEntryLine();
            newLine2.BookDate = CouponHistory.EndAccrualDate;
            newLine2.clientSettle(GeneralOpsJournalEntry, newLine2, glAccount.GLSettledAccount, accruedInterest.Negate(), this.Components[0].Component, this.Account);
            newLine2.Description = "Settle Interest " + newLine2.BookDate.ToString("dd-MM-yyyy");
            Components[0].MainLine = newLine2;

            foreach (IJournalEntryLine line in Components[0].JournalLines)
            {
                if (!line.GLAccount.IsSettledWithClient)
                    line.IsSettledStatus = true;
            }
            this.Status = BondCouponPaymentStati.Settled;
            this.IsNotarizable = true;
        }