Custom Queries & Report Queue: Report Queue Setup

User-defined queries, stored procedures, and report queue

Report Queue Setup

The Report Queue screen is used to display the reports that have been selected using the Report Queue flag. From this screen, users can retrieve the reports they have selected from the following menu options:

  • Fleet / Administration / Reports

  • Reporting / Standard Reports

This screen has been created to make it easier for users, both internal and external, to run reports without compromising system performance. Users will be able to select whether to run the report and download it immediately or to use the 'Report Queue' flag to push the report to the Report Queue screen.

Reports that take longer than the time specified in the Global Control reportqueuetimeouttobackground (default time is 10 minutes) will be sent to the Report Queue. The user will be alerted on screen that the report is taking a long time, and can be retrieved from the Report Queue screen. If set up, an email will be sent to the user when the report is available.

Please refer to Report Queue Roles Set Up to see which Roles have access to this feature.


User Set Up

By default, each User is set up to receive email notifications when a report they have requested is available to be retrieved from the Report Queue screen.

If you would like to switch this feature off, then please visit System / Users > Details Tab and check OFF the Report Queue Notifications flag.


Catch-e Set Up

Email Notification Template

Where the Report Queue Notifications flag is switched ON, an email template will need to be created. The content of these messages will be defined by you and supplied to Catch-e to upload into the system accordingly.

Under gb_templates, a template will need to be created with the name reportqueuemailmessage. The template_id will need to be recorded and entered into the gb_control reportqueuemailtemplate_id field in order for the email template to be created and sent as notification.

Warning: Currently, only ONE template with this name can be created and therefore one template_id stored in the gb_control table.

Long Running Reports

When system reports are run from Reports and Standard Reports, a cut off time can be set to push long running reports to the Report Queue screen. The default value is 10 minutes.

The table below describes how long running reports are managed under specific set ups:

Report Queue

Notification Flag

Report Queue Flag Result for Long Running Reports

ON

ON

Report will be sent to Report Queue and email will be sent notifying user report is complete.

ON

OFF

Alert will appear on screen that report is taking a long time to run. Report will be sent to Report Queue and email will be sent notifying user report is complete.

OFF

ON

Alert will appear on screen that the report will be sent to the Report Queue. No email will be sent notifying user report is complete.

OFF

OFF

Alert will appear on screen that report is taking too long to run. User will be advised to visit the Report Queue screen to retrieve completed report. No email will be sent notifying user report is complete. NOTE: Where the report is created within the time tolerance set for Long Running Reports, the report will be created for retrieval from the report screen as per current process.

Please contact Catch-e support to allocate a cut-off run time for reports before they are sent to the Report Queue. We will update the global control reportqueuetimeouttobackground accordingly.


Set-up Screen Report Templates

Screen Reports Templates Overview

You can develop a Screen Report Template in the same way that a System Form is created. Templates can only be created for 'Office(xlsx)' or 'Office(docx)' files.

Create a Screen Report Template

  1. Select the Report Format 'Field List' for the screen report you want to create a template for

  2. The 'Field List' is only available to 'admin' users

  3. Only fields listed in the 'Field List' can be used as {placeholders} in your template

  4. The {placeholders} will only return for the first record in the screen report that is run

  5. The screen report should be limited to the one record you want to use in your template

  6. Print and save this document

  7. Create the xlsx or docx template you want. It should have the same name as the Screen Report it will be created from

  8. Add the required {placeholders} from the saved 'Field List' file into your template file

  9. Work out the following details you need to provide to Catch-e Support:

    • The name of the existing Screen Report

    • The kind of file you are creating (xlsx or docx)

    • The report formats you want to have available, e.g. PDF only, xlsx only or PDF and xlsx

  10. From the details provide above, Catch-e Support can create the required:

    • gb_report_queries record

    • gb_report_query_files record

    • file_id (with filename)

  11. When the records have been created, use the Upload a form process to upload and test your new template


Screen Report Templates Field Descriptions

gb_report_query_files Table

Field

Mandatory / Optional

Comments

report_query_file_id

Auto

System allocated unique identifier.

report_query_id

Mandatory

Enter the gb_report_queries.report_query_id that this template is being created for.

file_id

Mandatory

Enter the gb_files.file_id that belongs to the file record that has been created for this Office(docx) or Office(xlsx) template. If the query returns more than one record, the first record in the query will be used to deliver placeholders to this Office(docx) or Office(xlsx) form. It's best to structure your query to only deliver a single record if you are using this feature.

file_extension_id

Mandatory

Enter the report format that matches the Office(docx) or Office(xlsx) template you are creating. The values you need are found in the gb_file_extensions table.

print_format

Mandatory

Enter which print formats you want to make available to users when the template is printed from the screen.

Print Format Values

Native

Office (@@@@)

native-and-pdf

Office (@@@@) as PDF or Office (@@@@)

pdf

Office (@@@@) as PDF

Sample Record

report_query_file_id

report_query_id

file_id

