Running totals of two values combined - User Billing & Hours Report


#1

Here is a link to a new sample report template (NOTE: this report template is included in your original installed AyaNova 5 and higher via the Labor grid in the Service navigation pane)

Sample Schedulable Users Billing & Hours Report

This report template is based on the Schedulable User Billing Report but includes displaying a total of no charge hours + billable hours for the schedulable user displaying in the report.

This is achieved by maintaining a running total of all no charge hours and billable hours for the schedulable user and displaying that total under Total NC & Billable Hours

To do this requires scripts to be applied.

I recommend downloading and importing the report template, open it in custom report designer, and follow along by selecting the properties where indicated so that you can see how done.

First off, you need to create the variable where the running totals will be kept. This is done by creating a script in the ReportHeader band OnBeforePrint script property.

//This creates the variable NCBillTotal and sets its initial value to 0
System.Decimal NCBillTotal = 0;
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
}

Than in the detailBand1 OnBeforePrint script property we create a script that maintains a running total of hours combined

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//This gets the value of Billable hours, converts it to a decimal value and adds it to the running total of NCBillTotal
NCBillTotal += (System.Decimal)GetCurrentColumnValue(“LT_WorkorderItemLabor_Label_ServiceRateQuantity”);

//This gets the value of NC hours, converts it to a decimal value and adds it to the running total of NCBillTotal
NCBillTotal += (System.Decimal)GetCurrentColumnValue(“LT_WorkorderItemLabor_Label_NoChargeQuantity”);
}

Than in the GroupFooter’s xrTableCell8 field, in its OnBeforePrint script property, we create a script that displays this total

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//this converts the total to date for NCBillTotal to a string value, and places it into the xrTableCell8 field
xrTableCell8.Text = NCBillTotal.ToString();
}

And than in GroupFooter band OnAfterPrint script we reset the NCBillTotal back to 0 (zero) otherwise the running total would continue adding onto other schedulable users totals.

private void OnAfterPrint(object sender, System.EventArgs e)
{
//This resets the running total to 0 for the next group of hours for the next schedulable user
NCBillTotal = 0;
}

As with all sample report templates, I suggest opening in the report designer, and checking out the properties to determine how results are obtained.