public FinancialSummary getFinalMonthSummary(int AccountId, int Year, int Quarter) { return(repo.getSelectedMonthSummary(Year, AccountId, Quarter)); }
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); } }