public void add(FinancialSummary summary)
        {
            int datarows = 0;

            datarows = this._db.Execute(@"INSERT FinancialSummary([AccountId],[AccountName],[Year],[Month],[MonthName],[Quarter],[ExpectedHours],[ActualHours],[CoveredBillableHours]) values (@AccountId,@AccountName,@Year,@Month,@MonthName,@Quarter,@ExpectedHours,@ActualHours,@CoveredBillableHours)",
                                        new { AccountId = summary.AccountId, AccountName = summary.AccountName, Year = summary.Year, Month = summary.Month, MonthName = summary.MonthName, Quarter = summary.Quarter, ExpectedHours = summary.ExpectedHours, ActualHours = summary.ActualHours, CoveredBillableHours = summary.coveredBillableHours });
        }
Ejemplo n.º 2
0
        public static List <Income> GetAllIncomes(FinancialSummary financialSummary, ExpenseTrackerContext _context)
        {
            var currentMonthFinancialObj = _context.Incomes.Where(b => b.Date.Month == financialSummary.Date.Month && b.Date.Year == financialSummary.Date.Year && b.ProfileNo == financialSummary.ProfileNo);

            return(currentMonthFinancialObj.ToList());
            //throw new NotImplementedException();
        }
Ejemplo n.º 3
0
        public static FinancialSummaryViewModel FinancialSummaryFrom(FinancialSummary summary, ActiveCandidate candidate, Election election)
        {
            if (summary == null || candidate == null)
            {
                return(new FinancialSummaryViewModel());
            }
            var statement = election == null ? null : (from s in election.Statements
                                                       where s.Key == summary.LastStatementSubmitted
                                                       select s.Value).SingleOrDefault();

            return(new FinancialSummaryViewModel
            {
                IsTie = election != null && election.IsTIE,
                ElectionCycle = candidate.ElectionCycle,
                CandidateName = string.Format("{0} (ID: {1})", candidate.Name, candidate.ID),
                OfficeSought = candidate.Office.ToString(),
                Classification = candidate.Classification,
                LastFiledStatement = statement == null ? null : statement.ToDetailString(),
                NetContributions = summary.NetContributions,
                MiscReceipts = summary.MiscellaneousReceipts,
                LoansReceived = summary.LoansReceived,
                PublicFundsReceived = summary.PublicFundsReceived,
                NetExpenditures = summary.NetExpenditures,
                LoansPaid = summary.LoansPaid,
                OutstandingBills = summary.OutstandingBills,
                FundsReturned = summary.PublicFundsReturned,
                ContributorsNumber = summary.ContributorCount,
                MatchingClaims = summary.MatchingClaims
            });
        }
Ejemplo n.º 4
0
        // GET: Profile/FinancialSummary
        public ActionResult Index()
        {
            var summary   = FinancialSummary.GetFinancialSummary(CPProfile.Cid, CPProfile.ElectionCycle);
            var candidate = CPProfile.ActiveCandidate;
            var election  = CPProfile.Election;

            return(View(ProfileViewModelFactory.FinancialSummaryFrom(summary, candidate, election)));
        }
        public int updatesummary(FinancialSummary summary)
        {
            int datarows = 0;

            datarows = this._db.Execute("UPDATE FinancialSummary set [ExpectedHours]=@ExpectedHours, [ActualHours]=@ActualHours WHERE [AccountId]=@AccountId and [Year]=@Year and [Month]=@Month",
                                        new { ExpectedHours = summary.ExpectedHours, ActualHours = summary.ActualHours, AccountId = summary.AccountId, Year = summary.Year, Month = summary.Month });

            return(datarows);
        }