file_extension_id

print_format

1198825314

7144397847

100008

100042

1198825314


Troubleshooting

Prior to uploading DOCX files, all {placeholder_names} must be spell checked and any text you see the wavy red underline must be Added to your dictionary.

In this sample document below, the text "{placeholder_names}" has a wavy red underline. This {placeholder} will not produce the desired outcome on your document.

However, the text "misspelled" also has a wavy red underline. Because this word is not a {placeholder} your document will show the text (with the spelling issue).


Useful Queries

Show Current Screen Report Templates

SELECT rq.report_query_id, rq.module, rq.page, rq.sub_page, rq.name, rq.print_format AS print_format_xls, rq.status_flag, fe.extension, rqf.print_format AS print_format_file, f.status_flag FROM gb_report_queries AS rq LEFT JOIN gb_report_query_files AS rqf ON rqf.report_query_id = rq.report_query_id LEFT JOIN gb_files AS f ON f.file_id = rqf.file_id LEFT JOIN gb_file_extensions AS fe ON fe.file_extension_id = rqf.file_extension_id; 

Create File Record

SELECT * FROM gb_file_types; SELECT * FROM gb_files; 

Find Screen Report Template Format Data

SELECT * FROM gb_report_queries; SELECT * FROM gb_file_extensions WHERE extension = 'xlsx'; /* or 'docx' */ SELECT * FROM gb_report_query_files; 

Generate Required Upload File

SELECT '' AS report_query_file_id, rq.report_query_id, f.file_id AS file_id, fe.file_extension_id, 'native-and-pdf' AS print_format /* or 'native' or 'pdf' */ FROM gb_report_queries AS rq INNER JOIN gb_file_extensions AS fe ON fe.extension = 'xlsx' /* or 'docx' */ INNER JOIN gb_files AS f ON f.name = 'transaction.docx' WHERE rq.name = 'transactions' AND rq.sub_page = 'fbt'; 

Derived Fields budgets_settlement

Derived fields from the /fleet/administration/contracts/templates/budgets_settlement library

This library is used to calculate budget values from the first period of a contract and other sundry fields.

Input Fields

Field

Source

Rules

contract_id

fm_contracts > contract_id

Mandatory

supplierid_financier

fm_suppliers > supplierid_financier

Optional, but required for the credit_category field. The supplierid for fm_suppliers comes from fm_contracts > financier_id

client_id

fm_contracts > client_id

Optional, but required for the credit_category field

quote_id

fm_contracts > quote_id

Optional, but required for aftermarketequipment# fields

Output Fields

  • {postingclasscode}net — Net amount of the {postingclasscode} budget for period 1 of a contract, e.g. Fnet, INSnet, CEOnet. The FIN and CSD budgets are additionally combined into FINCSD_net

  • {postingclasscode}gst — GST amount of the {postingclasscode} budget for period 1 of a contract, where {postingclasscode} represents a posting class code. The FIN and CSD budgets are additionally combined into FINCSD_gst

  • credit_category — Value from fm_credit_categories > credit_category

  • aftermarketequipment# — The description of an item of aftermarket equipment, stored in the qt_quote_optional_equipment table. The # represents a number, so if there were three aftermarket equipment items fitted, three fields will be returned numbering 1, 2, and 3

  • aftermarketequipment#_code — The aftermarket code of an item of aftermarket equipment

  • aftermarketequipment#_costprice_net — The cost price net of an item of aftermarket equipment

  • aftermarketequipment#_listprice_net — The list price net of an item of aftermarket equipment

  • aftermarketequipment#_discount_net — The net discount of an item of aftermarket equipment


Derived Fields emissions

Derived fields from the /lib/PDF/emissions library

This library is used to calculate emission values based on existing data. These readings are shown on screens and used in various reports, such as the Carbon Emissions Report.

This library can also be used with the following scheduler job methods: executeQuery, mailQuery, and eventQuery.

This library can also be used with the following APIs: printReportQuery and triggerTableImportProcedure.

Input Fields

Field

Source

Rules

contract_id

fm_contracts > contract_id

Mandatory

date_filter

Any valid date

Mandatory (dd/mm/yyyy)

Output Fields

Field

Description

last_valid_odo_date

Latest valid odometer date

last_valid_odo_km

Latest valid odometer

km_per_year

Kilometres per year

co2_emissions

Carbon dioxide emissions value

co2_emissions_per_year

Carbon dioxide emissions per year


Derived Fields fbt_operating

Derived fields from the /lib/PDF/fbt_operating library

This library is used to calculate FBT Operating information based on existing validated readings from the system. This library can be used with the Print a report query API.

Input Fields

Field

Source

Rules

contract_id

fm_contracts > contract_id

Mandatory

date_filter

Any valid date

Optional, if left out will default to the current date (dd/mm/yyyy)

Output Fields

Field

Description

fbt_year_start

FBT year start date

fbt_year_end

FBT year end date

lease_cost

Lease cost value

other_cost

Other cost value

