public DataTable GetAccountSummaryTotals(Int32 Billingaccountid, Int32 PeriodID) { BillingPeriodAccountsJoin billingperiodaccount = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Periodid, PeriodID).Where(BillingPeriodAccountsJoin.Columns.Accountid, Billingaccountid).Load()[0]; Int32 billingperiodaccountid = billingperiodaccount.Id; var timeSheetController = new TimesheetController(); DataTable summaryTotals = new DataTable(); summaryTotals.Columns.Add("RateGroupID"); summaryTotals.Columns.Add("RateGroupName"); summaryTotals.Columns.Add("Rate"); summaryTotals.Columns.Add("TotalHours"); summaryTotals.Columns.Add("PerDiemRate"); summaryTotals.Columns.Add("PerDiemTotal"); summaryTotals.Columns.Add("MileageRate"); summaryTotals.Columns.Add("MileageTotal"); summaryTotals.Columns.Add("ExpenseTotal"); Double perdiemrate = billingperiodaccount.Perdiemrate; Double cityPerdiemRateAverage = timeSheetController.GetPerCityDiemRateAverageByBillingPeriodAccountID(billingperiodaccountid); Double perdiemtotal = timeSheetController.GetPerDiemCountByBillingPeriodAccountID(billingperiodaccountid); Double expensetotal = new ExpenseEntryController().GetTotalByBillingPeriodAccountID(billingperiodaccountid); Double mileagerate = billingperiodaccount.Mileagerate; Double mileagetotal = timeSheetController.GetMileageCountByBillingPeriodAccountID(billingperiodaccountid); if (cityPerdiemRateAverage > 0) { perdiemrate = cityPerdiemRateAverage; } RateGroupCollection rategroups = new RateGroupController().FetchAll(); foreach (RateGroup rategroup in rategroups) { DataRow newrow = summaryTotals.NewRow(); newrow["RateGroupID"] = rategroup.Id; newrow["RateGroupName"] = rategroup.Name; BillingRateCollection billingratecollection = new BillingRateCollection().Where(BillingRate.Columns.Periodaccountid, billingperiodaccountid).Where(BillingRate.Columns.Groupid, rategroup.Id).Load(); newrow["Rate"] = billingratecollection[0].Rate; Double totalHours = 0; EmployeeTimesheetInfoCollection col = GetTimesheets(Billingaccountid, PeriodID, rategroup.Id); foreach (EmployeeTimesheetInfo timesheet in col) { totalHours += new TimeEntriesTotalController().GetTotalHoursByTimesheetID(timesheet.Timesheetid); } newrow["TotalHours"] = totalHours; newrow["PerDiemRate"] = perdiemrate; newrow["PerDiemTotal"] = perdiemtotal; newrow["MileageRate"] = mileagerate; newrow["MileageTotal"] = mileagetotal; newrow["ExpenseTotal"] = expensetotal; summaryTotals.Rows.Add(newrow); } return(summaryTotals); }
public DataTable GetAccountSummaryTotals(Int32 Billingaccountid, Int32 PeriodID) { BillingPeriodAccountsJoin billingperiodaccount = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Periodid, PeriodID).Where(BillingPeriodAccountsJoin.Columns.Accountid, Billingaccountid).Load()[0]; Int32 billingperiodaccountid = billingperiodaccount.Id; var timeSheetController = new TimesheetController(); DataTable summaryTotals = new DataTable(); summaryTotals.Columns.Add("RateGroupID"); summaryTotals.Columns.Add("RateGroupName"); summaryTotals.Columns.Add("Rate"); summaryTotals.Columns.Add("TotalHours"); summaryTotals.Columns.Add("PerDiemRate"); summaryTotals.Columns.Add("PerDiemTotal"); summaryTotals.Columns.Add("MileageRate"); summaryTotals.Columns.Add("MileageTotal"); summaryTotals.Columns.Add("ExpenseTotal"); Double perdiemrate = billingperiodaccount.Perdiemrate; Double cityPerdiemRateAverage = timeSheetController.GetPerCityDiemRateAverageByBillingPeriodAccountID(billingperiodaccountid); Double perdiemtotal = timeSheetController.GetPerDiemCountByBillingPeriodAccountID(billingperiodaccountid); Double expensetotal = new ExpenseEntryController().GetTotalByBillingPeriodAccountID(billingperiodaccountid); Double mileagerate = billingperiodaccount.Mileagerate; Double mileagetotal = timeSheetController.GetMileageCountByBillingPeriodAccountID(billingperiodaccountid); if (cityPerdiemRateAverage > 0) { perdiemrate = cityPerdiemRateAverage; } RateGroupCollection rategroups = new RateGroupController().FetchAll(); foreach (RateGroup rategroup in rategroups) { DataRow newrow = summaryTotals.NewRow(); newrow["RateGroupID"] = rategroup.Id; newrow["RateGroupName"] = rategroup.Name; BillingRateCollection billingratecollection = new BillingRateCollection().Where(BillingRate.Columns.Periodaccountid, billingperiodaccountid).Where(BillingRate.Columns.Groupid, rategroup.Id).Load(); newrow["Rate"] = billingratecollection[0].Rate; Double totalHours = 0; EmployeeTimesheetInfoCollection col = GetTimesheets(Billingaccountid, PeriodID, rategroup.Id); foreach (EmployeeTimesheetInfo timesheet in col) { totalHours += new TimeEntriesTotalController().GetTotalHoursByTimesheetID(timesheet.Timesheetid); } newrow["TotalHours"] = totalHours; newrow["PerDiemRate"] = perdiemrate; newrow["PerDiemTotal"] = perdiemtotal; newrow["MileageRate"] = mileagerate; newrow["MileageTotal"] = mileagetotal; newrow["ExpenseTotal"] = expensetotal; summaryTotals.Rows.Add(newrow); } return summaryTotals; }