Ejemplo n.º 6
0
        public void PrivateFundsReceivedTest()
        {
            FinancialSummary target   = new FinancialSummary(); // TODO: Initialize to an appropriate value
            Decimal          expected = new Decimal();          // TODO: Initialize to an appropriate value
            Decimal          actual;

            target.PrivateFundsReceived = expected;
            actual = target.PrivateFundsReceived;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 7
0
        public void GetFinancialSummaryTest()
        {
            string           candidateID   = string.Empty; // TODO: Initialize to an appropriate value
            string           electionCycle = string.Empty; // TODO: Initialize to an appropriate value
            FinancialSummary expected      = null;         // TODO: Initialize to an appropriate value
            FinancialSummary actual;

            actual = FinancialSummary.GetFinancialSummary(candidateID, electionCycle);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 8
0
        public void ContributorCountTest()
        {
            FinancialSummary target = new FinancialSummary(); // TODO: Initialize to an appropriate value
            int expected            = 0;                      // TODO: Initialize to an appropriate value
            int actual;

            target.ContributorCount = expected;
            actual = target.ContributorCount;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 9
0
        public void LastStatementSubmittedTest()
        {
            FinancialSummary target   = new FinancialSummary(); // TODO: Initialize to an appropriate value
            byte             expected = 0;                      // TODO: Initialize to an appropriate value
            byte             actual;

            target.LastStatementSubmitted = expected;
            actual = target.LastStatementSubmitted;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 10
0
        public static FinancialSummary GetfinancialSummary(FinancialSummary financialSummary, ExpenseTrackerContext _context)
        {
            FinancialSummary financialSummaryObj = null;
            decimal          currentMonthexpense = 0;

            try
            {
                //find current month total incomes and total budget
                var     currentMonthFinancialObj = _context.Incomes.Where(b => b.Date.Month == financialSummary.Date.Month && b.Date.Year == financialSummary.Date.Year && b.ProfileNo == financialSummary.ProfileNo);
                decimal currentMonthIncome       = currentMonthFinancialObj.Sum(d => d.Amount);
                decimal currentMonthBudget       = currentMonthFinancialObj.Sum(d => d.Budget);

                var currentMonthExpenseObj = _context.Expenses.Where(b => b.ExpenseDate.Month == financialSummary.Date.Month && b.ExpenseDate.Year == financialSummary.Date.Year && b.ProfileNo == financialSummary.ProfileNo);
                currentMonthexpense = currentMonthExpenseObj.Sum(d => d.Amount);

                //
                var     incomesObj   = _context.Incomes.Where(b => b.Date.Month <= financialSummary.Date.Month && b.Date.Year <= financialSummary.Date.Year && b.ProfileNo == financialSummary.ProfileNo);
                var     expenseObj   = _context.Expenses.Where(b => b.ExpenseDate.Month < financialSummary.Date.Month && b.ExpenseDate.Year <= financialSummary.Date.Year && b.ProfileNo == financialSummary.ProfileNo);
                decimal totalIncome  = 0;
                decimal totalExpense = 0;
                decimal totalSavings = 0;
                if (incomesObj != null)
                {
                    totalIncome = incomesObj.Sum(d => d.Amount);
                }
                if (expenseObj != null)
                {
                    totalExpense = expenseObj.Sum(d => d.Amount);
                }
                totalSavings               = (totalIncome - totalExpense) - currentMonthBudget;
                financialSummaryObj        = new FinancialSummary();
                financialSummaryObj.Income = currentMonthIncome;
                if (currentMonthexpense >= currentMonthBudget)
                {
                    financialSummaryObj.Budget  = 0;
                    financialSummaryObj.Savings = totalSavings - (currentMonthexpense - currentMonthBudget);
                }
                else
                {
                    financialSummaryObj.Budget  = currentMonthBudget - currentMonthexpense;
                    financialSummaryObj.Savings = totalSavings;
                }
                //Financial Health
                GetFinancialHealth(financialSummaryObj, currentMonthexpense, currentMonthBudget);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in getting financial summary", e);
            }
            return(financialSummaryObj);
        }
        public bool doesSummaryExists(int accountId, int year, int month)
        {
            string           query   = "select * from FinancialSummary where AccountId=" + accountId + " and Year=" + year + " and Month=" + month + "";
            FinancialSummary summary = this._db.Query <FinancialSummary>(query).SingleOrDefault();

            if (summary != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!Page.IsPostBack)
     {
         ActiveCandidate ac = CPProfile.ActiveCandidate;
         if (ac != null)
         {
             // general candidate information
             this.CandidateName.Text = string.Format("{0} (ID: {1})", ac.Name, ac.ID);
             if (ac.Office != null)
             {
                 this.OfficeLabel.Text = ac.Office.ToString();
             }
             this.ClassificationLabel.Text = CPConvert.ToString(ac.Classification);
             Election ec = CPApplication.Elections[CPProfile.ElectionCycle];
             if (ec != null)
             {
                 FinancialSummary fs = FinancialSummary.GetFinancialSummary(CPProfile.Cid, CPProfile.ElectionCycle);
                 if (fs != null)
                 {
                     Statement lastStatement;
                     if (ec.Statements.TryGetValue(fs.LastStatementSubmitted, out lastStatement))
                     {
                         // receipts
                         this.NetContributionsLabel.Text = FormatCurrency(fs.NetContributions);
                     }
                     this.NumberOfContributorsLabel.Text  = string.Format("{0:N0}", fs.ContributorCount);
                     this.MiscellaneousReceiptsLabel.Text = FormatCurrency(fs.MiscellaneousReceipts);
                     this.MatchingClaimsLabel.Text        = FormatCurrency(fs.MatchingClaims);
                     this.LoansReceivedLabel.Text         = FormatCurrency(fs.LoansReceived);
                     // disbursements
                     this.NetExpendituresLabel.Text = FormatCurrency(fs.NetExpenditures);
                     this.LoansPaidLabel.Text       = FormatCurrency(fs.LoansPaid);
                     this.OustandingBillsLabel.Text = FormatCurrency(fs.OutstandingBills);
                     if (!_isTIE)
                     {
                         this.PublicFundsReceivedLabel.Text = FormatCurrency(fs.PublicFundsReceived);
                         this.PublicFundsReturnedLabel.Text = FormatCurrency(fs.PublicFundsReturned);
                     }
                 }
                 if (_isTIE)
                 {
                     FSClassificationCol.Visible = FSClassificationHeader.Visible = FSClassificationCell.Visible = false;
                     ContributorsPanel.CssClass  = null;
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
        public ActionResult GetFinancialSummary()
        {
            List <FinancialSummary> lstFinancialSummary = new List <FinancialSummary>();
            FinancialSummary        obj1 = new FinancialSummary(2, 100, "2014");
            FinancialSummary        obj2 = new FinancialSummary(3, 200, "2015");
            FinancialSummary        obj3 = new FinancialSummary(8, 400, "2016");
            FinancialSummary        obj4 = new FinancialSummary(9, 500, "2017");

            lstFinancialSummary.Add(obj1);
            lstFinancialSummary.Add(obj2);
            lstFinancialSummary.Add(obj3);
            lstFinancialSummary.Add(obj4);
            return(Json(lstFinancialSummary, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        private static FinancialSummary GetFinancialHealth(FinancialSummary financialSummaryObj,
                                                           decimal currentMonthExpense, decimal currentMonthBudget)
        {
            decimal currrentMonthSavings = financialSummaryObj.Income - currentMonthBudget;

            if (currentMonthExpense == 0)
            {
                financialSummaryObj.HealthMessage   = "You do not have any expenses.";
                financialSummaryObj.SavedPercentage = 100;
                financialSummaryObj.SpendPercentage = 0;
                return(financialSummaryObj);
            }
            else if (currentMonthBudget == 0)
            {
                currentMonthBudget = currrentMonthSavings;
            }
            if (currentMonthExpense > currentMonthBudget)
            {
                financialSummaryObj.SavedPercentage = 0;
                financialSummaryObj.SpendPercentage = 100;
                financialSummaryObj.HealthMessage   = "You have spent all of your budget.Your saving at risk.";
                return(financialSummaryObj);
            }



            decimal spendingPercentage = currentMonthBudget / currentMonthExpense;

            spendingPercentage = 100 / spendingPercentage;
            financialSummaryObj.SpendPercentage = spendingPercentage;


            decimal savingPercentage = financialSummaryObj.Income / currrentMonthSavings;

            savingPercentage = 100 / savingPercentage;
            financialSummaryObj.SavedPercentage = savingPercentage;

            if (spendingPercentage > savingPercentage)
            {
                financialSummaryObj.HealthMessage = "You can save more.Cut down expenses.";
            }
            else
            {
                financialSummaryObj.HealthMessage = "You are in good financial position.";
            }

            return(financialSummaryObj);
        }
Ejemplo n.º 15
0
        public IActionResult GetFinacialSummary([FromBody] FinancialSummary financialSummary)
        {
            FinancialSummary financialObj = null;

            try
            {
                financialObj = new FinancialSummary();

                financialObj = financialSummaryBL.GetfinancialSummary(financialSummary);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in getting Financial summary", e);
            }
            return(new ObjectResult(financialObj));
        }
Ejemplo n.º 16
0
        public IEnumerable <Income> Update(int profileNo, [FromBody] FinancialSummary financialSummary)
        {
            FinancialSummary financialObj = null;
            List <Income>    incomes      = null;

            try
            {
                incomes      = new List <Income>();
                financialObj = new FinancialSummary();
                incomes      = financialSummaryBL.GetAllIncomes(profileNo, financialSummary);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in getting Context object", e);
            }
            return(incomes);
        }
Ejemplo n.º 17
0
        public FinancialSummary AddIncome(Income income)
        {
            decimal savingPercentage = income.Saving;
            decimal budgetPercentage = 100 - savingPercentage;

            income.Saving = (income.Amount * (savingPercentage / 100));
            income.Budget = (income.Amount * (budgetPercentage / 100));
            if (income.IsItRecurring == false)
            {
                income.Frequency = null;
            }
            _context.Incomes.Add(income);
            _context.SaveChanges();
            FinancialSummary financialSummary = new FinancialSummary();

            financialSummary.Date      = income.Date;
            financialSummary.ProfileNo = income.ProfileNo;
            return(FinancialSummaryDetails.GetfinancialSummary(financialSummary, _context));
        }
Ejemplo n.º 18
0
 public FinancialSummary GetfinancialSummary(FinancialSummary financialSummary)
 {
     return(FinancialSummaryDetails.GetfinancialSummary(financialSummary, _context));
 }
Ejemplo n.º 19
0
        public void FinancialSummaryConstructorTest()
        {
            FinancialSummary target = new FinancialSummary();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Ejemplo n.º 20
0
        public void Post([FromBody] List <FinancialResults> results)
        {
            Debug.WriteLine("RESULT SIZE " + results.Count);
            // repo.add(results);

            if (results.Count != 0)
            {
                List <int> empIds = repo.getTimeReportedEmpIdForQuarter(results[0].Year, results[0].Quarter, results[0].AccountId);
                foreach (FinancialResults result in results)
                {
                    empIds.Remove(result.EmpId);

                    //repo.saveData(result);
                }

                foreach (int empId in empIds)
                {
                    TeamMembers member = teamRepo.Get(empId);
                    if (member != null)
                    {
                        FinancialResults tempResult = new FinancialResults();
                        tempResult.EmpId       = empId;
                        tempResult.EmpName     = member.MemberName;
                        tempResult.AccountId   = results[0].AccountId;
                        tempResult.AccountName = results[0].AccountName;
                        tempResult.Month       = results[0].Month;
                        tempResult.Quarter     = results[0].Quarter;
                        tempResult.Year        = results[0].Year;
                        Console.WriteLine(tempResult.EmpName);
                        //  repo.saveData(tempResult);
                    }
                }
            }

            //Calculate Financial Summary
            double expectedHours        = 0;
            double actualHours          = 0;
            double coveredBillableHours = 0;

            foreach (FinancialResults result in results)
            {
                if (result.BillableType == Constants.FULLTIMEBILLABLE)
                {
                    // The below commented code compares individual allocation with its billable hours

                    //expectedHours += result.AllocatedHours;

                    //double tempActualHours = 0;
                    //if (result.AllocatedHours < result.BillableHours)
                    //{
                    //    tempActualHours = result.AllocatedHours;
                    //}
                    //else
                    //{
                    //    tempActualHours = result.BillableHours;
                    //}
                    //actualHours += tempActualHours;

                    expectedHours        += result.AllocatedHours;
                    actualHours          += result.BillableHours;
                    coveredBillableHours += result.BillableHours;
                }
            }

            if (results.Count != 0)
            {
                if (actualHours > expectedHours)
                {
                    // actualHours = expectedHours;
                }

                string strDate = "01/" + results[0].Month + "/" + results[0].Year;

                //String strDate = "01/12/2014";
                DateTime dateTime = new DateTime(results[0].Year, results[0].Month, 1);
                //DateTime dateTime = DateTime.ParseExact(strDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTime = dateTime.AddMonths(-1);


                FinancialSummary summary = summaryRepo.getSelectedMonthSummary(dateTime.Year, results[0].AccountId, results[0].Quarter);

                FinancialSummary savingSummary = new FinancialSummary();
                savingSummary.Month       = results[0].Month;
                savingSummary.Year        = results[0].Year;
                savingSummary.Quarter     = results[0].Quarter;
                savingSummary.AccountId   = results[0].AccountId;
                savingSummary.AccountName = results[0].AccountName;
                savingSummary.MonthName   = getMonth(results[0].Month);

                if (summary != null)
                {
                    double finalAllocatedHours       = expectedHours + summary.ExpectedHours;
                    double finalActualHours          = actualHours + summary.ActualHours;
                    double finalCoveredBillableHours = coveredBillableHours + summary.coveredBillableHours;
                    finalActualHours = finalCoveredBillableHours;
                    if (finalCoveredBillableHours > finalAllocatedHours)
                    {
                        finalActualHours = finalAllocatedHours;
                    }

                    savingSummary.ExpectedHours        = finalAllocatedHours;
                    savingSummary.ActualHours          = finalActualHours;
                    savingSummary.coveredBillableHours = finalCoveredBillableHours;
                }
                else
                {
                    savingSummary.ExpectedHours = expectedHours;
                    Debug.WriteLine("Saving Summary " + expectedHours);
                    savingSummary.ActualHours          = actualHours;
                    savingSummary.coveredBillableHours = coveredBillableHours;
                }

                summaryRepo.add(savingSummary);
            }
        }
Ejemplo n.º 21
0
 public List <Income> GetAllIncomes(int profileNo, FinancialSummary financialSummary)
 {
     financialSummary.ProfileNo = profileNo;
     return(FinancialSummaryDetails.GetAllIncomes(financialSummary, _context));
 }
Ejemplo n.º 22
0
        public void updateFinancialResults([FromBody] List <FinancialResults> results)
        {
            Debug.WriteLine("RESULT SIZE " + results.Count);
            int didExistingResultesDeleted = 0;
            int didExistingSummaryDeleted  = 0;

            if (results.Count != 0)
            {
                didExistingResultesDeleted = repo.deleteFinancialResults(results[0].AccountId, results[0].Year, results[0].Quarter, results[0].Month);
                didExistingSummaryDeleted  = summaryRepo.deleteExistingSummary(results[0].AccountId, results[0].Year, results[0].Quarter, results[0].Month);
            }

            if (didExistingResultesDeleted > 0 & didExistingSummaryDeleted > 0)
            {
                //  repo.add(results);
                double expectedHours        = 0;
                double actualHours          = 0;
                double coveredBillableHours = 0;
                if (results.Count != 0)
                {
                    List <int> empIds = repo.getTimeReportedEmpIdForQuarter(results[0].Year, results[0].Quarter, results[0].AccountId);
                    foreach (FinancialResults result in results)
                    {
                        empIds.Remove(result.EmpId);

                        //repo.saveData(result);
                    }

                    foreach (int empId in empIds)
                    {
                        TeamMembers member = teamRepo.Get(empId);
                        if (member != null)
                        {
                            FinancialExpandedResults tempResult = new FinancialExpandedResults();
                            tempResult.EmpId       = empId;
                            tempResult.EmpName     = member.MemberName;
                            tempResult.AccountId   = results[0].AccountId;
                            tempResult.AccountName = results[0].AccountName;
                            tempResult.Month       = results[0].Month;
                            tempResult.Quarter     = results[0].Quarter;
                            tempResult.Year        = results[0].Year;
                            Console.WriteLine(tempResult.EmpName);
                            //  repo.saveData(tempResult);

                            FinancialExpandedResults empFinancialResult = repo.getIndividualEmpDataForLastMonthInQuarter(results[0].AccountId, empId, results[0].Year, results[0].Quarter);
                            if (empFinancialResult != null)
                            {
                                expectedHours        += empFinancialResult.CumAllocatedHours;
                                actualHours          += empFinancialResult.BillableHours;
                                coveredBillableHours += empFinancialResult.CumConsiderableHours;
                            }
                        }
                    }
                }

                //Calculate Financial Summary

                List <FinancialExpandedResults> newResultList = new List <FinancialExpandedResults>();
                foreach (FinancialResults result in results)
                {
                    FinancialExpandedResults lastMonthresult = repo.getIndividualEmpDataForLastMonthInQuarter(result.AccountId, result.EmpId, result.Year, result.Quarter);
                    FinancialExpandedResults currentResult   = result;



                    if (result.BillableType == Constants.FULLTIMEBILLABLE)
                    {
                        //results
                        currentResult.CumAllocatedHours     = lastMonthresult.CumAllocatedHours + currentResult.AllocatedHours;
                        currentResult.CumBillableHours      = lastMonthresult.CumBillableHours + currentResult.BillableHours;
                        currentResult.CumTotalReportedHours = lastMonthresult.CumTotalReportedHours + currentResult.TotalReportedHours;
                        if (currentResult.CumBillableHours > currentResult.CumAllocatedHours)
                        {
                            currentResult.CumConsiderableHours = currentResult.CumAllocatedHours;
                        }
                        else
                        {
                            currentResult.CumConsiderableHours = currentResult.CumBillableHours;
                        }
                    }
                    else if (result.BillableType == Constants.NONBILLABLE || result.BillableType == Constants.HOURLYBILLABLE)
                    {
                        currentResult.CumAllocatedHours     = lastMonthresult.CumAllocatedHours;
                        currentResult.CumBillableHours      = lastMonthresult.CumBillableHours;
                        currentResult.CumTotalReportedHours = lastMonthresult.CumTotalReportedHours;
                        currentResult.CumConsiderableHours  = lastMonthresult.CumConsiderableHours;
                    }

                    newResultList.Add(currentResult);
                    //summary
                    expectedHours        += currentResult.CumAllocatedHours;
                    actualHours          += currentResult.CumBillableHours;
                    coveredBillableHours += currentResult.CumConsiderableHours;
                }

                if (results.Count != 0)
                {
                    repo.add(newResultList);

                    FinancialSummary savingSummary = new FinancialSummary();
                    savingSummary.Month       = results[0].Month;
                    savingSummary.Year        = results[0].Year;
                    savingSummary.Quarter     = results[0].Quarter;
                    savingSummary.AccountId   = results[0].AccountId;
                    savingSummary.AccountName = results[0].AccountName;
                    savingSummary.MonthName   = getMonth(results[0].Month);


                    savingSummary.ExpectedHours = expectedHours;
                    Debug.WriteLine("Saving Summary " + expectedHours);
                    savingSummary.ActualHours          = actualHours;
                    savingSummary.coveredBillableHours = coveredBillableHours;


                    summaryRepo.add(savingSummary);
                }
            }
        }