How to Track Authorisation Method
Objective
Track every authorisation of an enquiry along with the method (manual or auto) and the order in which the authorisations happened.
View
- 
View Name In BigQuery:
authorisation_method_view - 
Dataset In BigQuery:
bqDatalake 
Columns
| Column Name | Description | 
|---|---|
| EnquiryId | Unique ID of the enquiry. | 
| EnquiryNumber | Enquiry number. | 
| AccountId | Account ID. | 
| ServiceUnitId | Service unit ID. | 
| LeaseId | Lease company ID. | 
| GroupName | Supplier group name. | 
| SupplierName | Supplier name. | 
| LeaseCompanyName | Lease company name. | 
| VRM | Vehicle registration mark (plate number). | 
| Vehicle_Make | Vehicle make (brand). | 
| Vehicle_Model | Vehicle model. | 
| AuthorisedBy | Full name of the user or system who authorised the enquiry. | 
| AuthorisationMethod | How the authorisation happened: 'AUTO' or 'MANUAL'. | 
| AuthorisedOn | Timestamp when the authorisation occurred. | 
| AuthorisationSequence | Sequence number of authorisation (1 = first/initial authorisation, 2nd, 3rd ...). | 
Logic Behind Authorisation Method
- If the authoriser is:
'System Admin'and all the system rules are satisfied,
➔ then AuthorisationMethod = 'AUTO'.- Or if an user authorises it manually from V-customer,
➔ AuthorisationMethod = 'MANUAL'. 
 
How Sequence Number (AuthorisationSequence) is Calculated
- For each EnquiryId,
 - All 
AUTHORISEDevents are ordered by their timestamp (earliest first). - Then row numbers are assigned starting from 1.
 
How to Fetch Data
Example 1: Get all authorisations for a specific Enquiry
SELECT *
FROM `bqDataLake.authorisation_method_view`
WHERE EnquiryId = 'abc123'
ORDER BY AuthorisationSequence ASC;
Example 2: Get only the latest (most recent) authorisation for an Enquiry
SELECT *
FROM `bqDataLake.authorisation_method_view`
WHERE EnquiryId = 'abc123'
ORDER BY AuthorisationSequence DESC
LIMIT 1;
Example 3: Find all Enquiries that were only AUTO-authorised (no manual)
SELECT *
FROM `bqDataLake.authorisation_method_view`
WHERE EnquiryId IN (
  SELECT EnquiryId
  FROM `bqDataLake.authorisation_method_view`
  GROUP BY EnquiryId
  HAVING (COUNT(*) = 1 AND MAX(AuthorisationMethod) = 'AUTO')
     OR COUNTIF(AuthorisationMethod = 'AUTO') = COUNT(*)
);
Example 4: Find all Enquiries where the first authorisations were AUTO
SELECT * FROM `bqDataLake.authorisation_method_view`
where AuthorisationSequence = 1 and AuthorisationMethod = 'AUTO'
✨ Authorisation Process Flow
Status: Accepted
Category: Protected
Authored By: Vignesh Kanthimathinathan on Apr 29, 2025