Example #1
0
        public BillingPeriodAccountsJoinCollection GetPendingTimesheets()
        {
            BillingPeriodAccountsJoinCollection col = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Openuntil, SubSonic.Comparison.GreaterOrEquals, DateTime.Now).Load();
            BillingPeriodAccountsJoinCollection returnCollection = new BillingPeriodAccountsJoinCollection();

            returnCollection.AddRange(col);
            //foreach (Timesheet timesheet in new TimesheetController().FetchByUsername(Username))
            //    foreach (BillingPeriodAccountsJoin billingperiod in col)
            //        if (billingperiod.Id == timesheet.Periodaccountid)
            //            returnCollection.Remove(billingperiod);
            returnCollection.Sort(BillingPeriodAccountsJoin.Columns.Periodid, true);
            return(returnCollection);
        }
        public BillingPeriodAccountsJoinCollection FetchByPeriodIDWithoutCityPerdiem(Int32 periodid)
        {
            var billingCityRateController   = new BillingCityRateController();
            var billingCityCol              = billingCityRateController.FetchAllActive();
            var billingPeriodsCol           = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Periodid, periodid).OrderByAsc(BillingPeriodAccountsJoin.Columns.Accountname).Load();
            var billingCityPeriodAccountIds = new List <int>();

            var retBillingPeriodAccountCol = new BillingPeriodAccountsJoinCollection();

            billingCityPeriodAccountIds.AddRange(billingCityCol.Select(billingCity => billingCity.Periodaccountid));

            foreach (var billingPeriod in billingPeriodsCol)
            {
                if (!billingCityPeriodAccountIds.Contains(billingPeriod.Id))
                {
                    retBillingPeriodAccountCol.Add(billingPeriod);
                }
            }

            return(retBillingPeriodAccountCol);
        }
Example #3
0
        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);
        }