total_cost

Total cost value

fbt_business_use

FBT business use percentage

fbt_private_use

FBT private use percentage

fbt_benefit_pre_contribution

FBT benefit before employee contribution

employee_contribution_ytd

Employee contribution year to date

fbt_benefit_net

FBT benefit net value

fbt_benefit_reportable

FBT benefit reportable value

fbt_cost

FBT cost value


Derived Fields financials

Derived fields from the /lib/PDF/financial library

This library is used to calculate financial values such as the NPV.

Input Fields

Field

Source

Rules

amount_financed

fm_contracts > amount_financed

Mandatory

interest_rate

fm_contracts > interest_rate

Mandatory

finance_pmt_regular

fm_contracts > finance_pmt_regular

Mandatory

finance_start

fm_contracts > finance_start

Mandatory

periods_deferred

fm_contracts > periods_deferred

Mandatory

pmt_periods_to_date

Any positive integer

Optional, if not provided a value will be calculated

Output Fields

  • pmt_periods_to_date — Monthly payments to date. If you don't provide this in the Input Fields it will be calculated as follows: Number of months between finance_start and today, minus periods_deferred

  • npv — NPV (Net Present Value)


Derived Fields fuel_performance

Derived fields from the /lib/PDF/fuel_performance library

This library is used to calculate fuel usage values e.g. Litres / 100km. To do this it calculates a km span between the current row and the previous one.

Input Fields

Field

Source

Rules

reg_no

fm_contracts > reg_no

Mandatory

odometer

fm_maintenance > odometer

Mandatory

odometer_valid_flag

fm_maintenance > odometer_valid_flag

Mandatory

litres

fm_maintenance > litres

Mandatory

Output Fields

Field

Description

odometer_span

Odometer for the current record minus the odometer from the previous record

litres_per_100km

Running Litres / 100km for the current transaction

litres_per_100km_group_code

Running Litres / 100km for the current Client Group

litres_per_100km_client_code

Running Litres / 100km for the current Client

litres_per_100km_division

Running Litres / 100km for the current Division

litres_per_100km_cost_centre

Running Litres / 100km for the current Cost Centre

litres_per_100km_reg_no

Running Litres / 100km for the current Reg No


Derived Fields funds_check

Derived fields from the /lib/PDF/funds_check library

This library is used to show the Funds Check pop up screen fields and values.

Library Comment Syntax

## library_type standard ## library_path /lib/PDF ## library_name funds_check 

Input Fields

Field

Source

Rules

contract_id

fm_contracts > contract_id

Mandatory

Output Fields

Path

Library

Description

/lib/PDF

funds_finance_budget

Each Category row delivers a placeholder for its Budget amount. The name is used as the middle section of the placeholder. E.g. finance

/lib/PDF

funds_finance_actual

Placeholder for the category row Actual amount

/lib/PDF

funds_finance_variance

Placeholder for the category row Variance amount

/lib/PDF

funds_finance_available

Placeholder for the category row Available amount

/lib/PDF

funds_finance_posting_class_codes

A delimited list of posting class codes linked to this category stored in fm_budget_categories

/lib/PDF

funds_finance_report_budget_as_actual

Displays the value stored in report_budget_as_actual for this category

/lib/PDF

funds_finance_available_to_claim

Displays the value stored in available_to_claim for this category

/lib/PDF

funds_unmapped_budget

Placeholder for the unmapped Budget amount. This will only report a value if there are posting_classes used that are not stored in fm_budget_categories and linked to a category

/lib/PDF

funds_unmapped_actual

Placeholder for the unmapped Actual amount

/lib/PDF

funds_unmapped_variance

Placeholder for the unmapped Variance amount

/lib/PDF

funds_unmapped_available

Placeholder for the unmapped Available amount

/lib/PDF

funds_unmapped_posting_class_codes

A delimited list of posting class codes that are not stored in fm_budget_categories and linked to a category

/lib/PDF

funds_total_budget

Total for all Budget amounts

/lib/PDF

funds_total_actual

Total for all Actual amounts

/lib/PDF

funds_total_variance

Total for all Variance amounts

/lib/PDF

funds_total_available

Total for all Available amounts

/lib/PDF

funds_received

Funds Received

/lib/PDF

funds_variance

Funds variance (Received less Expected)

/lib/PDF

funds_available_balance

Current Funds Balance (including GST)

/lib/PDF

funds_actual_balance

funds_total_variance + funds_variance


Derived Fields lease_budgets

Derived fields from the /lib/PDF/lease_budgets library

This library is used to derive the GST Overridden flag on the Contract / Lease screen.

Input Fields

Field

Source

Rules

contract_id

fm_contracts > contract_id

Mandatory

billing_period

fm_contract_budgets > billing_period

Mandatory

Output Fields

  • is_gst_overridden_flag — Calculates GST from the net values of all budgets, including an adjusting value in the largest budget, and then compares with the actual GST values. If there are any discrepancies 'yes' is returned otherwise 'no'