<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki-reporting.qms-portal.aero/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Collins.bahati</id>
	<title>PBI Reporting Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-reporting.qms-portal.aero/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Collins.bahati"/>
	<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Special:Contributions/Collins.bahati"/>
	<updated>2026-05-31T08:04:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Trouble_Shooting_%26_FAQs&amp;diff=549</id>
		<title>Trouble Shooting &amp; FAQs</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Trouble_Shooting_%26_FAQs&amp;diff=549"/>
		<updated>2026-04-16T09:43:19Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Troubleshooting Row Level Security (RLS ==&lt;br /&gt;
&#039;&#039;&#039;1.    Purpose&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This section provides a structured approach to diagnosing and resolving issues related to Row Level Security (RLS).&lt;br /&gt;
&lt;br /&gt;
The objective is to ensure that:&lt;br /&gt;
&lt;br /&gt;
·        Users see only the data they are authorized to access. &lt;br /&gt;
&lt;br /&gt;
·        Access issues such as &#039;&#039;&#039;no data visibility&#039;&#039;&#039; or &#039;&#039;&#039;overexposure of data&#039;&#039;&#039; are quickly identified and resolved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2.    Common RLS Issues&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Issue&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|No Data Visible&lt;br /&gt;
|User opens report but sees blank visuals&lt;br /&gt;
|-&lt;br /&gt;
|Excess Data Visible&lt;br /&gt;
|User sees more data than expected&lt;br /&gt;
|-&lt;br /&gt;
|Partial Data&lt;br /&gt;
|Some expected data is missing&lt;br /&gt;
|-&lt;br /&gt;
|Inconsistent Results&lt;br /&gt;
|Data differs between Desktop and Service&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Key Troubleshooting Areas&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.1 User Identity Validation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
RLS is driven by the logged-in user identity using:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;USERNAME()&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Confirm that the email used in the RLS DAX &#039;&#039;&#039;exactly matches&#039;&#039;&#039; the user’s login email. &lt;br /&gt;
** Ensure there are no spelling errors or domain mismatches &#039;&#039;&#039;3.2 Data Availability Validation&#039;&#039;&#039; RLS only filters existing data. If the filtered values do not exist in the dataset, the user will see no data.  &#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
** Confirm     that the dataset contains the expected values.  Example:&lt;br /&gt;
** Allowed in RLS: GROUPAIR &lt;br /&gt;
** Available in dataset: HAE, AIRCROSS   Result:&lt;br /&gt;
** No     data will be returned.   &#039;&#039;&#039;Resolution:&#039;&#039;&#039;  Ensure that all values referenced in the RLS logic exist in the dataset.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.3 RLS DAX Logic Validation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Incorrect DAX logic is a common cause of RLS failure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Common Issues:&lt;br /&gt;
&lt;br /&gt;
Incorrect Logical Conditions&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;[Database] = &amp;quot;HAE&amp;quot; &amp;amp;&amp;amp; [Database] = &amp;quot;AIRCROSS&amp;quot;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This condition will never be true&lt;br /&gt;
&lt;br /&gt;
Correct Approach&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;[Database] IN {&amp;quot;HAE&amp;quot;, &amp;quot;AIRCROSS&amp;quot;}&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Incorrect Default Condition&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF (&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   USERNAME () = &amp;quot;user@email.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   [Database] = &amp;quot;HAE&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   FALSE ()&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This blocks all other users completely.&lt;br /&gt;
&lt;br /&gt;
Recommended Structure&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   USERNAME() = &amp;quot;user@email.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   [Database] IN {&amp;quot;HAE&amp;quot;,&amp;quot;AIRCROSS&amp;quot;},&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       USERNAME() IN {Admin_List},&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       TRUE(),&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       FALSE()&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   )&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.4 Role Assignment in Power BI Service&#039;&#039;&#039;&lt;br /&gt;
Even with correct DAX logic, users will not see data if they are not assigned to the RLS role.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Navigate to: &#039;&#039;&#039;Power BI Service → Dataset → Security&#039;&#039;&#039; Confirm the user is added to the correct role. &amp;lt;br /&amp;gt;&#039;&#039;&#039;3.5 Data Model Relationships&#039;&#039;&#039;  RLS filters propagate through relationships between tables.  &#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
** Ensure     relationships are: &lt;br /&gt;
*** Active      &lt;br /&gt;
*** Correctly configured &lt;br /&gt;
** Confirm RLS is applied on the correct table containing the filtering column (e.g. Database). &#039;&#039;&#039;3.6 Report-Level Filters&#039;&#039;&#039; Report, page, or visual filters may override RLS.        &#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
** Review: &lt;br /&gt;
*** Report filters &lt;br /&gt;
*** Page filters &lt;br /&gt;
*** Visual filters &lt;br /&gt;
*** Slicers        &#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
** RLS allows HAE &lt;br /&gt;
** Report filter is set to ACS   Result:&lt;br /&gt;
** No data displayed &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.7 Data Consistency and Formatting&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Text mismatches can cause filters to fail.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Checks:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Case     sensitivity: &lt;br /&gt;
** &amp;quot;HAE&amp;quot;  vs &amp;quot;hae&amp;quot; &lt;br /&gt;
* Trailing     spaces: &lt;br /&gt;
** &amp;quot;HAE      &amp;quot; vs &amp;quot;HAE&amp;quot; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Recommended Fix:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
UPPER([Database]) = &amp;quot;HAE&amp;quot; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. RLS Testing Procedure&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4.1 Testing in Power BI Desktop&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Navigate to:&lt;br /&gt;
&lt;br /&gt;
Model → View As&lt;br /&gt;
&lt;br /&gt;
  Enter the user’s email. &lt;br /&gt;
&lt;br /&gt;
 Validate visible data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4.2 Testing in Power BI Service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
   Go to Dataset → Security&lt;br /&gt;
&lt;br /&gt;
    Use Test as Role &lt;br /&gt;
&lt;br /&gt;
   Confirm expected results &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. Standard Troubleshooting Workflow&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;    When a user reports an issue, follow this sequence:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# Verify USERNAME () output&lt;br /&gt;
# Confirm user is assigned to role&lt;br /&gt;
# Check if required data exists in dataset&lt;br /&gt;
# Validate RLS DAX logic&lt;br /&gt;
# Inspect relationships in data model&lt;br /&gt;
# Remove report-level filters&lt;br /&gt;
# Test using “View As”8. Refresh dataset&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=542</id>
		<title>Row Level Security Setup Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=542"/>
		<updated>2026-04-08T11:17:31Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&#039;&#039;&#039;Power BI Row Level Security (RLS) Documentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sample Report: Global HAE Booking Summary Dashboard&lt;br /&gt;
&lt;br /&gt;
Purpose: Control user access to report data based on database permissions.&lt;br /&gt;
&lt;br /&gt;
Prepared by: PBI Team&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Purpose of This Document&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This guide outlines the &#039;&#039;&#039;Row Level Security (RLS) configuration and management process&#039;&#039;&#039; implemented in the Power BI reports.&lt;br /&gt;
&lt;br /&gt;
Sample report used is the Global HAE Booking Summary Dashboard.&lt;br /&gt;
&lt;br /&gt;
The RLS is applied the same way across all the reports.&lt;br /&gt;
&lt;br /&gt;
The goal of RLS is to ensure that:&lt;br /&gt;
&lt;br /&gt;
·        Users only see &#039;&#039;&#039;data relevant to their authorized databases&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Certain administrators have &#039;&#039;&#039;unrestricted access to all data&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Access is controlled securely and consistently across the company.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Overview of the RLS Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The RLS model uses the user email identification to determine which data a user is allowed to see.&lt;br /&gt;
&lt;br /&gt;
PowerBI identifies the logged in user using:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;USERNAME()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The function returns the email address of the user who is currently accessing the report.&lt;br /&gt;
&lt;br /&gt;
The system then applies DAX logic to determine the data that the user can view.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Access Categories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Users are divided into two access levels&lt;br /&gt;
&lt;br /&gt;
Restricted Access Users&lt;br /&gt;
&lt;br /&gt;
Unrestricted Access Users&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.1 Restricted Access Users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the users who can access specific databases/sites/carriers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|Email&lt;br /&gt;
|Access Level&lt;br /&gt;
|Role  Name&lt;br /&gt;
|-&lt;br /&gt;
|neil.cross@groupair.aero&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_NEIL&lt;br /&gt;
|-&lt;br /&gt;
|andy.smith@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_ANDY&lt;br /&gt;
|-&lt;br /&gt;
|blake.attley@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_BLAKE&lt;br /&gt;
|-&lt;br /&gt;
|charlie.storcks@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_CHARLIE&lt;br /&gt;
|-&lt;br /&gt;
|alyne.fukuda@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_ALYNE&lt;br /&gt;
|-&lt;br /&gt;
|cecilia.ngure@datacair.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_NGURE&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;3.2 Unrestricted Access Users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the users who have full access to all databases/sites/carriers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|Email&lt;br /&gt;
|Access&lt;br /&gt;
|Role  Name&lt;br /&gt;
|-&lt;br /&gt;
|ian.hutchinson@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|steve.dickinson@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|richard.arrowsmith@datacair.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|john.ward@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|brian.virgo@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;4. RLS Logic Structure&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The RLS rules are implemented using &#039;&#039;&#039;conditional DAX expressions&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Example structure:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  USERNAME() = &amp;quot;specific_user@email.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  &amp;lt;restricted access rule&amp;gt;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       USERNAME() IN {list_of_admin_users},&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       TRUE(),&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       FALSE()&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  )&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Explanation:&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|USERNAME()&lt;br /&gt;
|Identifies the  current user&lt;br /&gt;
|-&lt;br /&gt;
|Restricted Rule&lt;br /&gt;
|Defines database  access&lt;br /&gt;
|-&lt;br /&gt;
|Admin List&lt;br /&gt;
|Allows full access&lt;br /&gt;
|-&lt;br /&gt;
|TRUE()&lt;br /&gt;
|Access granted&lt;br /&gt;
|-&lt;br /&gt;
|FALSE()&lt;br /&gt;
|Access denied&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;5. Example RLS Implementation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Example for &#039;&#039;&#039;Cecilia Ngure&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
She has access to:&lt;br /&gt;
&lt;br /&gt;
·        HAE database with specific site access- ‘NBO’ and ‘HFZCO/Dubai’&lt;br /&gt;
&lt;br /&gt;
·        AIRCROSS database with all associated sites access.&lt;br /&gt;
&lt;br /&gt;
·        GROUPAIR database with all associated sites access.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  USERNAME() = &amp;quot;cecilia.ngure@datacair.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  (&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;HAE&amp;quot; &amp;amp;&amp;amp; [Sites] IN { &amp;quot;NBO&amp;quot;, &amp;quot;HFZCO/Dubai&amp;quot; }) ||&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;AIRCROSS&amp;quot;) ||&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;GROUPAIR&amp;quot;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  ),  // Cecilia&#039;s specific access&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      USERNAME() IN {&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;ian.hutchinson@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;steve.dickinson@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;richard.arrowsmith@datacair.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;john.ward@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;brian.virgo@haegroup.com&amp;quot;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   &#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      },&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      TRUE(),  // Unrestricted access for listed users&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;FALSE() // Default condition: restricted access&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  )&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. RLS Implementation Process&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;        &#039;&#039;&#039;Step 1 — Define Access Requirements&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Before configuring RLS, determine:&lt;br /&gt;
&lt;br /&gt;
·        Which &#039;&#039;&#039;database(s)&#039;&#039;&#039; the user should access.&lt;br /&gt;
&lt;br /&gt;
·        Whether the user needs &#039;&#039;&#039;restricted or unrestricted access&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;        &#039;&#039;&#039;Step 2 — Create or Modify RLS in Power BI Desktop&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the report in Power BI Desktop.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Navigate to:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Model View&lt;br /&gt;
&lt;br /&gt;
Manage Role&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 3 — Publish the Dataset&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once RLS is configured:&lt;br /&gt;
&lt;br /&gt;
1.   Save the report.&lt;br /&gt;
&lt;br /&gt;
2.   Publish the dataset to &#039;&#039;&#039;Power BI Service&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 4 — Assign Users to the Role&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Power BI Service&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Workspace&lt;br /&gt;
&lt;br /&gt;
Dataset&lt;br /&gt;
&lt;br /&gt;
Security&lt;br /&gt;
&lt;br /&gt;
Add the user email to the appropriate &#039;&#039;&#039;RLS Role&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 5 — Test the RLS Configuration&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Testing must be done before sharing the report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Testing in Power BI Desktop&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1.   Go to &#039;&#039;&#039;Model View&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
2.   Select &#039;&#039;&#039;View As&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3.   Enter the user email&lt;br /&gt;
&lt;br /&gt;
4.   Confirm that the correct data appears&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Testing in Power BI Service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1.   Open the dataset&lt;br /&gt;
&lt;br /&gt;
2.   Select &#039;&#039;&#039;Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3.   Click &#039;&#039;&#039;Test as Role&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Verify that the user can only see the intended data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;7. Access Management Guidelines&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To maintain security:&lt;br /&gt;
&lt;br /&gt;
·        Grant &#039;&#039;&#039;minimum required access&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
·        Review user permissions periodically&lt;br /&gt;
&lt;br /&gt;
·        Remove access for inactive users&lt;br /&gt;
&lt;br /&gt;
·        Document all new access requests&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;8. Maintenance Process&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
RLS should be reviewed when:&lt;br /&gt;
&lt;br /&gt;
·        A new user requires access&lt;br /&gt;
&lt;br /&gt;
·        A database is added&lt;br /&gt;
&lt;br /&gt;
·        An employee leaves the organization&lt;br /&gt;
&lt;br /&gt;
·        Report requirements change&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;9. Change Management&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All RLS changes must follow this process:&lt;br /&gt;
&lt;br /&gt;
1.   Request received&lt;br /&gt;
&lt;br /&gt;
2.   Access verified by management&lt;br /&gt;
&lt;br /&gt;
3.   RLS updated in Power BI&lt;br /&gt;
&lt;br /&gt;
4.   Changes tested&lt;br /&gt;
&lt;br /&gt;
5.   Dataset republished&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10. Responsible Personnel.&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&#039;&#039;&#039;RLS  Development&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;BI Developers&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Access  Approval&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Management&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Dataset  Maintenance&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;BI Developers&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=541</id>
		<title>Row Level Security Setup Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=541"/>
		<updated>2026-04-08T11:13:33Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&#039;&#039;&#039;Power BI Row Level Security (RLS) Documentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sample Report: Global HAE Booking Summary Dashboard&lt;br /&gt;
&lt;br /&gt;
Purpose: Control user access to report data based on database permissions.&lt;br /&gt;
&lt;br /&gt;
Prepared by: PBI Team&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Purpose of This Document&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This guide outlines the &#039;&#039;&#039;Row Level Security (RLS) configuration and management process&#039;&#039;&#039; implemented in the Power BI reports.&lt;br /&gt;
&lt;br /&gt;
Sample report used is the Global HAE Booking Summary Dashboard.&lt;br /&gt;
&lt;br /&gt;
The RLS is applied the same way across all the reports.&lt;br /&gt;
&lt;br /&gt;
The goal of RLS is to ensure that:&lt;br /&gt;
&lt;br /&gt;
·        Users only see &#039;&#039;&#039;data relevant to their authorized databases&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Certain administrators have &#039;&#039;&#039;unrestricted access to all data&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Access is controlled securely and consistently across the company.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Overview of the RLS Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The RLS model uses the user email identification to determine which data a user is allowed to see.&lt;br /&gt;
&lt;br /&gt;
PowerBI identifies the logged in user using:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;USERNAME()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The function returns the email address of the user who is currently accessing the report.&lt;br /&gt;
&lt;br /&gt;
The system then applies DAX logic to determine the data that the user can view.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Access Categories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Users are divided into two access levels&lt;br /&gt;
&lt;br /&gt;
Restricted Access Users&lt;br /&gt;
&lt;br /&gt;
Unrestricted Access Users&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3.1 Restricted Access Users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the users who can access specific databases/sites/carriers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|Email&lt;br /&gt;
|Access Level&lt;br /&gt;
|Role  Name&lt;br /&gt;
|-&lt;br /&gt;
|neil.cross@groupair.aero&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_NEIL&lt;br /&gt;
|-&lt;br /&gt;
|andy.smith@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_ANDY&lt;br /&gt;
|-&lt;br /&gt;
|blake.attley@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_BLAKE&lt;br /&gt;
|-&lt;br /&gt;
|charlie.storcks@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_CHARLIE&lt;br /&gt;
|-&lt;br /&gt;
|alyne.fukuda@haegroup.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_ALYNE&lt;br /&gt;
|-&lt;br /&gt;
|cecilia.ngure@datacair.com&lt;br /&gt;
|Restricted&lt;br /&gt;
|GLOBAL(HAE)_NGURE&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;3.2 Unrestricted Access Users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the users who have full access to all databases/sites/carriers.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|Email&lt;br /&gt;
|Access&lt;br /&gt;
|Role  Name&lt;br /&gt;
|-&lt;br /&gt;
|ian.hutchinson@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|steve.dickinson@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|richard.arrowsmith@datacair.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|john.ward@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|-&lt;br /&gt;
|brian.virgo@haegroup.com&lt;br /&gt;
|Unrestricted&lt;br /&gt;
|GLOBAL(HAE)_ALL&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;4. RLS Logic Structure&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The RLS rules are implemented using &#039;&#039;&#039;conditional DAX expressions&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Example structure:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  USERNAME() = &amp;quot;specific_user@email.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  &amp;lt;restricted access rule&amp;gt;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       USERNAME() IN {list_of_admin_users},&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       TRUE(),&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;       FALSE()&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  )&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Explanation:&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|USERNAME()&lt;br /&gt;
|Identifies the  current user&lt;br /&gt;
|-&lt;br /&gt;
|Restricted Rule&lt;br /&gt;
|Defines database  access&lt;br /&gt;
|-&lt;br /&gt;
|Admin List&lt;br /&gt;
|Allows full access&lt;br /&gt;
|-&lt;br /&gt;
|TRUE()&lt;br /&gt;
|Access granted&lt;br /&gt;
|-&lt;br /&gt;
|FALSE()&lt;br /&gt;
|Access denied&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;5. Example RLS Implementation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Example for &#039;&#039;&#039;Cecilia Ngure&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
She has access to:&lt;br /&gt;
&lt;br /&gt;
·        HAE database with specific site access- ‘NBO’ and ‘HFZCO/Dubai’&lt;br /&gt;
&lt;br /&gt;
·        AIRCROSS database with all associated sites access.&lt;br /&gt;
&lt;br /&gt;
·        GROUPAIR database with all associated sites access.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  USERNAME() = &amp;quot;cecilia.ngure@datacair.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  (&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;HAE&amp;quot; &amp;amp;&amp;amp; [Sites] IN { &amp;quot;NBO&amp;quot;, &amp;quot;HFZCO/Dubai&amp;quot; }) ||&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;AIRCROSS&amp;quot;) ||&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      ([Database] = &amp;quot;GROUPAIR&amp;quot;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  ),  // Cecilia&#039;s specific access&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  IF(&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      USERNAME() IN {&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;ian.hutchinson@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;steve.dickinson@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;richard.arrowsmith@datacair.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;john.ward@haegroup.com&amp;quot;,&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;          &amp;quot;brian.virgo@haegroup.com&amp;quot;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;   &#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      },&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;      TRUE(),  // Unrestricted access for listed users&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;FALSE() // Default condition: restricted access&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;  )&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;)&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. RLS Implementation Process&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;        &#039;&#039;&#039;Step 1 — Define Access Requirements&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Before configuring RLS, determine:&lt;br /&gt;
&lt;br /&gt;
·        Which &#039;&#039;&#039;database(s)&#039;&#039;&#039; the user should access.&lt;br /&gt;
&lt;br /&gt;
·        Whether the user needs &#039;&#039;&#039;restricted or unrestricted access&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;        &#039;&#039;&#039;Step 2 — Create or Modify RLS in Power BI Desktop&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the report in Power BI Desktop.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Navigate to:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Model View&lt;br /&gt;
&lt;br /&gt;
Manage Role&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 3 — Publish the Dataset&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once RLS is configured:&lt;br /&gt;
&lt;br /&gt;
1.   Save the report.&lt;br /&gt;
&lt;br /&gt;
2.   Publish the dataset to &#039;&#039;&#039;Power BI Service&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 4 — Assign Users to the Role&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Power BI Service&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Workspace&lt;br /&gt;
&lt;br /&gt;
Dataset&lt;br /&gt;
&lt;br /&gt;
Security&lt;br /&gt;
&lt;br /&gt;
Add the user email to the appropriate &#039;&#039;&#039;RLS Role&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Step 5 — Test the RLS Configuration&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Testing must be done before sharing the report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Testing in Power BI Desktop&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1.   Go to &#039;&#039;&#039;Model View&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
2.   Select &#039;&#039;&#039;View As&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3.   Enter the user email&lt;br /&gt;
&lt;br /&gt;
4.   Confirm that the correct data appears&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Testing in Power BI Service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1.   Open the dataset&lt;br /&gt;
&lt;br /&gt;
2.   Select &#039;&#039;&#039;Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3.   Click &#039;&#039;&#039;Test as Role&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Verify that the user can only see the intended data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;7. Access Management Guidelines&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To maintain security:&lt;br /&gt;
&lt;br /&gt;
·        Grant &#039;&#039;&#039;minimum required access&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
·        Review user permissions periodically&lt;br /&gt;
&lt;br /&gt;
·        Remove access for inactive users&lt;br /&gt;
&lt;br /&gt;
·        Document all new access requests&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;8. Maintenance Process&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
RLS should be reviewed when:&lt;br /&gt;
&lt;br /&gt;
·        A new user requires access&lt;br /&gt;
&lt;br /&gt;
·        A database is added&lt;br /&gt;
&lt;br /&gt;
·        An employee leaves the organization&lt;br /&gt;
&lt;br /&gt;
·        Report requirements change&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;9. Change Management&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All RLS changes must follow this process:&lt;br /&gt;
&lt;br /&gt;
1.   Request received&lt;br /&gt;
&lt;br /&gt;
2.   Access verified by management&lt;br /&gt;
&lt;br /&gt;
3.   RLS updated in Power BI&lt;br /&gt;
&lt;br /&gt;
4.   Changes tested&lt;br /&gt;
&lt;br /&gt;
5.   Dataset republished&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10. Responsible Personnel.&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&#039;&#039;&#039;RLS  Development&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;BI Developers&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Access  Approval&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Management&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Dataset  Maintenance&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;BI Developers&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=540</id>
		<title>Row Level Security Setup Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=540"/>
		<updated>2026-04-07T14:14:03Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Power BI Row Level Security (RLS) Documentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sample Report: Global HAE Booking Summary Dashboard&lt;br /&gt;
&lt;br /&gt;
Dataset: Email Reporting Dataset&lt;br /&gt;
&lt;br /&gt;
Prepared by: PBI Team &lt;br /&gt;
&lt;br /&gt;
Purpose: Control user access to report data based on database permissions.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Purpose of This Document&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This document outlines the &#039;&#039;&#039;Row Level Security (RLS) configuration and management process&#039;&#039;&#039; implemented in the Power BI Global HAE Booking Report.&lt;br /&gt;
&lt;br /&gt;
The goal of RLS is to ensure that:&lt;br /&gt;
&lt;br /&gt;
·        Users only see &#039;&#039;&#039;data relevant to their authorized databases&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Certain administrators have &#039;&#039;&#039;unrestricted access to all data&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Access is controlled securely and consistently across the company.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Overview of the RLS Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The RLS model uses the user email identification to determine which data a user is allowed to see.&lt;br /&gt;
&lt;br /&gt;
PowerBI identifies the logged in user using:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;USERNAME()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The function returns the email address of the user who is currently accessing the report.&lt;br /&gt;
&lt;br /&gt;
The system then applies DAX logic to determine the data that the user can view.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Access Categories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Users are divided into two access levels&lt;br /&gt;
&lt;br /&gt;
            Restricted Access Users&lt;br /&gt;
&lt;br /&gt;
Unrestricted Access Users&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=539</id>
		<title>Row Level Security Setup Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Row_Level_Security_Setup_Guide&amp;diff=539"/>
		<updated>2026-04-07T14:11:26Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Power BI Row Level Security (RLS) Documentation&lt;br /&gt;
&lt;br /&gt;
Sample Report: Global HAE Booking Summary Dashboard&lt;br /&gt;
&lt;br /&gt;
Dataset: Email Reporting Dataset&lt;br /&gt;
&lt;br /&gt;
Prepared by: PBI Team &lt;br /&gt;
&lt;br /&gt;
Purpose: Control user access to report data based on database permissions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;1.&#039;&#039;&#039; Purpose of This Document&lt;br /&gt;
&lt;br /&gt;
This document outlines the &#039;&#039;&#039;Row Level Security (RLS) configuration and management process&#039;&#039;&#039; implemented in the Power BI Global HAE Booking Report.&lt;br /&gt;
&lt;br /&gt;
The goal of RLS is to ensure that:&lt;br /&gt;
&lt;br /&gt;
·        Users only see &#039;&#039;&#039;data relevant to their authorized databases&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Certain administrators have &#039;&#039;&#039;unrestricted access to all data&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
·        Access is controlled securely and consistently across the company.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Overview of the RLS Design&lt;br /&gt;
&lt;br /&gt;
The RLS model uses the user email identification to determine which data a user is allowed to see.&lt;br /&gt;
&lt;br /&gt;
PowerBI identifies the logged in user using:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;USERNAME()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The function returns the email address of the user who is currently accessing the report.&lt;br /&gt;
&lt;br /&gt;
The system then applies DAX logic to determine the data that the user can view.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Access Categories&lt;br /&gt;
&lt;br /&gt;
Users are divided into two access levels&lt;br /&gt;
&lt;br /&gt;
·         Restricted Access Users&lt;br /&gt;
&lt;br /&gt;
Unrestricted Access Users&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=497</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=497"/>
		<updated>2026-02-19T08:19:27Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|-&lt;br /&gt;
|Date Range&lt;br /&gt;
|The date range is linked to the depart date. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|quotations&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039;, &#039;&#039;&#039;depart_date&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_carriers&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039;, &#039;&#039;&#039;main_carrier_id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, &#039;&#039;&#039;carrier_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;carrier_id&#039;&#039;&#039;, &#039;&#039;&#039;Carrier&#039;&#039;&#039;, &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Kept only rows where &#039;&#039;&#039;quotation_carriers.carrier_id = 250&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|hae_booking_db carriers&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;sites&#039;&#039;&#039; on &#039;&#039;&#039;site_id&#039;&#039;&#039; and &#039;&#039;&#039;id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;name&#039;&#039;&#039; from &#039;&#039;&#039;sites&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;hae_booking_db sites.name&#039;&#039;&#039; to &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_totals_local&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;total_cost&#039;&#039;&#039; → &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039;  &#039;&#039;&#039;total_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Invoice Customer Total (Sales BRL)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;HAE Over&#039;&#039;&#039; = &#039;&#039;&#039;total_sell_rate - total_cost_rate&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_charges&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column&#039;&#039;&#039;: &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column Again&#039;&#039;&#039;: &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039; → &#039;&#039;&#039;HAE Commission Currency (USD)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_routes&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, &#039;&#039;&#039;currency&#039;&#039;&#039;, &#039;&#039;&#039;currency_sell&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;cost_rate&#039;&#039;&#039; → &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;  &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;Selling Rate&#039;&#039;&#039;  &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Buying Currency&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;Sell Rate Currency&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Mode of Payment)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (AWB Issue Date)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;AWB Issue Date Final&#039;&#039;&#039; = if &#039;&#039;&#039;AWB Issue Date = &amp;quot;&amp;quot;&#039;&#039;&#039; then &#039;&#039;&#039;&amp;quot;NODATA&amp;quot;&#039;&#039;&#039; else &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Due Agent)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Due Agent&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, retained max of &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_exchange_Original&#039;&#039;&#039; on &#039;&#039;&#039;quotation_id&#039;&#039;&#039; and &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;, &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_exchange_Original.exchange_rate&#039;&#039;&#039; → &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;  &#039;&#039;&#039;quotation_exchange_Original.is_fixed&#039;&#039;&#039; → &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_Original&lt;br /&gt;
|&#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_chargesHAE_TAX&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Initial filter kept all, then second filter kept rows where &#039;&#039;&#039;HAE Tax (charge currency) = USD&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;sell_min&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax (charge currency)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_route_partsOriginal&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_routes_flight_number.quotation_id&#039;&#039;&#039; → &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_flight_number&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, selected &#039;&#039;&#039;Min(id)&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_route_partsOriginal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;flight_number&#039;&#039;&#039;, &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_route_partsOriginal.flight_number&#039;&#039;&#039; → &#039;&#039;&#039;flight_number&#039;&#039;&#039;  &#039;&#039;&#039;quotation_route_partsOriginal.carrier_code&#039;&#039;&#039; → &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableTotalRevenue&lt;br /&gt;
|To create a table that combines quotation data with revenue-related charge details. This helps in calculating &#039;&#039;&#039;Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
&#039;&#039;&#039;How it works:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* It &#039;&#039;&#039;joins&#039;&#039;&#039; the quotations table with the quotations_total_revenue table using matching quotation IDs.&lt;br /&gt;
* From the joined data, it &#039;&#039;&#039;selects&#039;&#039;&#039; only these columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; – the quotation ID&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; – used in revenue calculation&lt;br /&gt;
** &#039;&#039;&#039;Code&#039;&#039;&#039; – type of charge (e.g., LINEHAUL, DTC)&lt;br /&gt;
** &#039;&#039;&#039;Sell Rate&#039;&#039;&#039; – rate per weight unit&lt;br /&gt;
** &#039;&#039;&#039;Sell Min&#039;&#039;&#039; – minimum selling value&lt;br /&gt;
&lt;br /&gt;
This table is then used in the revenue formula that applies different logic depending on the charge code.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierUSD&lt;br /&gt;
|&#039;&#039;&#039;Purpose:&#039;&#039;&#039;&lt;br /&gt;
To create a clean table for calculating Due Carrier USD, excluding rows where the charge code is LINEHAUL.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use three tables: &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; (a filtered version of quotation_charges), and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Join &#039;&#039;&#039;quotations&#039;&#039;&#039; with &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; using a natural inner join.&lt;br /&gt;
* Then join the result with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; using another natural inner join.&lt;br /&gt;
* Select the following columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
* Use &#039;&#039;&#039;DISTINCT&#039;&#039;&#039; to remove any duplicate rows.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierTotal&lt;br /&gt;
|To create a unified table that includes &#039;&#039;&#039;all carrier charges&#039;&#039;&#039; (including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;) for calculating &#039;&#039;&#039;Total Due Carrier USD&#039;&#039;&#039; values.&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Start with the &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;, and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; tables.&lt;br /&gt;
* Perform a &#039;&#039;&#039;natural inner join&#039;&#039;&#039; between &#039;&#039;&#039;quotations&#039;&#039;&#039; and &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
* Then perform another &#039;&#039;&#039;natural inner join&#039;&#039;&#039; with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Use &#039;&#039;&#039;SELECTCOLUMNS&#039;&#039;&#039; to extract the following fields:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierTotal&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate =&lt;br /&gt;
IF(&lt;br /&gt;
&lt;br /&gt;
    quotation_exchange_rates[is_fixed] = TRUE(),&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;✓&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;×&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|Buying Rate = quotation_routes[cost_rate]&lt;br /&gt;
|&#039;&#039;&#039;Join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_routes&#039;&#039;&#039; table (filtered where &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, &#039;&#039;&#039;filtered where code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;.&lt;br /&gt;
From this joined data, &#039;&#039;&#039;extract the cost_rate&#039;&#039;&#039; field and rename it as &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; =&lt;br /&gt;
quotation_routes[Buying Rate] × RELATED(quotations[chargeable_weight])&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|Due Carrier USD =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Rate] * QuotationCombinedTableDueCarrierUSD[Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;GR&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Rate] * QuotationCombinedTableDueCarrierUSD[Gross Weight],&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Min],&lt;br /&gt;
&lt;br /&gt;
    0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;gross_weight&#039;&#039;&#039; from quotations.&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;GR&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;gross weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;. This version includes all relevant charge codes required to calculate total revenue—specifically LINEHAUL, DTC, and CAC.&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields: &amp;lt;code&amp;gt;quotation_id&amp;lt;/code&amp;gt; (renamed as ID), &amp;lt;code&amp;gt;chargeable_weight&amp;lt;/code&amp;gt; from quotations, and &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sell_rate&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt; from quotation_charges_Total Revenue.&lt;br /&gt;
&lt;br /&gt;
Total Revenue is then calculated using conditional logic per charge code. If &amp;lt;code&amp;gt;code = &amp;quot;LINEHAUL&amp;quot;&amp;lt;/code&amp;gt;, first compute &amp;lt;code&amp;gt;sell_rate × chargeable_weight&amp;lt;/code&amp;gt;, then compare the result to &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt;. If the calculated value is less than &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt;, use &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt;; otherwise, use the calculated value. This ensures that minimum billing logic is enforced and revenue is never below the defined minimum charge.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;code = &amp;quot;DTC&amp;quot;&amp;lt;/code&amp;gt;, use &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;code = &amp;quot;CAC&amp;quot;&amp;lt;/code&amp;gt;, also use &amp;lt;code&amp;gt;sell_min&amp;lt;/code&amp;gt;. For any other charge code, return 0.&lt;br /&gt;
&lt;br /&gt;
Finally, sum all resulting values per quotation to produce the Total Revenue. This updated logic ensures that LINEHAUL revenue respects minimum charge thresholds while DTC and CAC continue to contribute their minimum charges, resulting in accurate and protected revenue calculations.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; =&lt;br /&gt;
SWITCH (&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierTotal[On] = &amp;quot;CH&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
        VAR CalculatedChargeCH =&lt;br /&gt;
&lt;br /&gt;
            QuotationCombinedTableDueCarrierTotal[Cost Rate]&lt;br /&gt;
&lt;br /&gt;
            * QuotationCombinedTableDueCarrierTotal[Chargeable Weight]&lt;br /&gt;
&lt;br /&gt;
        RETURN&lt;br /&gt;
&lt;br /&gt;
            IF (&lt;br /&gt;
&lt;br /&gt;
                CalculatedChargeCH &amp;lt;= QuotationCombinedTableDueCarrierTotal[Cost Min],&lt;br /&gt;
&lt;br /&gt;
                QuotationCombinedTableDueCarrierTotal[Cost Min],&lt;br /&gt;
&lt;br /&gt;
                CalculatedChargeCH&lt;br /&gt;
&lt;br /&gt;
            ),&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierTotal[On] = &amp;quot;GR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
        VAR CalculatedChargeGR =&lt;br /&gt;
&lt;br /&gt;
            QuotationCombinedTableDueCarrierTotal[Cost Rate]&lt;br /&gt;
&lt;br /&gt;
            * QuotationCombinedTableDueCarrierTotal[Gross Weight]&lt;br /&gt;
&lt;br /&gt;
        RETURN&lt;br /&gt;
&lt;br /&gt;
            IF (&lt;br /&gt;
&lt;br /&gt;
                CalculatedChargeGR &amp;lt;= QuotationCombinedTableDueCarrierTotal[Cost Min],&lt;br /&gt;
&lt;br /&gt;
                QuotationCombinedTableDueCarrierTotal[Cost Min],&lt;br /&gt;
&lt;br /&gt;
                CalculatedChargeGR&lt;br /&gt;
&lt;br /&gt;
            ),&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierTotal[On] = &amp;quot;FL&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
        QuotationCombinedTableDueCarrierTotal[Cost Min],&lt;br /&gt;
&lt;br /&gt;
    0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;gross_weight&#039;&#039;&#039; from quotations.&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;GR&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;gross weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=496</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=496"/>
		<updated>2026-02-19T08:12:56Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|-&lt;br /&gt;
|Date Range&lt;br /&gt;
|The date range is linked to the depart date. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|quotations&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039;, &#039;&#039;&#039;depart_date&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_carriers&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039;, &#039;&#039;&#039;main_carrier_id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, &#039;&#039;&#039;carrier_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;carrier_id&#039;&#039;&#039;, &#039;&#039;&#039;Carrier&#039;&#039;&#039;, &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Kept only rows where &#039;&#039;&#039;quotation_carriers.carrier_id = 250&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|hae_booking_db carriers&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;sites&#039;&#039;&#039; on &#039;&#039;&#039;site_id&#039;&#039;&#039; and &#039;&#039;&#039;id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;name&#039;&#039;&#039; from &#039;&#039;&#039;sites&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;hae_booking_db sites.name&#039;&#039;&#039; to &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_totals_local&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;total_cost&#039;&#039;&#039; → &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039;  &#039;&#039;&#039;total_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Invoice Customer Total (Sales BRL)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;HAE Over&#039;&#039;&#039; = &#039;&#039;&#039;total_sell_rate - total_cost_rate&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_charges&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column&#039;&#039;&#039;: &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column Again&#039;&#039;&#039;: &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039; → &#039;&#039;&#039;HAE Commission Currency (USD)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_routes&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, &#039;&#039;&#039;currency&#039;&#039;&#039;, &#039;&#039;&#039;currency_sell&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;cost_rate&#039;&#039;&#039; → &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;  &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;Selling Rate&#039;&#039;&#039;  &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Buying Currency&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;Sell Rate Currency&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Mode of Payment)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (AWB Issue Date)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;AWB Issue Date Final&#039;&#039;&#039; = if &#039;&#039;&#039;AWB Issue Date = &amp;quot;&amp;quot;&#039;&#039;&#039; then &#039;&#039;&#039;&amp;quot;NODATA&amp;quot;&#039;&#039;&#039; else &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Due Agent)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Due Agent&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, retained max of &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_exchange_Original&#039;&#039;&#039; on &#039;&#039;&#039;quotation_id&#039;&#039;&#039; and &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;, &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_exchange_Original.exchange_rate&#039;&#039;&#039; → &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;  &#039;&#039;&#039;quotation_exchange_Original.is_fixed&#039;&#039;&#039; → &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_Original&lt;br /&gt;
|&#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_chargesHAE_TAX&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Initial filter kept all, then second filter kept rows where &#039;&#039;&#039;HAE Tax (charge currency) = USD&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;sell_min&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax (charge currency)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_route_partsOriginal&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_routes_flight_number.quotation_id&#039;&#039;&#039; → &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_flight_number&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, selected &#039;&#039;&#039;Min(id)&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_route_partsOriginal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;flight_number&#039;&#039;&#039;, &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_route_partsOriginal.flight_number&#039;&#039;&#039; → &#039;&#039;&#039;flight_number&#039;&#039;&#039;  &#039;&#039;&#039;quotation_route_partsOriginal.carrier_code&#039;&#039;&#039; → &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableTotalRevenue&lt;br /&gt;
|To create a table that combines quotation data with revenue-related charge details. This helps in calculating &#039;&#039;&#039;Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
&#039;&#039;&#039;How it works:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* It &#039;&#039;&#039;joins&#039;&#039;&#039; the quotations table with the quotations_total_revenue table using matching quotation IDs.&lt;br /&gt;
* From the joined data, it &#039;&#039;&#039;selects&#039;&#039;&#039; only these columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; – the quotation ID&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; – used in revenue calculation&lt;br /&gt;
** &#039;&#039;&#039;Code&#039;&#039;&#039; – type of charge (e.g., LINEHAUL, DTC)&lt;br /&gt;
** &#039;&#039;&#039;Sell Rate&#039;&#039;&#039; – rate per weight unit&lt;br /&gt;
** &#039;&#039;&#039;Sell Min&#039;&#039;&#039; – minimum selling value&lt;br /&gt;
&lt;br /&gt;
This table is then used in the revenue formula that applies different logic depending on the charge code.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierUSD&lt;br /&gt;
|&#039;&#039;&#039;Purpose:&#039;&#039;&#039;&lt;br /&gt;
To create a clean table for calculating Due Carrier USD, excluding rows where the charge code is LINEHAUL.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use three tables: &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; (a filtered version of quotation_charges), and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Join &#039;&#039;&#039;quotations&#039;&#039;&#039; with &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; using a natural inner join.&lt;br /&gt;
* Then join the result with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; using another natural inner join.&lt;br /&gt;
* Select the following columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
* Use &#039;&#039;&#039;DISTINCT&#039;&#039;&#039; to remove any duplicate rows.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierTotal&lt;br /&gt;
|To create a unified table that includes &#039;&#039;&#039;all carrier charges&#039;&#039;&#039; (including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;) for calculating &#039;&#039;&#039;Total Due Carrier USD&#039;&#039;&#039; values.&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Start with the &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;, and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; tables.&lt;br /&gt;
* Perform a &#039;&#039;&#039;natural inner join&#039;&#039;&#039; between &#039;&#039;&#039;quotations&#039;&#039;&#039; and &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
* Then perform another &#039;&#039;&#039;natural inner join&#039;&#039;&#039; with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Use &#039;&#039;&#039;SELECTCOLUMNS&#039;&#039;&#039; to extract the following fields:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierTotal&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate =&lt;br /&gt;
IF(&lt;br /&gt;
&lt;br /&gt;
    quotation_exchange_rates[is_fixed] = TRUE(),&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;✓&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;×&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|Buying Rate = quotation_routes[cost_rate]&lt;br /&gt;
|&#039;&#039;&#039;Join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_routes&#039;&#039;&#039; table (filtered where &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, &#039;&#039;&#039;filtered where code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;.&lt;br /&gt;
From this joined data, &#039;&#039;&#039;extract the cost_rate&#039;&#039;&#039; field and rename it as &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; =&lt;br /&gt;
quotation_routes[Buying Rate] × RELATED(quotations[chargeable_weight])&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|Due Carrier USD =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Rate] * QuotationCombinedTableDueCarrierUSD[Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;GR&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Rate] * QuotationCombinedTableDueCarrierUSD[Gross Weight],&lt;br /&gt;
&lt;br /&gt;
    QuotationCombinedTableDueCarrierUSD[On] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[Cost Min],&lt;br /&gt;
&lt;br /&gt;
    0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;gross_weight&#039;&#039;&#039; from quotations.&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;GR&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;gross weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the quotation charges table, rename it to:&lt;br /&gt;
&#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
This version includes all relevant charge codes for calculating total revenue—specifically &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039; and &#039;&#039;&#039;DTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quotation_id&#039;&#039;&#039; as ID&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, and &#039;&#039;&#039;sell_min&#039;&#039;&#039; from &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, compute &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; using a conditional logic:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;sell_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;DTC&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total =&#039;&#039;&#039;&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_rate] * QuotationCombinedTableDueCarrierTotal[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=232</id>
		<title>Sales Performance</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=232"/>
		<updated>2025-08-21T10:52:39Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-performance-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Sales Rep Quotes &amp;amp; Conversion Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Issued:&#039;&#039;&#039; Counts all quotations created.&lt;br /&gt;
* &#039;&#039;&#039;% Total Sales Quotes Issued:&#039;&#039;&#039; Calculates each sales representative’s share of total quotes that have &#039;&#039;&#039;not yet been booked&#039;&#039;&#039;, expressed as a percentage of overall sales quotes.&lt;br /&gt;
* &#039;&#039;&#039;Converted Quotes Sales:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the quote date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Converted Quotes Sales:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
|This table evaluates sales activity and conversion performance by representative. It shows how many quotes each representative issued, what portion of unbooked sales quotes they contributed, and how effectively those quotes converted into bookings.&lt;br /&gt;
|-&lt;br /&gt;
|2. Sales Representative Booking Performance Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Booking Sales:&#039;&#039;&#039; Counts all bookings made by a sales representative using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of overall bookings.&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Converted:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Quotes Converted:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
* &#039;&#039;&#039;Direct Booking Sales:&#039;&#039;&#039; Counts bookings made directly (without passing through a quotation) using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Direct Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of total direct bookings.&lt;br /&gt;
|This table evaluates booking performance by representative. It shows how many total bookings each representative created, how many came from converted quotations, and how many were direct bookings. The percentage measures highlight individual contributions to overall sales, while the calculations ensure accurate time-based tracking and a clear view of performance across different bookings.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=231</id>
		<title>Sales Performance</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=231"/>
		<updated>2025-08-21T10:52:06Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Hide Losat/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-performance-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Sales Rep Quotes &amp;amp; Conversion Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Issued:&#039;&#039;&#039; Counts all quotations created.&lt;br /&gt;
* &#039;&#039;&#039;% Total Sales Quotes Issued:&#039;&#039;&#039; Calculates each sales representative’s share of total quotes that have &#039;&#039;&#039;not yet been booked&#039;&#039;&#039;, expressed as a percentage of overall sales quotes.&lt;br /&gt;
* &#039;&#039;&#039;Converted Quotes Sales:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the quote date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Converted Quotes Sales:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
|This table evaluates sales activity and conversion performance by representative. It shows how many quotes each representative issued, what portion of unbooked sales quotes they contributed, and how effectively those quotes converted into bookings.&lt;br /&gt;
|-&lt;br /&gt;
|2. Sales Representative Booking Performance Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Booking Sales:&#039;&#039;&#039; Counts all bookings made by a sales representative using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of overall bookings.&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Converted:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Quotes Converted:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
* &#039;&#039;&#039;Direct Booking Sales:&#039;&#039;&#039; Counts bookings made directly (without passing through a quotation) using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Direct Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of total direct bookings.&lt;br /&gt;
|This table evaluates booking performance by representative. It shows how many total bookings each representative created, how many came from converted quotations, and how many were direct bookings. The percentage measures highlight individual contributions to overall sales, while the calculations ensure accurate time-based tracking and a clear view of performance across different bookings.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=230</id>
		<title>Sales Performance</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=230"/>
		<updated>2025-08-21T10:46:50Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-performance-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Sales Rep Quotes &amp;amp; Conversion Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Issued:&#039;&#039;&#039; Counts all quotations created.&lt;br /&gt;
* &#039;&#039;&#039;% Total Sales Quotes Issued:&#039;&#039;&#039; Calculates each sales representative’s share of total quotes that have &#039;&#039;&#039;not yet been booked&#039;&#039;&#039;, expressed as a percentage of overall sales quotes.&lt;br /&gt;
* &#039;&#039;&#039;Converted Quotes Sales:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the quote date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Converted Quotes Sales:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
|This table evaluates sales activity and conversion performance by representative. It shows how many quotes each representative issued, what portion of unbooked sales quotes they contributed, and how effectively those quotes converted into bookings.&lt;br /&gt;
|-&lt;br /&gt;
|2. Sales Representative Booking Performance Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Booking Sales:&#039;&#039;&#039; Counts all bookings made by a sales representative using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of overall bookings.&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Converted:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Quotes Converted:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
* &#039;&#039;&#039;Direct Booking Sales:&#039;&#039;&#039; Counts bookings made directly (without passing through a quotation) using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Direct Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of total direct bookings.&lt;br /&gt;
|This table evaluates booking performance by representative. It shows how many total bookings each representative created, how many came from converted quotations, and how many were direct bookings. The percentage measures highlight individual contributions to overall sales, while the calculations ensure accurate time-based tracking and a clear view of performance across different bookings.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=229</id>
		<title>Sales Performance</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=229"/>
		<updated>2025-08-21T10:41:33Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-performance-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Sales Rep Quotes &amp;amp; Conversion Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Issued:&#039;&#039;&#039; Counts all quotations created.&lt;br /&gt;
* &#039;&#039;&#039;% Total Sales Quotes Issued:&#039;&#039;&#039; Calculates each sales representative’s share of total quotes that have &#039;&#039;&#039;not yet been booked&#039;&#039;&#039;, expressed as a percentage of overall sales quotes.&lt;br /&gt;
* &#039;&#039;&#039;Converted Quotes Sales:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the quote date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Converted Quotes Sales:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
|This table evaluates sales activity and conversion performance by representative. It shows how many quotes each representative issued, what portion of unbooked sales quotes they contributed, and how effectively those quotes converted into bookings.&lt;br /&gt;
|-&lt;br /&gt;
|2. Sales Representative Booking Performance Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Booking Sales:&#039;&#039;&#039; Counts all bookings made by a sales representative using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of overall bookings.&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Converted:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Quotes Converted:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
* &#039;&#039;&#039;Direct Booking Sales:&#039;&#039;&#039; Counts bookings made directly (without passing through a quotation) using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Direct Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of total direct bookings.&lt;br /&gt;
|This table evaluates booking performance by representative. It shows how many total bookings each representative created, how many came from converted quotations, and how many were direct bookings. The percentage measures highlight individual contributions to overall sales, while the calculations ensure accurate time-based tracking and a clear view of performance across different bookings.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=228</id>
		<title>Sales Performance</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Sales_Performance&amp;diff=228"/>
		<updated>2025-08-21T10:40:42Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-performance-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Sales Rep Quotes &amp;amp; Conversion Table&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Issued:&#039;&#039;&#039; Counts all quotations created.&lt;br /&gt;
* &#039;&#039;&#039;% Total Sales Quotes Issued:&#039;&#039;&#039; Calculates each sales representative’s share of total quotes that have &#039;&#039;&#039;not yet been booked&#039;&#039;&#039;, expressed as a percentage of overall sales quotes.&lt;br /&gt;
* &#039;&#039;&#039;Converted Quotes Sales:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the quote date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Converted Quotes Sales:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
|This table evaluates sales activity and conversion performance by representative. It shows how many quotes each representative issued, what portion of unbooked sales quotes they contributed, and how effectively those quotes converted into bookings.&lt;br /&gt;
|-&lt;br /&gt;
|2.&lt;br /&gt;
|Displays a table with the following measures for each sales representative:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Total Booking Sales:&#039;&#039;&#039; Counts all bookings made by a sales representative using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of overall bookings.&lt;br /&gt;
* &#039;&#039;&#039;Total Quotes Converted:&#039;&#039;&#039; Counts quotations that were issued, booked by a sales rep, and finalized as bookings using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Total Quotes Converted:&#039;&#039;&#039; Shows each representative’s share of total converted quotations.&lt;br /&gt;
* &#039;&#039;&#039;Direct Booking Sales:&#039;&#039;&#039; Counts bookings made directly (without passing through a quotation) using the booking date for time-based tracking.&lt;br /&gt;
* &#039;&#039;&#039;% Direct Booking Sales:&#039;&#039;&#039; Calculates each representative’s share of total direct bookings.&lt;br /&gt;
|This table evaluates booking performance by representative. It shows how many total bookings each representative created, how many came from converted quotations, and how many were direct bookings. The percentage measures highlight individual contributions to overall sales, while the calculations ensure accurate time-based tracking and a clear view of performance across different bookings.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=227</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=227"/>
		<updated>2025-08-21T10:02:23Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|CALCULATE(&lt;br /&gt;
    SUM(quotations[total_cost]), &lt;br /&gt;
&lt;br /&gt;
    quotations[Total_Bookings_Confirmed] = &amp;quot;Confirmed Booking&amp;quot;&lt;br /&gt;
&lt;br /&gt;
) + 0&lt;br /&gt;
|Calculates and formats total confirmed booking costs by currency, excluding currencies with zero revenue. The measure aligns amounts neatly by padding values with spaces and outputs a list showing each total alongside its corresponding currency, separated by line breaks for clear display.&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|CALCULATE(&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at])),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[confirmed_at])),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(quotations[booked_at], DimDate[Date])&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts &#039;&#039;&#039;all bookings&#039;&#039;&#039; that have both a &#039;&#039;&#039;booking date&#039;&#039;&#039; and a &#039;&#039;&#039;confirmation date&#039;&#039;&#039;, using the booking date as the active relationship to provide accurate time-based booking totals.&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|CALCULATE(&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  &lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[quoted_at]),  &lt;br /&gt;
&lt;br /&gt;
    (&lt;br /&gt;
&lt;br /&gt;
        (NOT(ISBLANK(quotations[booked_at])) &amp;amp;&amp;amp; NOT(ISBLANK(quotations[confirmed_at])))  &lt;br /&gt;
&lt;br /&gt;
        ||&lt;br /&gt;
&lt;br /&gt;
        (NOT(ISBLANK(quotations[pre_quoted_at])) &amp;amp;&amp;amp; NOT(ISBLANK(quotations[booked_at])) &amp;amp;&amp;amp; NOT(ISBLANK(quotations[confirmed_at])))  &lt;br /&gt;
&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts &#039;&#039;&#039;all bookings&#039;&#039;&#039; that bypassed the standard quotation stage or originated from &#039;&#039;&#039;pre-quotes&#039;&#039;&#039;, ensuring they are b&#039;&#039;&#039;oth booked and confirmed&#039;&#039;&#039;. This measure uses the booking date for accurate time-based tracking.&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|CALCULATE(&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]), &lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp; &lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at])) &amp;amp;&amp;amp; &lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[confirmed_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|This measure counts the number of quotations that have progressed through all key stages—&#039;&#039;&#039;quoted, booked, and confirmed&#039;&#039;&#039;—using the booking date as the active relationship for time-based analysis. It reflects only fully converted bookings.&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039;- &amp;gt; Sourced directly from the quotations table.&lt;br /&gt;
|This metric captures the &#039;&#039;&#039;chargeable weight&#039;&#039;&#039; exactly as recorded in the quotations table, ensuring accuracy by using the original shipment data without additional calculations or transformations&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates &#039;&#039;&#039;total revenue&#039;&#039;&#039; from &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups it by &#039;&#039;&#039;customer&#039;&#039;&#039; to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest &#039;&#039;&#039;revenue-generating customers&#039;&#039;&#039;, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; (converted quotes that have been finalized as bookings), then groups them by &#039;&#039;&#039;origin&#039;&#039;&#039; to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the &#039;&#039;&#039;total confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;origin&#039;&#039;&#039; location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; (converted quotes that have been finalized as bookings), then groups them by &#039;&#039;&#039;destination&#039;&#039;&#039; to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;destination&#039;&#039;&#039; location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups them by &#039;&#039;&#039;service&#039;&#039;&#039; type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the &#039;&#039;&#039;total confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;service&#039;&#039;&#039; type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|Groups bookings into predefined &#039;&#039;&#039;weight break&#039;&#039;&#039;s and displays three key measures side by side: &#039;&#039;&#039;Total Bookings, Direct Bookings, and Converted Bookings,&#039;&#039;&#039; allowing detailed comparison within each weight category.&lt;br /&gt;
|This matrix table provides a clear breakdown of &#039;&#039;&#039;booking volumes by weight segment&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes c&#039;&#039;&#039;onverted into confirmed bookings&#039;&#039;&#039; for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates &#039;&#039;&#039;total revenue&#039;&#039;&#039; from &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups it by month to show revenue trends over time, plus the &#039;&#039;&#039;respective currencies&#039;&#039;&#039;.&lt;br /&gt;
|This chart provides a clear view of m&#039;&#039;&#039;onthly revenue performance&#039;&#039;&#039;, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|Aggregates the &#039;&#039;&#039;total chargeable weight&#039;&#039;&#039; and groups it by customer to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart displays the &#039;&#039;&#039;total chargeable weight&#039;&#039;&#039; attributed to each customer.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=226</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=226"/>
		<updated>2025-08-21T09:50:22Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039;- &amp;gt; Sourced directly from the quotations table.&lt;br /&gt;
|This metric captures the &#039;&#039;&#039;chargeable weight&#039;&#039;&#039; exactly as recorded in the quotations table, ensuring accuracy by using the original shipment data without additional calculations or transformations&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates &#039;&#039;&#039;total revenue&#039;&#039;&#039; from &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups it by &#039;&#039;&#039;customer&#039;&#039;&#039; to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest &#039;&#039;&#039;revenue-generating customers&#039;&#039;&#039;, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; (converted quotes that have been finalized as bookings), then groups them by &#039;&#039;&#039;origin&#039;&#039;&#039; to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the &#039;&#039;&#039;total confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;origin&#039;&#039;&#039; location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; (converted quotes that have been finalized as bookings), then groups them by &#039;&#039;&#039;destination&#039;&#039;&#039; to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;destination&#039;&#039;&#039; location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups them by &#039;&#039;&#039;service&#039;&#039;&#039; type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the &#039;&#039;&#039;total confirmed bookings&#039;&#039;&#039; for each &#039;&#039;&#039;service&#039;&#039;&#039; type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|Groups bookings into predefined &#039;&#039;&#039;weight break&#039;&#039;&#039;s and displays three key measures side by side: &#039;&#039;&#039;Total Bookings, Direct Bookings, and Converted Bookings,&#039;&#039;&#039; allowing detailed comparison within each weight category.&lt;br /&gt;
|This matrix table provides a clear breakdown of &#039;&#039;&#039;booking volumes by weight segment&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes c&#039;&#039;&#039;onverted into confirmed bookings&#039;&#039;&#039; for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates &#039;&#039;&#039;total revenue&#039;&#039;&#039; from &#039;&#039;&#039;confirmed bookings&#039;&#039;&#039; and groups it by month to show revenue trends over time, plus the &#039;&#039;&#039;respective currencies&#039;&#039;&#039;.&lt;br /&gt;
|This chart provides a clear view of m&#039;&#039;&#039;onthly revenue performance&#039;&#039;&#039;, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|Aggregates the &#039;&#039;&#039;total chargeable weight&#039;&#039;&#039; and groups it by customer to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart displays the &#039;&#039;&#039;total chargeable weight&#039;&#039;&#039; attributed to each customer.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=225</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=225"/>
		<updated>2025-08-21T09:46:36Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039;- &amp;gt; Sourced directly from the quotations table.&lt;br /&gt;
|This metric captures the chargeable weight exactly as recorded in the quotations table, ensuring accuracy by using the original shipment data without additional calculations or transformations&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by customer to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest revenue-generating customers, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|Groups bookings into predefined weight breaks and displays three key measures side by side: Total Bookings, Direct Bookings, and Converted Bookings, allowing detailed comparison within each weight category.&lt;br /&gt;
|This matrix table provides a clear breakdown of booking volumes by weight segment.&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes converted into confirmed bookings for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by month to show revenue trends over time, plus the respective currencies.&lt;br /&gt;
|This chart provides a clear view of monthly revenue performance, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|Aggregates the total chargeable weight and groups it by customer to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart displays the total chargeable weight attributed to each customer.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=224</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=224"/>
		<updated>2025-08-21T09:43:26Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by customer to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest revenue-generating customers, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|Groups bookings into predefined weight breaks and displays three key measures side by side: Total Bookings, Direct Bookings, and Converted Bookings, allowing detailed comparison within each weight category.&lt;br /&gt;
|This matrix table provides a clear breakdown of booking volumes by weight segment.&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes converted into confirmed bookings for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by month to show revenue trends over time, plus the respective currencies.&lt;br /&gt;
|This chart provides a clear view of monthly revenue performance, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|Aggregates the total chargeable weight and groups it by customer to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart displays the total chargeable weight attributed to each customer.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=223</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=223"/>
		<updated>2025-08-21T09:41:17Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by customer to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest revenue-generating customers, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes converted into confirmed bookings for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by month to show revenue trends over time, plus the respective currencies.&lt;br /&gt;
|This chart provides a clear view of monthly revenue performance, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|Aggregates the total chargeable weight and groups it by customer to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart displays the total chargeable weight attributed to each customer.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=222</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=222"/>
		<updated>2025-08-21T09:38:57Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by customer to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest revenue-generating customers, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|Calculates the percentage of quotes converted into confirmed bookings for each month, grouping results over time to show conversion trends.&lt;br /&gt;
|This chart highlights how effectively quotes are turning into bookings month by month.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by month to show revenue trends over time, plus the respective currencies.&lt;br /&gt;
|This chart provides a clear view of monthly revenue performance, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=221</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=221"/>
		<updated>2025-08-21T09:36:22Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by customer to compare side by side in a clustered bar chart and with specific currency used for each.&lt;br /&gt;
|This chart displays the highest revenue-generating customers, showing amounts in their respective currencies.&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|Aggregates total revenue from confirmed bookings and groups it by month to show revenue trends over time, plus the respective currencies.&lt;br /&gt;
|This chart provides a clear view of monthly revenue performance, showing amounts in their original currencies.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=220</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=220"/>
		<updated>2025-08-21T09:31:21Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by origin to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each origin location, making it easy to identify which origins generate the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|Counts only confirmed bookings (converted quotes that have been finalized as bookings), then groups them by destination to compare side by side in a clustered bar chart.&lt;br /&gt;
|This chart shows the total confirmed bookings for each destination location, making it easy to identify which destinations receive the highest booking volumes and highlight performance differences across locations.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|Counts only confirmed bookings and groups them by service type to compare in a clustered bar chart.&lt;br /&gt;
|This chart highlights the total confirmed bookings for each service type, making it easy to see which services are most in demand and where performance differences exist across offerings.&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=219</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=219"/>
		<updated>2025-08-21T09:12:38Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1. Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2. Total Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Direct Bookings(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Converted Booking(Confirmed)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Chargeable Weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6. Top Customers By Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|7. Top Bookings (Confirmed) by Origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Bookings(Confirmed) by Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Bookings by Service&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|10. Bookings by Weight Breaks Matrix Table&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.Conversion Rate by Month&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Monthly Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Chargeable Weight by Customer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=218</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=218"/>
		<updated>2025-08-21T08:57:51Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|8.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|9.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|10.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|11.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|12.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|13.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=217</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=217"/>
		<updated>2025-08-21T08:55:55Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|1.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|2.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|3.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|4.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|5.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=216</id>
		<title>Revenue &amp; Booking Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Revenue_%26_Booking_Overview&amp;diff=216"/>
		<updated>2025-08-21T08:53:33Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer&lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport&lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-revnueandbookings-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=215</id>
		<title>Quotes</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=215"/>
		<updated>2025-08-20T11:28:46Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier &lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer &lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport &lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted Quotes or show Lost &amp;amp; Deleted Quotes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-quote-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes&lt;br /&gt;
|Total Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts all quotations based on &#039;&#039;&#039;quoted_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the correct date link with &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|2. Converted Quotes&lt;br /&gt;
|Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
|Counts quotations that have both &#039;&#039;&#039;quoted_at&#039;&#039;&#039; and &#039;&#039;&#039;booked_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the date link on &#039;&#039;&#039;booked_at&#039;&#039;&#039; for accurate filtering.&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Lost &amp;amp; Deleted &lt;br /&gt;
|Total_Lost_Deleted_Formatted =&lt;br /&gt;
VAR TotalLost =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[lost_at] ) )      -- Marked as lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
VAR TotalDeleted =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[deleted_at] ) ),  -- Marked as deleted&lt;br /&gt;
&lt;br /&gt;
        ISBLANK ( Quotations[lost_at] )              -- Not lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
RETURN&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Lost: &amp;quot; &amp;amp; FORMAT ( TotalLost, &amp;quot;#,0&amp;quot; ) &amp;amp;&lt;br /&gt;
&lt;br /&gt;
    &amp;quot; | Deleted: &amp;quot; &amp;amp; FORMAT ( TotalDeleted, &amp;quot;#,0&amp;quot; )&lt;br /&gt;
|Calculates &#039;&#039;&#039;how many quotations were lost&#039;&#039;&#039; (quoted and have a &#039;&#039;&#039;lost_at&#039;&#039;&#039; date) and &#039;&#039;&#039;how many were only deleted&#039;&#039;&#039; (quoted, have &#039;&#039;&#039;deleted_at&#039;&#039;&#039;, but no &#039;&#039;&#039;lost_at&#039;&#039;&#039;).&lt;br /&gt;
The result is returned as formatted text like:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lost: X | Deleted: Y&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; is used to activate the link between &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039; and &#039;&#039;&#039;quoted_at&#039;&#039;&#039; for accurate date filtering.&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Spot Rate Quotes&lt;br /&gt;
|Total Spot Rate Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    FILTER(&lt;br /&gt;
&lt;br /&gt;
        quotations,&lt;br /&gt;
&lt;br /&gt;
        NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
        quotations[spotrate] = 1&lt;br /&gt;
&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|This measure &#039;&#039;&#039;counts all quotations&#039;&#039;&#039; where:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quoted_at is not blank&#039;&#039;&#039;,&lt;br /&gt;
* &#039;&#039;&#039;spotrate equals 1&#039;&#039;&#039;,&lt;br /&gt;
* and it uses the &#039;&#039;&#039;inactive DimDate → quotations[quoted_at] relationship&#039;&#039;&#039; during calculation.&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Quotes &amp;amp; Converted Quotes by Customer.&lt;br /&gt;
|Uses existing DAX measures for &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; and add them on the clustered bar chart.&lt;br /&gt;
|This clustered bar chart &#039;&#039;&#039;shows each customer on the Y-axis and compares their total quotes against those converted quotes on the X axis.&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6. Quotes &amp;amp; Converted quotes  by Weight Break Table&lt;br /&gt;
|&lt;br /&gt;
* WeightBreakChar classifies each quotation into weight break ranges (e.g., &amp;lt;45, &amp;lt;100, …, &amp;gt;=3000) based on chargeable_weight.&lt;br /&gt;
* Total Quotes counts quotations per weight break using the quoted_at date relationship.&lt;br /&gt;
* %Total Quotes divides each weight break’s quotations by the total quotations in the current selection.&lt;br /&gt;
* Converted Quotes counts successfully booked quotations per weight break using the booked_at date relationship.&lt;br /&gt;
&lt;br /&gt;
* %Converted Quotes divides each weight break’s converted quotations by the total converted quotations in the current selection.&lt;br /&gt;
|This table groups quotations by weight break (WB) and shows:&lt;br /&gt;
&lt;br /&gt;
* Total Quotes per weight category,&lt;br /&gt;
* % of Total Quotes each weight break represents,&lt;br /&gt;
* Converted Quotes within each category, and&lt;br /&gt;
* % of Converted Quotes relative to the overall converted total.&lt;br /&gt;
|-&lt;br /&gt;
|7.Quotes by Weight Break and Service Name Matrix Table&lt;br /&gt;
|The matrix counts the number of quotations using the quoted_at field and groups them by &#039;&#039;&#039;Weight Break&#039;&#039;&#039; and &#039;&#039;&#039;Service Name&#039;&#039;&#039;.&lt;br /&gt;
|Shows how many quotations were created, organized by weight break and service name.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Tariffs By Total Quotes&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes =&lt;br /&gt;
&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at])))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = &lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; using quotation date filtering (via &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039;) and classifies them into tariff types for &lt;br /&gt;
visualization in a pie chart.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Tariffs By Converted Quotes &lt;br /&gt;
|1.Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; by counting quotations that were both &#039;&#039;&#039;quoted&#039;&#039;&#039; and &#039;&#039;&#039;booked&#039;&#039;&#039; (using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; on the booking date), then classifies them into tariff types for visualization in a pie chart.&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|10.Total Quotes and Converted Quotes by Origin&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by origin to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;origin location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|11. Total Quotes and Converted Quotes by Destination&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by Destination  to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;Destination location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Quotes by Lost Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;loss reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different loss reasons&#039;&#039;&#039;, helping to identify the most common factors leading to lost quotes.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Quotes by Delete Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;Delete reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different Delete reasons&#039;&#039;&#039;, helping to identify the most common factors leading to deleted quotes.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=214</id>
		<title>Quotes</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=214"/>
		<updated>2025-08-20T11:23:27Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Carrier &lt;br /&gt;
|Select to filter the Quote page by Carrier Name&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Select to filter the Quote page by Customer &lt;br /&gt;
|-&lt;br /&gt;
|Origin Airport &lt;br /&gt;
|Select to filter the Quote page by Origin Airport&lt;br /&gt;
|-&lt;br /&gt;
|Destination Airport&lt;br /&gt;
|Select to filter the Quote page by Destination Airport&lt;br /&gt;
|-&lt;br /&gt;
|Spot Rate Only&lt;br /&gt;
|Select to filter the Quote page by either Spotrates or Non Spotrates&lt;br /&gt;
|-&lt;br /&gt;
|Hide Lost/Deleted&lt;br /&gt;
|Select to filter the Quote page by choosing to Hide Lost &amp;amp; Deleted or show Lost &amp;amp; Deleted&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-quote-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes&lt;br /&gt;
|Total Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts all quotations based on &#039;&#039;&#039;quoted_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the correct date link with &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|2. Converted Quotes&lt;br /&gt;
|Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
|Counts quotations that have both &#039;&#039;&#039;quoted_at&#039;&#039;&#039; and &#039;&#039;&#039;booked_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the date link on &#039;&#039;&#039;booked_at&#039;&#039;&#039; for accurate filtering.&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Lost &amp;amp; Deleted &lt;br /&gt;
|Total_Lost_Deleted_Formatted =&lt;br /&gt;
VAR TotalLost =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[lost_at] ) )      -- Marked as lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
VAR TotalDeleted =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[deleted_at] ) ),  -- Marked as deleted&lt;br /&gt;
&lt;br /&gt;
        ISBLANK ( Quotations[lost_at] )              -- Not lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
RETURN&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Lost: &amp;quot; &amp;amp; FORMAT ( TotalLost, &amp;quot;#,0&amp;quot; ) &amp;amp;&lt;br /&gt;
&lt;br /&gt;
    &amp;quot; | Deleted: &amp;quot; &amp;amp; FORMAT ( TotalDeleted, &amp;quot;#,0&amp;quot; )&lt;br /&gt;
|Calculates &#039;&#039;&#039;how many quotations were lost&#039;&#039;&#039; (quoted and have a &#039;&#039;&#039;lost_at&#039;&#039;&#039; date) and &#039;&#039;&#039;how many were only deleted&#039;&#039;&#039; (quoted, have &#039;&#039;&#039;deleted_at&#039;&#039;&#039;, but no &#039;&#039;&#039;lost_at&#039;&#039;&#039;).&lt;br /&gt;
The result is returned as formatted text like:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lost: X | Deleted: Y&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; is used to activate the link between &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039; and &#039;&#039;&#039;quoted_at&#039;&#039;&#039; for accurate date filtering.&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Spot Rate Quotes&lt;br /&gt;
|Total Spot Rate Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    FILTER(&lt;br /&gt;
&lt;br /&gt;
        quotations,&lt;br /&gt;
&lt;br /&gt;
        NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
        quotations[spotrate] = 1&lt;br /&gt;
&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|This measure &#039;&#039;&#039;counts all quotations&#039;&#039;&#039; where:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quoted_at is not blank&#039;&#039;&#039;,&lt;br /&gt;
* &#039;&#039;&#039;spotrate equals 1&#039;&#039;&#039;,&lt;br /&gt;
* and it uses the &#039;&#039;&#039;inactive DimDate → quotations[quoted_at] relationship&#039;&#039;&#039; during calculation.&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Quotes &amp;amp; Converted Quotes by Customer.&lt;br /&gt;
|Uses existing DAX measures for &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; and add them on the clustered bar chart.&lt;br /&gt;
|This clustered bar chart &#039;&#039;&#039;shows each customer on the Y-axis and compares their total quotes against those converted quotes on the X axis.&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6. Quotes &amp;amp; Converted quotes  by Weight Break Table&lt;br /&gt;
|&lt;br /&gt;
* WeightBreakChar classifies each quotation into weight break ranges (e.g., &amp;lt;45, &amp;lt;100, …, &amp;gt;=3000) based on chargeable_weight.&lt;br /&gt;
* Total Quotes counts quotations per weight break using the quoted_at date relationship.&lt;br /&gt;
* %Total Quotes divides each weight break’s quotations by the total quotations in the current selection.&lt;br /&gt;
* Converted Quotes counts successfully booked quotations per weight break using the booked_at date relationship.&lt;br /&gt;
&lt;br /&gt;
* %Converted Quotes divides each weight break’s converted quotations by the total converted quotations in the current selection.&lt;br /&gt;
|This table groups quotations by weight break (WB) and shows:&lt;br /&gt;
&lt;br /&gt;
* Total Quotes per weight category,&lt;br /&gt;
* % of Total Quotes each weight break represents,&lt;br /&gt;
* Converted Quotes within each category, and&lt;br /&gt;
* % of Converted Quotes relative to the overall converted total.&lt;br /&gt;
|-&lt;br /&gt;
|7.Quotes by Weight Break and Service Name Matrix Table&lt;br /&gt;
|The matrix counts the number of quotations using the quoted_at field and groups them by &#039;&#039;&#039;Weight Break&#039;&#039;&#039; and &#039;&#039;&#039;Service Name&#039;&#039;&#039;.&lt;br /&gt;
|Shows how many quotations were created, organized by weight break and service name.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Tariffs By Total Quotes&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes =&lt;br /&gt;
&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at])))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = &lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; using quotation date filtering (via &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039;) and classifies them into tariff types for &lt;br /&gt;
visualization in a pie chart.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Tariffs By Converted Quotes &lt;br /&gt;
|1.Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; by counting quotations that were both &#039;&#039;&#039;quoted&#039;&#039;&#039; and &#039;&#039;&#039;booked&#039;&#039;&#039; (using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; on the booking date), then classifies them into tariff types for visualization in a pie chart.&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|10.Total Quotes and Converted Quotes by Origin&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by origin to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;origin location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|11. Total Quotes and Converted Quotes by Destination&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by Destination  to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;Destination location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Quotes by Lost Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;loss reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different loss reasons&#039;&#039;&#039;, helping to identify the most common factors leading to lost quotes.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Quotes by Delete Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;Delete reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different Delete reasons&#039;&#039;&#039;, helping to identify the most common factors leading to deleted quotes.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=213</id>
		<title>Quotes</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=213"/>
		<updated>2025-08-20T10:58:31Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-quote-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes&lt;br /&gt;
|Total Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts all quotations based on &#039;&#039;&#039;quoted_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the correct date link with &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|2. Converted Quotes&lt;br /&gt;
|Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
|Counts quotations that have both &#039;&#039;&#039;quoted_at&#039;&#039;&#039; and &#039;&#039;&#039;booked_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the date link on &#039;&#039;&#039;booked_at&#039;&#039;&#039; for accurate filtering.&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Lost &amp;amp; Deleted &lt;br /&gt;
|Total_Lost_Deleted_Formatted =&lt;br /&gt;
VAR TotalLost =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[lost_at] ) )      -- Marked as lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
VAR TotalDeleted =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[deleted_at] ) ),  -- Marked as deleted&lt;br /&gt;
&lt;br /&gt;
        ISBLANK ( Quotations[lost_at] )              -- Not lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
RETURN&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Lost: &amp;quot; &amp;amp; FORMAT ( TotalLost, &amp;quot;#,0&amp;quot; ) &amp;amp;&lt;br /&gt;
&lt;br /&gt;
    &amp;quot; | Deleted: &amp;quot; &amp;amp; FORMAT ( TotalDeleted, &amp;quot;#,0&amp;quot; )&lt;br /&gt;
|Calculates &#039;&#039;&#039;how many quotations were lost&#039;&#039;&#039; (quoted and have a &#039;&#039;&#039;lost_at&#039;&#039;&#039; date) and &#039;&#039;&#039;how many were only deleted&#039;&#039;&#039; (quoted, have &#039;&#039;&#039;deleted_at&#039;&#039;&#039;, but no &#039;&#039;&#039;lost_at&#039;&#039;&#039;).&lt;br /&gt;
The result is returned as formatted text like:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lost: X | Deleted: Y&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; is used to activate the link between &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039; and &#039;&#039;&#039;quoted_at&#039;&#039;&#039; for accurate date filtering.&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Spot Rate Quotes&lt;br /&gt;
|Total Spot Rate Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    FILTER(&lt;br /&gt;
&lt;br /&gt;
        quotations,&lt;br /&gt;
&lt;br /&gt;
        NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
        quotations[spotrate] = 1&lt;br /&gt;
&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|This measure &#039;&#039;&#039;counts all quotations&#039;&#039;&#039; where:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quoted_at is not blank&#039;&#039;&#039;,&lt;br /&gt;
* &#039;&#039;&#039;spotrate equals 1&#039;&#039;&#039;,&lt;br /&gt;
* and it uses the &#039;&#039;&#039;inactive DimDate → quotations[quoted_at] relationship&#039;&#039;&#039; during calculation.&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Quotes &amp;amp; Converted Quotes by Customer.&lt;br /&gt;
|Uses existing DAX measures for &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; and add them on the clustered bar chart.&lt;br /&gt;
|This clustered bar chart &#039;&#039;&#039;shows each customer on the Y-axis and compares their total quotes against those converted quotes on the X axis.&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6. Quotes &amp;amp; Converted quotes  by Weight Break Table&lt;br /&gt;
|&lt;br /&gt;
* WeightBreakChar classifies each quotation into weight break ranges (e.g., &amp;lt;45, &amp;lt;100, …, &amp;gt;=3000) based on chargeable_weight.&lt;br /&gt;
* Total Quotes counts quotations per weight break using the quoted_at date relationship.&lt;br /&gt;
* %Total Quotes divides each weight break’s quotations by the total quotations in the current selection.&lt;br /&gt;
* Converted Quotes counts successfully booked quotations per weight break using the booked_at date relationship.&lt;br /&gt;
&lt;br /&gt;
* %Converted Quotes divides each weight break’s converted quotations by the total converted quotations in the current selection.&lt;br /&gt;
|This table groups quotations by weight break (WB) and shows:&lt;br /&gt;
&lt;br /&gt;
* Total Quotes per weight category,&lt;br /&gt;
* % of Total Quotes each weight break represents,&lt;br /&gt;
* Converted Quotes within each category, and&lt;br /&gt;
* % of Converted Quotes relative to the overall converted total.&lt;br /&gt;
|-&lt;br /&gt;
|7.Quotes by Weight Break and Service Name Matrix Table&lt;br /&gt;
|The matrix counts the number of quotations using the quoted_at field and groups them by &#039;&#039;&#039;Weight Break&#039;&#039;&#039; and &#039;&#039;&#039;Service Name&#039;&#039;&#039;.&lt;br /&gt;
|Shows how many quotations were created, organized by weight break and service name.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Tariffs By Total Quotes&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes =&lt;br /&gt;
&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at])))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = &lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; using quotation date filtering (via &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039;) and classifies them into tariff types for &lt;br /&gt;
visualization in a pie chart.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
|-&lt;br /&gt;
|9. Top Tariffs By Converted Quotes &lt;br /&gt;
|1.Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Tariff Types = SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; by counting quotations that were both &#039;&#039;&#039;quoted&#039;&#039;&#039; and &#039;&#039;&#039;booked&#039;&#039;&#039; (using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; on the booking date), then classifies them into tariff types for visualization in a pie chart.&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|10.Total Quotes and Converted Quotes by Origin&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by origin to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;origin location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|11. Total Quotes and Converted Quotes by Destination&lt;br /&gt;
|Counts quotes and converted quotes , then groups them by Destination  to compare side by side in a clustered bar chart&lt;br /&gt;
|This chart provides a side-by-side comparison of &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; versus &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; for each &#039;&#039;&#039;Destination location&#039;&#039;&#039;, making it easy to see which origins generate the highest quote volumes and where conversions are strongest or weakest.&lt;br /&gt;
|-&lt;br /&gt;
|12. Total Quotes by Lost Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;loss reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different loss reasons&#039;&#039;&#039;, helping to identify the most common factors leading to lost quotes.&lt;br /&gt;
|-&lt;br /&gt;
|13. Total Quotes by Delete Reasons&lt;br /&gt;
|Counts &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and groups them by &#039;&#039;&#039;Delete reason&#039;&#039;&#039;, then displays them in a stacked column chart for easy comparison&lt;br /&gt;
|This chart shows how &#039;&#039;&#039;quotes are distributed across different Delete reasons&#039;&#039;&#039;, helping to identify the most common factors leading to deleted quotes.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=212</id>
		<title>Quotes</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=Quotes&amp;diff=212"/>
		<updated>2025-08-20T10:32:09Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
[[File:Report-quote-mastercarrier.png|none|thumb|800x800px]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes&lt;br /&gt;
|Total Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Counts all quotations based on &#039;&#039;&#039;quoted_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the correct date link with &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|2. Converted Quotes&lt;br /&gt;
|Converted Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[booked_at]),  // Temporarily activate the relationship with booked_at&lt;br /&gt;
&lt;br /&gt;
    (NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[booked_at]))&lt;br /&gt;
&lt;br /&gt;
))&lt;br /&gt;
|Counts quotations that have both &#039;&#039;&#039;quoted_at&#039;&#039;&#039; and &#039;&#039;&#039;booked_at&#039;&#039;&#039;, using &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; to activate the date link on &#039;&#039;&#039;booked_at&#039;&#039;&#039; for accurate filtering.&lt;br /&gt;
|-&lt;br /&gt;
|3. Total Lost &amp;amp; Deleted &lt;br /&gt;
|Total_Lost_Deleted_Formatted =&lt;br /&gt;
VAR TotalLost =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[lost_at] ) )      -- Marked as lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
VAR TotalDeleted =&lt;br /&gt;
&lt;br /&gt;
    CALCULATE (&lt;br /&gt;
&lt;br /&gt;
        COUNTROWS ( Quotations ),&lt;br /&gt;
&lt;br /&gt;
        USERELATIONSHIP ( DimDate[Date], Quotations[quoted_at] ),&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[quoted_at] ) ),   -- Was quoted&lt;br /&gt;
&lt;br /&gt;
        NOT ( ISBLANK ( Quotations[deleted_at] ) ),  -- Marked as deleted&lt;br /&gt;
&lt;br /&gt;
        ISBLANK ( Quotations[lost_at] )              -- Not lost&lt;br /&gt;
&lt;br /&gt;
    ) + 0&lt;br /&gt;
&lt;br /&gt;
RETURN&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Lost: &amp;quot; &amp;amp; FORMAT ( TotalLost, &amp;quot;#,0&amp;quot; ) &amp;amp;&lt;br /&gt;
&lt;br /&gt;
    &amp;quot; | Deleted: &amp;quot; &amp;amp; FORMAT ( TotalDeleted, &amp;quot;#,0&amp;quot; )&lt;br /&gt;
|Calculates &#039;&#039;&#039;how many quotations were lost&#039;&#039;&#039; (quoted and have a &#039;&#039;&#039;lost_at&#039;&#039;&#039; date) and &#039;&#039;&#039;how many were only deleted&#039;&#039;&#039; (quoted, have &#039;&#039;&#039;deleted_at&#039;&#039;&#039;, but no &#039;&#039;&#039;lost_at&#039;&#039;&#039;).&lt;br /&gt;
The result is returned as formatted text like:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lost: X | Deleted: Y&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039; is used to activate the link between &#039;&#039;&#039;DimDate[Date]&#039;&#039;&#039; and &#039;&#039;&#039;quoted_at&#039;&#039;&#039; for accurate date filtering.&lt;br /&gt;
|-&lt;br /&gt;
|4. Total Spot Rate Quotes&lt;br /&gt;
|Total Spot Rate Quotes =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    FILTER(&lt;br /&gt;
&lt;br /&gt;
        quotations,&lt;br /&gt;
&lt;br /&gt;
        NOT(ISBLANK(quotations[quoted_at])) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
        quotations[spotrate] = 1&lt;br /&gt;
&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|This measure &#039;&#039;&#039;counts all quotations&#039;&#039;&#039; where:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quoted_at is not blank&#039;&#039;&#039;,&lt;br /&gt;
* &#039;&#039;&#039;spotrate equals 1&#039;&#039;&#039;,&lt;br /&gt;
* and it uses the &#039;&#039;&#039;inactive DimDate → quotations[quoted_at] relationship&#039;&#039;&#039; during calculation.&lt;br /&gt;
|-&lt;br /&gt;
|5. Total Quotes &amp;amp; Converted Quotes by Customer.&lt;br /&gt;
|Uses existing DAX measures for &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; and &#039;&#039;&#039;Converted Quotes&#039;&#039;&#039; and add them on the clustered bar chart.&lt;br /&gt;
|This clustered bar chart &#039;&#039;&#039;shows each customer on the Y-axis and compares their total quotes against those converted quotes on the X axis.&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6. Quotes &amp;amp; Converted quotes  by Weight Break Table&lt;br /&gt;
|&lt;br /&gt;
* WeightBreakChar classifies each quotation into weight break ranges (e.g., &amp;lt;45, &amp;lt;100, …, &amp;gt;=3000) based on chargeable_weight.&lt;br /&gt;
* Total Quotes counts quotations per weight break using the quoted_at date relationship.&lt;br /&gt;
* %Total Quotes divides each weight break’s quotations by the total quotations in the current selection.&lt;br /&gt;
* Converted Quotes counts successfully booked quotations per weight break using the booked_at date relationship.&lt;br /&gt;
&lt;br /&gt;
* %Converted Quotes divides each weight break’s converted quotations by the total converted quotations in the current selection.&lt;br /&gt;
|This table groups quotations by weight break (WB) and shows:&lt;br /&gt;
&lt;br /&gt;
* Total Quotes per weight category,&lt;br /&gt;
* % of Total Quotes each weight break represents,&lt;br /&gt;
* Converted Quotes within each category, and&lt;br /&gt;
* % of Converted Quotes relative to the overall converted total.&lt;br /&gt;
|-&lt;br /&gt;
|7.Quotes by Weight Break and Service Name Matrix Table&lt;br /&gt;
|The matrix counts the number of quotations using the quoted_at field and groups them by &#039;&#039;&#039;Weight Break&#039;&#039;&#039; and &#039;&#039;&#039;Service Name&#039;&#039;&#039;.&lt;br /&gt;
|Shows how many quotations were created, organized by weight break and service name.&lt;br /&gt;
|-&lt;br /&gt;
|8. Top Tariffs By Total Quotes&lt;br /&gt;
|&lt;br /&gt;
# Total Quotes =&lt;br /&gt;
&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
    COUNTROWS(quotations),&lt;br /&gt;
&lt;br /&gt;
    USERELATIONSHIP(DimDate[Date], quotations[quoted_at]),&lt;br /&gt;
&lt;br /&gt;
    NOT(ISBLANK(quotations[quoted_at]))&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
2. Tariff Types = &lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
    TRUE(),&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Contract SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    NOT ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Contract&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] = 1, &amp;quot;Promo SR&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = TRUE() &amp;amp;&amp;amp; quotations[spotrate] &amp;lt;&amp;gt; 1, &amp;quot;Promo&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    ISBLANK(quotations[tariff_customer_id]) &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[tariff_flag_promo] = FALSE() &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
    quotations[spotrate] = 0, &amp;quot;Standard&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;Spot Rate&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Calculates &#039;&#039;&#039;Total Quotes&#039;&#039;&#039; using quotation date filtering (via &#039;&#039;&#039;USERELATIONSHIP&#039;&#039;&#039;) and classifies them into tariff types for &lt;br /&gt;
visualization in a pie chart.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logic for classification:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Contract SR&#039;&#039;&#039; – Customer contract exists (&#039;&#039;&#039;tariff_customer_id&#039;&#039;&#039; not blank) and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Contract&#039;&#039;&#039; – Customer contract exists and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo SR&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate = 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Promo&#039;&#039;&#039; – &#039;&#039;&#039;tariff_flag_promo = TRUE&#039;&#039;&#039; and &#039;&#039;&#039;spotrate ≠ 1&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Standard&#039;&#039;&#039; – No contract, no promo, and &#039;&#039;&#039;spotrate = 0&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Spot Rate&#039;&#039;&#039; – All remaining cases (&#039;&#039;&#039;fallback&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=145</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=145"/>
		<updated>2025-07-31T09:31:38Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|quotations&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039;, &#039;&#039;&#039;depart_date&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_carriers&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039;, &#039;&#039;&#039;main_carrier_id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, &#039;&#039;&#039;carrier_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;carrier_id&#039;&#039;&#039;, &#039;&#039;&#039;Carrier&#039;&#039;&#039;, &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Kept only rows where &#039;&#039;&#039;quotation_carriers.carrier_id = 250&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|hae_booking_db carriers&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;sites&#039;&#039;&#039; on &#039;&#039;&#039;site_id&#039;&#039;&#039; and &#039;&#039;&#039;id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;name&#039;&#039;&#039; from &#039;&#039;&#039;sites&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;hae_booking_db sites.name&#039;&#039;&#039; to &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_totals_local&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;total_cost&#039;&#039;&#039; → &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039;  &#039;&#039;&#039;total_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Invoice Customer Total (Sales BRL)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;HAE Over&#039;&#039;&#039; = &#039;&#039;&#039;total_sell_rate - total_cost_rate&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_charges&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column&#039;&#039;&#039;: &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column Again&#039;&#039;&#039;: &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039; → &#039;&#039;&#039;HAE Commission Currency (USD)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_routes&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, &#039;&#039;&#039;currency&#039;&#039;&#039;, &#039;&#039;&#039;currency_sell&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;cost_rate&#039;&#039;&#039; → &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;  &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;Selling Rate&#039;&#039;&#039;  &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Buying Currency&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;Sell Rate Currency&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Mode of Payment)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (AWB Issue Date)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;AWB Issue Date Final&#039;&#039;&#039; = if &#039;&#039;&#039;AWB Issue Date = &amp;quot;&amp;quot;&#039;&#039;&#039; then &#039;&#039;&#039;&amp;quot;NODATA&amp;quot;&#039;&#039;&#039; else &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Due Agent)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Due Agent&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, retained max of &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_exchange_Original&#039;&#039;&#039; on &#039;&#039;&#039;quotation_id&#039;&#039;&#039; and &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;, &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_exchange_Original.exchange_rate&#039;&#039;&#039; → &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;  &#039;&#039;&#039;quotation_exchange_Original.is_fixed&#039;&#039;&#039; → &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_Original&lt;br /&gt;
|&#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_chargesHAE_TAX&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Initial filter kept all, then second filter kept rows where &#039;&#039;&#039;HAE Tax (charge currency) = USD&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;sell_min&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax (charge currency)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_route_partsOriginal&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_routes_flight_number.quotation_id&#039;&#039;&#039; → &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_flight_number&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, selected &#039;&#039;&#039;Min(id)&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_route_partsOriginal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;flight_number&#039;&#039;&#039;, &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_route_partsOriginal.flight_number&#039;&#039;&#039; → &#039;&#039;&#039;flight_number&#039;&#039;&#039;  &#039;&#039;&#039;quotation_route_partsOriginal.carrier_code&#039;&#039;&#039; → &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableTotalRevenue&lt;br /&gt;
|To create a table that combines quotation data with revenue-related charge details. This helps in calculating &#039;&#039;&#039;Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
&#039;&#039;&#039;How it works:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* It &#039;&#039;&#039;joins&#039;&#039;&#039; the quotations table with the quotations_total_revenue table using matching quotation IDs.&lt;br /&gt;
* From the joined data, it &#039;&#039;&#039;selects&#039;&#039;&#039; only these columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; – the quotation ID&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; – used in revenue calculation&lt;br /&gt;
** &#039;&#039;&#039;Code&#039;&#039;&#039; – type of charge (e.g., LINEHAUL, DTC)&lt;br /&gt;
** &#039;&#039;&#039;Sell Rate&#039;&#039;&#039; – rate per weight unit&lt;br /&gt;
** &#039;&#039;&#039;Sell Min&#039;&#039;&#039; – minimum selling value&lt;br /&gt;
&lt;br /&gt;
This table is then used in the revenue formula that applies different logic depending on the charge code.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierUSD&lt;br /&gt;
|&#039;&#039;&#039;Purpose:&#039;&#039;&#039;&lt;br /&gt;
To create a clean table for calculating Due Carrier USD, excluding rows where the charge code is LINEHAUL.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use three tables: &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; (a filtered version of quotation_charges), and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Join &#039;&#039;&#039;quotations&#039;&#039;&#039; with &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; using a natural inner join.&lt;br /&gt;
* Then join the result with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; using another natural inner join.&lt;br /&gt;
* Select the following columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
* Use &#039;&#039;&#039;DISTINCT&#039;&#039;&#039; to remove any duplicate rows.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierTotal&lt;br /&gt;
|To create a unified table that includes &#039;&#039;&#039;all carrier charges&#039;&#039;&#039; (including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;) for calculating &#039;&#039;&#039;Total Due Carrier USD&#039;&#039;&#039; values.&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Start with the &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;, and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; tables.&lt;br /&gt;
* Perform a &#039;&#039;&#039;natural inner join&#039;&#039;&#039; between &#039;&#039;&#039;quotations&#039;&#039;&#039; and &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
* Then perform another &#039;&#039;&#039;natural inner join&#039;&#039;&#039; with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Use &#039;&#039;&#039;SELECTCOLUMNS&#039;&#039;&#039; to extract the following fields:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierTotal&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate =&lt;br /&gt;
IF(&lt;br /&gt;
&lt;br /&gt;
    quotation_exchange_rates[is_fixed] = TRUE(),&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;✓&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;×&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|Buying Rate = quotation_routes[cost_rate]&lt;br /&gt;
|&#039;&#039;&#039;Join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_routes&#039;&#039;&#039; table (filtered where &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, &#039;&#039;&#039;filtered where code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;.&lt;br /&gt;
From this joined data, &#039;&#039;&#039;extract the cost_rate&#039;&#039;&#039; field and rename it as &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; =&lt;br /&gt;
quotation_routes[Buying Rate] × RELATED(quotations[chargeable_weight])&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_rate] * QuotationCombinedTableDueCarrierUSD[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the quotation charges table, rename it to:&lt;br /&gt;
&#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
This version includes all relevant charge codes for calculating total revenue—specifically &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039; and &#039;&#039;&#039;DTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quotation_id&#039;&#039;&#039; as ID&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, and &#039;&#039;&#039;sell_min&#039;&#039;&#039; from &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, compute &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; using a conditional logic:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;sell_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;DTC&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total =&#039;&#039;&#039;&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_rate] * QuotationCombinedTableDueCarrierTotal[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=141</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=141"/>
		<updated>2025-07-30T14:45:03Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|quotations&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039;, &#039;&#039;&#039;depart_date&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_carriers&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039;, &#039;&#039;&#039;main_carrier_id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, &#039;&#039;&#039;carrier_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;carrier_id&#039;&#039;&#039;, &#039;&#039;&#039;Carrier&#039;&#039;&#039;, &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Kept only rows where &#039;&#039;&#039;quotation_carriers.carrier_id = 250&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|hae_booking_db carriers&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;sites&#039;&#039;&#039; on &#039;&#039;&#039;site_id&#039;&#039;&#039; and &#039;&#039;&#039;id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;name&#039;&#039;&#039; from &#039;&#039;&#039;sites&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;hae_booking_db sites.name&#039;&#039;&#039; to &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_totals_local&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;total_cost&#039;&#039;&#039; → &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039;  &#039;&#039;&#039;total_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Invoice Customer Total (Sales BRL)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;HAE Over&#039;&#039;&#039; = &#039;&#039;&#039;total_sell_rate - total_cost_rate&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_charges&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column&#039;&#039;&#039;: &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column Again&#039;&#039;&#039;: &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039; → &#039;&#039;&#039;HAE Commission Currency (USD)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_routes&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, &#039;&#039;&#039;currency&#039;&#039;&#039;, &#039;&#039;&#039;currency_sell&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;cost_rate&#039;&#039;&#039; → &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;  &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;Selling Rate&#039;&#039;&#039;  &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Buying Currency&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;Sell Rate Currency&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Mode of Payment)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (AWB Issue Date)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;AWB Issue Date Final&#039;&#039;&#039; = if &#039;&#039;&#039;AWB Issue Date = &amp;quot;&amp;quot;&#039;&#039;&#039; then &#039;&#039;&#039;&amp;quot;NODATA&amp;quot;&#039;&#039;&#039; else &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Due Agent)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Due Agent&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, retained max of &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_exchange_Original&#039;&#039;&#039; on &#039;&#039;&#039;quotation_id&#039;&#039;&#039; and &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;, &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_exchange_Original.exchange_rate&#039;&#039;&#039; → &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;  &#039;&#039;&#039;quotation_exchange_Original.is_fixed&#039;&#039;&#039; → &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_Original&lt;br /&gt;
|&#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_chargesHAE_TAX&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Initial filter kept all, then second filter kept rows where &#039;&#039;&#039;HAE Tax (charge currency) = USD&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;sell_min&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax (charge currency)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_route_partsOriginal&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_routes_flight_number.quotation_id&#039;&#039;&#039; → &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_flight_number&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, selected &#039;&#039;&#039;Min(id)&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_route_partsOriginal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;flight_number&#039;&#039;&#039;, &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_route_partsOriginal.flight_number&#039;&#039;&#039; → &#039;&#039;&#039;flight_number&#039;&#039;&#039;  &#039;&#039;&#039;quotation_route_partsOriginal.carrier_code&#039;&#039;&#039; → &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableTotalRevenue&lt;br /&gt;
|To create a table that combines quotation data with revenue-related charge details. This helps in calculating &#039;&#039;&#039;Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
&#039;&#039;&#039;How it works:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* It &#039;&#039;&#039;joins&#039;&#039;&#039; the quotations table with the quotations_total_revenue table using matching quotation IDs.&lt;br /&gt;
* From the joined data, it &#039;&#039;&#039;selects&#039;&#039;&#039; only these columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; – the quotation ID&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; – used in revenue calculation&lt;br /&gt;
** &#039;&#039;&#039;Code&#039;&#039;&#039; – type of charge (e.g., LINEHAUL, DTC)&lt;br /&gt;
** &#039;&#039;&#039;Sell Rate&#039;&#039;&#039; – rate per weight unit&lt;br /&gt;
** &#039;&#039;&#039;Sell Min&#039;&#039;&#039; – minimum selling value&lt;br /&gt;
&lt;br /&gt;
This table is then used in the revenue formula that applies different logic depending on the charge code.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierUSD&lt;br /&gt;
|&#039;&#039;&#039;Purpose:&#039;&#039;&#039;&lt;br /&gt;
To create a clean table for calculating Due Carrier USD, excluding rows where the charge code is LINEHAUL.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use three tables: &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; (a filtered version of quotation_charges), and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Join &#039;&#039;&#039;quotations&#039;&#039;&#039; with &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; using a natural inner join.&lt;br /&gt;
* Then join the result with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; using another natural inner join.&lt;br /&gt;
* Select the following columns:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
* Use &#039;&#039;&#039;DISTINCT&#039;&#039;&#039; to remove any duplicate rows.&lt;br /&gt;
|-&lt;br /&gt;
|QuotationCombinedTableDueCarrierTotal&lt;br /&gt;
|To create a unified table that includes &#039;&#039;&#039;all carrier charges&#039;&#039;&#039; (including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;) for calculating &#039;&#039;&#039;Total Due Carrier USD&#039;&#039;&#039; values.&lt;br /&gt;
&#039;&#039;&#039;Steps:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Start with the &#039;&#039;&#039;quotations&#039;&#039;&#039;, &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;, and &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; tables.&lt;br /&gt;
* Perform a &#039;&#039;&#039;natural inner join&#039;&#039;&#039; between &#039;&#039;&#039;quotations&#039;&#039;&#039; and &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
* Then perform another &#039;&#039;&#039;natural inner join&#039;&#039;&#039; with &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;.&lt;br /&gt;
* Use &#039;&#039;&#039;SELECTCOLUMNS&#039;&#039;&#039; to extract the following fields:&lt;br /&gt;
** &#039;&#039;&#039;ID&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Chargeable Weight&#039;&#039;&#039; from quotations&lt;br /&gt;
** &#039;&#039;&#039;Cost Rate&#039;&#039;&#039;, &#039;&#039;&#039;Code&#039;&#039;&#039;, &#039;&#039;&#039;Cost Min&#039;&#039;&#039;, &#039;&#039;&#039;On&#039;&#039;&#039; from quotation_chargesDueCarrierTotal&lt;br /&gt;
** &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate =&lt;br /&gt;
IF(&lt;br /&gt;
&lt;br /&gt;
    quotation_exchange_rates[is_fixed] = TRUE(),&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;✓&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;×&amp;quot;&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; =&lt;br /&gt;
quotation_routes[Buying Rate] × RELATED(quotations[chargeable_weight])&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_rate] * QuotationCombinedTableDueCarrierUSD[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the quotation charges table, rename it to:&lt;br /&gt;
&#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
This version includes all relevant charge codes for calculating total revenue—specifically &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039; and &#039;&#039;&#039;DTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quotation_id&#039;&#039;&#039; as ID&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, and &#039;&#039;&#039;sell_min&#039;&#039;&#039; from &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, compute &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; using a conditional logic:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;sell_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;DTC&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total =&#039;&#039;&#039;&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_rate] * QuotationCombinedTableDueCarrierTotal[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=140</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=140"/>
		<updated>2025-07-30T13:54:54Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Transformations&lt;br /&gt;
|-&lt;br /&gt;
|quotations&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039;, &#039;&#039;&#039;depart_date&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_carriers&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039;, &#039;&#039;&#039;main_carrier_id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, &#039;&#039;&#039;carrier_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;carrier_id&#039;&#039;&#039;, &#039;&#039;&#039;Carrier&#039;&#039;&#039;, &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Kept only rows where &#039;&#039;&#039;quotation_carriers.carrier_id = 250&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|hae_booking_db carriers&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;sites&#039;&#039;&#039; on &#039;&#039;&#039;site_id&#039;&#039;&#039; and &#039;&#039;&#039;id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;name&#039;&#039;&#039; from &#039;&#039;&#039;sites&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;hae_booking_db sites.name&#039;&#039;&#039; to &#039;&#039;&#039;Site&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_totals_local&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;total_cost&#039;&#039;&#039; → &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039;  &#039;&#039;&#039;total_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Invoice Customer Total (Sales BRL)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;HAE Over&#039;&#039;&#039; = &#039;&#039;&#039;total_sell_rate - total_cost_rate&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_charges&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column&#039;&#039;&#039;: &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Duplicated Column Again&#039;&#039;&#039;: &#039;&#039;&#039;Due Carrier Currency&#039;&#039;&#039; → &#039;&#039;&#039;HAE Commission Currency (USD)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_routes&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; on &#039;&#039;&#039;id&#039;&#039;&#039; and &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, &#039;&#039;&#039;currency&#039;&#039;&#039;, &#039;&#039;&#039;currency_sell&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;cost_rate&#039;&#039;&#039; → &#039;&#039;&#039;Buying Rate&#039;&#039;&#039;  &#039;&#039;&#039;sell_rate&#039;&#039;&#039; → &#039;&#039;&#039;Selling Rate&#039;&#039;&#039;  &#039;&#039;&#039;currency&#039;&#039;&#039; → &#039;&#039;&#039;Buying Currency&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;Sell Rate Currency&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Mode of Payment)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (AWB Issue Date)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Added Custom Column&#039;&#039;&#039;:  &#039;&#039;&#039;AWB Issue Date Final&#039;&#039;&#039; = if &#039;&#039;&#039;AWB Issue Date = &amp;quot;&amp;quot;&#039;&#039;&#039; then &#039;&#039;&#039;&amp;quot;NODATA&amp;quot;&#039;&#039;&#039; else &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_fields (Due Agent)&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;field_value&#039;&#039;&#039; → &#039;&#039;&#039;Due Agent&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, retained max of &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_exchange_Original&#039;&#039;&#039; on &#039;&#039;&#039;quotation_id&#039;&#039;&#039; and &#039;&#039;&#039;created_at&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;, &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_exchange_Original.exchange_rate&#039;&#039;&#039; → &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;  &#039;&#039;&#039;quotation_exchange_Original.is_fixed&#039;&#039;&#039; → &#039;&#039;&#039;is_fixed&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_exchange_Original&lt;br /&gt;
|&#039;&#039;&#039;Changed Type&#039;&#039;&#039;: &#039;&#039;&#039;created_at&#039;&#039;&#039; to &#039;&#039;&#039;date&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_chargesHAE_TAX&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Filtered Rows&#039;&#039;&#039;: Initial filter kept all, then second filter kept rows where &#039;&#039;&#039;HAE Tax (charge currency) = USD&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;sell_min&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;  &#039;&#039;&#039;currency_sell&#039;&#039;&#039; → &#039;&#039;&#039;HAE Tax (charge currency)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_route_partsOriginal&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_routes_flight_number.quotation_id&#039;&#039;&#039; → &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|quotation_flight_number&lt;br /&gt;
|&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_routes_flight_number&#039;&#039;&#039; on &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Column&#039;&#039;&#039;: &#039;&#039;&#039;quotation_id&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Grouped Rows&#039;&#039;&#039;: by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, selected &#039;&#039;&#039;Min(id)&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Merged Queries&#039;&#039;&#039;: Joined with &#039;&#039;&#039;quotation_route_partsOriginal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Expanded Columns&#039;&#039;&#039;: &#039;&#039;&#039;flight_number&#039;&#039;&#039;, &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Renamed Columns&#039;&#039;&#039;:  &#039;&#039;&#039;quotation_route_partsOriginal.flight_number&#039;&#039;&#039; → &#039;&#039;&#039;flight_number&#039;&#039;&#039;  &#039;&#039;&#039;quotation_route_partsOriginal.carrier_code&#039;&#039;&#039; → &#039;&#039;&#039;carrier_code&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_rate] * QuotationCombinedTableDueCarrierUSD[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the quotation charges table, rename it to:&lt;br /&gt;
&#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
This version includes all relevant charge codes for calculating total revenue—specifically &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039; and &#039;&#039;&#039;DTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quotation_id&#039;&#039;&#039; as ID&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, and &#039;&#039;&#039;sell_min&#039;&#039;&#039; from &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, compute &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; using a conditional logic:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;sell_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;DTC&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total =&#039;&#039;&#039;&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_rate] * QuotationCombinedTableDueCarrierTotal[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=139</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=139"/>
		<updated>2025-07-30T13:16:31Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Calculations&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; =&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_rate] * QuotationCombinedTableDueCarrierUSD[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierUSD[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierUSD[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and rename it to &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;exclude all rows where code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, keeping only relevant carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, join &#039;&#039;&#039;quotation_chargesDueCarrierUSD&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, join the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the most recent &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from quotations&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from quotation_chargesDueCarrierUSD&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from quotation_exchange_rates&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total BRL&lt;br /&gt;
|&#039;&#039;&#039;Total Due Carrier BRL =&#039;&#039;&#039;&lt;br /&gt;
QuotationCombinedTableDueCarrierTotal[Due Carrier Total] × QuotationCombinedTableDueCarrierTotal[Exchange Rate]&lt;br /&gt;
|After calculating &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; (which includes all carrier charges, including &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;), convert the amount into &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the relevant &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039; includes both the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; and the correct &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039;, retrieved as the most recent value per &#039;&#039;&#039;quotation_id&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table.&lt;br /&gt;
*&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier BRL =&lt;br /&gt;
QuotationCombinedTableDueCarrierUSD[Due Carrier USD] * QuotationCombinedTableDueCarrierUSD[Exchange Rate]&lt;br /&gt;
|After computing &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039;, convert the value into &#039;&#039;&#039;BRL&#039;&#039;&#039; by applying the corresponding &#039;&#039;&#039;exchange rate&#039;&#039;&#039;.&lt;br /&gt;
Ensure that &#039;&#039;&#039;QuotationCombinedTableDueCarrierUSD&#039;&#039;&#039; already contains the &#039;&#039;&#039;Due Carrier USD&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange Rate&#039;&#039;&#039; (retrieved from the most recent entry in the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table, joined by &#039;&#039;&#039;quotation_id&#039;&#039;&#039;).&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue =&#039;&#039;&#039;&lt;br /&gt;
CALCULATE (&lt;br /&gt;
&lt;br /&gt;
 SUMX (&lt;br /&gt;
&lt;br /&gt;
  QuotationCombinedTableTotalRevenue,&lt;br /&gt;
&lt;br /&gt;
  SWITCH (&lt;br /&gt;
&lt;br /&gt;
   TRUE(),&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;LINEHAUL&amp;quot;, [Sell Rate] * [Chargeable Weight],&lt;br /&gt;
&lt;br /&gt;
   [Code] = &amp;quot;DTC&amp;quot;, [Sell Min],&lt;br /&gt;
&lt;br /&gt;
   0&lt;br /&gt;
&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the quotation charges table, rename it to:&lt;br /&gt;
&#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;.&lt;br /&gt;
This version includes all relevant charge codes for calculating total revenue—specifically &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039; and &#039;&#039;&#039;DTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, perform a &#039;&#039;&#039;NATURALINNERJOIN&#039;&#039;&#039; between the &#039;&#039;&#039;quotations&#039;&#039;&#039; table and &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableTotalRevenue&#039;&#039;&#039;. From this joined table, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;quotation_id&#039;&#039;&#039; as ID&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;sell_rate&#039;&#039;&#039;, and &#039;&#039;&#039;sell_min&#039;&#039;&#039; from &#039;&#039;&#039;quotation_charges_Total Revenue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, compute &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; using a conditional logic:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;LINEHAUL&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;sell_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;code = &amp;quot;DTC&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return 0&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&#039;&#039;&#039;Total Revenue Currency =&#039;&#039;&#039;&lt;br /&gt;
quotation_charges[currency_sell]&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&#039;&#039;&#039;Due Carrier Total =&#039;&#039;&#039;&lt;br /&gt;
SWITCH(&lt;br /&gt;
&lt;br /&gt;
 TRUE(),&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;CH&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_rate] * QuotationCombinedTableDueCarrierTotal[chargeable_weight],&lt;br /&gt;
&lt;br /&gt;
 QuotationCombinedTableDueCarrierTotal[on] = &amp;quot;FL&amp;quot;, QuotationCombinedTableDueCarrierTotal[cost_min],&lt;br /&gt;
&lt;br /&gt;
 0&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Grab the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table and renamed it to &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
From this duplicated table, &#039;&#039;&#039;include all rows&#039;&#039;&#039;, including those where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;, to capture the full set of carrier charges.&lt;br /&gt;
&lt;br /&gt;
Then, &#039;&#039;&#039;join&#039;&#039;&#039; &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039; with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to create &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Also, &#039;&#039;&#039;join&#039;&#039;&#039; the &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039; table to bring in the &#039;&#039;&#039;most recent exchange_rate&#039;&#039;&#039; per quotation.&lt;br /&gt;
&lt;br /&gt;
From &#039;&#039;&#039;QuotationCombinedTableDueCarrierTotal&#039;&#039;&#039;, retrieve the following fields:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from &#039;&#039;&#039;quotations&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, &#039;&#039;&#039;code&#039;&#039;&#039;, &#039;&#039;&#039;cost_min&#039;&#039;&#039;, and &#039;&#039;&#039;on&#039;&#039;&#039; from &#039;&#039;&#039;quotation_chargesDueCarrierTotal&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; from &#039;&#039;&#039;quotation_exchange_rates&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; using the logic based on the &#039;&#039;&#039;on&#039;&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, use &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=138</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=138"/>
		<updated>2025-07-29T10:34:28Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Calculations&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&#039;&#039;&#039;Buying Currency = currency&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&#039;&#039;&#039;AWB Rate = sell_rate&#039;&#039;&#039; from quotation_charges where code = &#039;LINEHAUL&#039;, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, filter to only include the charge where &#039;&#039;&#039;code = &#039;LINEHAUL&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field for this charge, which represents the &#039;&#039;&#039;AWB Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|Total Revenue Currency =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
 SELECTEDVALUE (quotation_charges[currency sell]),&lt;br /&gt;
&lt;br /&gt;
 FILTER (&lt;br /&gt;
&lt;br /&gt;
  quotation_charges,&lt;br /&gt;
&lt;br /&gt;
  quotation_charges[quotation_id] = quotations[id]&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
This logic ensures the currency is selected in the context of the current quotation.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=137</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=137"/>
		<updated>2025-07-29T10:28:48Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Calculations&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&#039;&#039;&#039;flight_number&#039;&#039;&#039; — retrieved from hae_route_parts, filtered to the minimum quotation_route_id per quotation_id, and joined back to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;flight_number&#039;&#039;&#039; associated with each quotation by linking route data. This is done by identifying the first (minimum) &#039;&#039;&#039;quotation_route_id&#039;&#039;&#039; per &#039;&#039;&#039;quotation_id&#039;&#039;&#039;, then using it to pull the corresponding &#039;&#039;&#039;flight_number&#039;&#039;&#039; from the route details.&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax (charge currency) = currency_sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency of the HAE Tax.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|Total Revenue Currency =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
 SELECTEDVALUE (quotation_charges[currency sell]),&lt;br /&gt;
&lt;br /&gt;
 FILTER (&lt;br /&gt;
&lt;br /&gt;
  quotation_charges,&lt;br /&gt;
&lt;br /&gt;
  quotation_charges[quotation_id] = quotations[id]&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
This logic ensures the currency is selected in the context of the current quotation.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|HAE Margin BRL =&lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|After retrieving the &#039;&#039;&#039;HAE Commission&#039;&#039;&#039; and the applicable &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; (ensuring it&#039;s the most recent per quotation_id), calculate the &#039;&#039;&#039;HAE Margin in BRL&#039;&#039;&#039; by converting the commission using the exchange rate.&lt;br /&gt;
If the &#039;&#039;&#039;Exchange_rate&#039;&#039;&#039; is null or zero, return null to avoid invalid conversion.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate = sell rate&#039;&#039;&#039; from quotation_charges, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=136</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=136"/>
		<updated>2025-07-29T09:44:36Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Calculations&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|Total Revenue Currency =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
 SELECTEDVALUE (quotation_charges[currency sell]),&lt;br /&gt;
&lt;br /&gt;
 FILTER (&lt;br /&gt;
&lt;br /&gt;
  quotation_charges,&lt;br /&gt;
&lt;br /&gt;
  quotation_charges[quotation_id] = quotations[id]&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
This logic ensures the currency is selected in the context of the current quotation.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;Sell Rate Currency = currency sell&#039;&#039;&#039; from quotation_charges, joined via quotation_id&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&#039;&#039;&#039;Retrieved Value:&#039;&#039;&#039;&lt;br /&gt;
&#039;&#039;&#039;Mode of Payment = field_value&#039;&#039;&#039; from quotation_fields where carrier_quotation_field_id = 199, joined to quotations via quotation_id.&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Mode of Payment&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering records where &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039;, which corresponds to this customer field.&lt;br /&gt;
Join the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to ensure the value is linked to the correct quotation.&lt;br /&gt;
&lt;br /&gt;
Only values associated with &#039;&#039;&#039;carrier_quotation_field_id = 199&#039;&#039;&#039; are displayed.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=135</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=135"/>
		<updated>2025-07-29T09:38:12Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Transformation Applied ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Query&lt;br /&gt;
!Calculations&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|Total Revenue Currency =&lt;br /&gt;
CALCULATE(&lt;br /&gt;
&lt;br /&gt;
 SELECTEDVALUE (quotation_charges[currency sell]),&lt;br /&gt;
&lt;br /&gt;
 FILTER (&lt;br /&gt;
&lt;br /&gt;
  quotation_charges,&lt;br /&gt;
&lt;br /&gt;
  quotation_charges[quotation_id] = quotations[id]&lt;br /&gt;
&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;currency_sell&#039;&#039;&#039; field, which indicates the currency in which the revenue is quoted.&lt;br /&gt;
&lt;br /&gt;
This logic ensures the currency is selected in the context of the current quotation.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;total_sell&#039;&#039;&#039; field.&lt;br /&gt;
|&#039;&#039;&#039;HAE Invoice Customer Total (Sales) = total_sell&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (Margin) BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=131</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=131"/>
		<updated>2025-07-17T11:22:06Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&#039;&#039;&#039;ET Refund (COST) = total_cost&#039;&#039;&#039; from quotation_totals_local, joined via quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;quotation_totals_local&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the joined data, retrieve the &#039;&#039;&#039;total_cost&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
This value represents the &#039;&#039;&#039;ET Refund (COST)&#039;&#039;&#039; associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=130</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=130"/>
		<updated>2025-07-17T10:54:35Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&#039;&#039;&#039;HAE Tax USD = sell_min&#039;&#039;&#039; from quotation_charges where code = &#039;DTC&#039;, linked to quotations by quotation_id.&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_min&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table where the &#039;&#039;&#039;code = &#039;DTC&#039;.&#039;&#039;&#039;&lt;br /&gt;
Join this table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039; to match the correct quotation. This value represents the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039;, as the charge is stored in USD by default.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|HAE Tax BRL = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot;&lt;br /&gt;
else [HAE Tax USD] * [Exchange_rate]&lt;br /&gt;
|convert the &#039;&#039;&#039;HAE Tax USD&#039;&#039;&#039; amount to &#039;&#039;&#039;BRL&#039;&#039;&#039; by multiplying it with the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039;.&lt;br /&gt;
If the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; is null or zero, return &#039;&#039;&#039;&amp;quot;NOEXR&amp;quot;&#039;&#039;&#039; to indicate a missing or invalid rate.&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=129</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=129"/>
		<updated>2025-07-17T10:43:09Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&#039;&#039;&#039;exchange_rate&#039;&#039;&#039; — retrieved from the exchange_rate table as the most recent entry (by created_at) for each quotation_id.&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table, retrieve the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; field that has the &#039;&#039;&#039;most recent created_at&#039;&#039;&#039; timestamp &#039;&#039;&#039;per quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This ensures that each quotation is matched with the latest available exchange rate record&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|Fixed_exRate = IF(hae_quotations[is_fixed] = TRUE(), &amp;quot;✓&amp;quot;, &amp;quot;×&amp;quot;)&lt;br /&gt;
|Join the &#039;&#039;&#039;exchange_rate&#039;&#039;&#039; table with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039; key.&lt;br /&gt;
From the exchange_rate table, retrieve the &#039;&#039;&#039;is_fixed&#039;&#039;&#039; field that with the most recent created_at per quotation_id&lt;br /&gt;
&lt;br /&gt;
which indicates whether the exchange rate is fixed.&lt;br /&gt;
&lt;br /&gt;
Then evaluate the value:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;TRUE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;✓&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;is_fixed&#039;&#039;&#039; is &#039;&#039;&#039;FALSE&#039;&#039;&#039;, return &#039;&#039;&#039;&amp;quot;×&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=128</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=128"/>
		<updated>2025-07-17T10:30:12Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&#039;&#039;&#039;id&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;id&#039;&#039;&#039; is a unique identifier for each record and is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table. &lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;master_airwaybill&#039;&#039;&#039; field contains the main airway bill number for the shipment. It is pulled directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table for reference and tracking.&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&#039;&#039;&#039;Customer Name&#039;&#039;&#039; — pulled from the customer table via customer_id and linked to the quotations table.&lt;br /&gt;
|Join the &#039;&#039;&#039;customer&#039;&#039;&#039; table to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;customer_id&#039;&#039;&#039; as the key.&lt;br /&gt;
From the joined customer record, retrieve the &#039;&#039;&#039;name&#039;&#039;&#039; field to identify the customer associated with the quotation.&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&#039;&#039;&#039;depart_date&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|The &#039;&#039;&#039;depart_date&#039;&#039;&#039; is obtained directly from the quotations table.&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&#039;&#039;&#039;origin&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&#039;&#039;&#039;destination&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&#039;&#039;&#039;gross_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; — sourced directly from the quotations table.&lt;br /&gt;
|It is retrieved directly from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=127</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=127"/>
		<updated>2025-07-17T10:21:25Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|Due Agent = value from quotation_fields (field ID 204), joined to quotations via quotation_id&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;Due Agent&#039;&#039;&#039; value from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table by filtering for &#039;&#039;&#039;carrier_quotation_field_id = 204&#039;&#039;&#039;, which corresponds to the Due Agent field.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|HAE Over = [Total Sell Rate] - [Total Cost Rate]&lt;br /&gt;
|Retrieve &#039;&#039;&#039;sell_rate&#039;&#039;&#039; and &#039;&#039;&#039;cost_rate&#039;&#039;&#039; from the &#039;&#039;&#039;hae_quotations_local&#039;&#039;&#039; table as &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039; and &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039;, respectively.&lt;br /&gt;
Then, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using the &#039;&#039;&#039;id&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;HAE Over&#039;&#039;&#039; by subtracting the &#039;&#039;&#039;Total Cost Rate&#039;&#039;&#039; from the &#039;&#039;&#039;Total Sell Rate&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=126</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=126"/>
		<updated>2025-07-17T10:13:03Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|Total Revenue = [LINEHAUL.sell_rate] * [chargeable_weight] + [DTC.sell_min]&lt;br /&gt;
|First, filter the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table to get two specific charge types:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_rate&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;DTC&#039;&#039;&#039;, from which you retrieve the &#039;&#039;&#039;sell_min&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Then, access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; from the &#039;&#039;&#039;quotations&#039;&#039;&#039; table.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Total Revenue&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL sell_rate&#039;&#039;&#039; with the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;, and then adding the &#039;&#039;&#039;DTC sell_min&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=125</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=125"/>
		<updated>2025-07-17T10:03:55Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|Buying Rate Total = [hae__routes.LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
|Join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, where the &#039;&#039;&#039;Airfreight rate&#039;&#039;&#039; is &#039;&#039;&#039;LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, extract the &#039;&#039;&#039;cost_rate&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Next, join this data with the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, calculate the &#039;&#039;&#039;Buying Rate Total&#039;&#039;&#039; by multiplying the &#039;&#039;&#039;LINEHAUL cost_rate&#039;&#039;&#039; by the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=124</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=124"/>
		<updated>2025-07-17T10:01:15Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|AWB Issue Date = if [AWB Issue Date] = null then &amp;quot;NO DATA&amp;quot; else [AWB Issue Date]&lt;br /&gt;
|Retrieve the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; from the &#039;&#039;&#039;quotation_fields&#039;&#039;&#039; table where &#039;&#039;&#039;carrier_quotation_field_id&#039;&#039;&#039; equals &#039;&#039;&#039;200&#039;&#039;&#039;, which corresponds to the AWB Issue Date field.&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table using &#039;&#039;&#039;quotation_id&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally, check if the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039; is null; if so, return &#039;&#039;&#039;&amp;quot;NO DATA&amp;quot;&#039;&#039;&#039;. Otherwise, return the &#039;&#039;&#039;AWB Issue Date&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|Due Carrier Total = if [LINEHAUL.on] = &amp;quot;CH&amp;quot; then [LINEHAUL.cost_rate] * [chargeable_weight]&lt;br /&gt;
else if [LINEHAUL.on] = &amp;quot;FL&amp;quot; then [LINEHAUL.cost_min]&lt;br /&gt;
&lt;br /&gt;
else 0&lt;br /&gt;
|First, join the &#039;&#039;&#039;routes&#039;&#039;&#039; table (filtered to &#039;&#039;&#039;carrier_id = 12&#039;&#039;&#039;) with the &#039;&#039;&#039;quotation_charges&#039;&#039;&#039; table, selecting only the charge with &#039;&#039;&#039;Airfreight rate = LINEHAUL&#039;&#039;&#039;.&lt;br /&gt;
From this join, retrieve the fields: &#039;&#039;&#039;on&#039;&#039;&#039;, &#039;&#039;&#039;cost_rate&#039;&#039;&#039;, and &#039;&#039;&#039;cost_min&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Then, join this data to the &#039;&#039;&#039;quotations&#039;&#039;&#039; table to access the &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039; field.&lt;br /&gt;
&lt;br /&gt;
Finally, calculate the &#039;&#039;&#039;Due Carrier Total&#039;&#039;&#039; as follows:&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;CH&amp;quot;&#039;&#039;&#039;, multiply &#039;&#039;&#039;cost_rate&#039;&#039;&#039; by &#039;&#039;&#039;chargeable_weight&#039;&#039;&#039;&lt;br /&gt;
* If &#039;&#039;&#039;on = &amp;quot;FL&amp;quot;&#039;&#039;&#039;, return &#039;&#039;&#039;cost_min&#039;&#039;&#039;&lt;br /&gt;
* Otherwise, return &#039;&#039;&#039;0&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
	<entry>
		<id>https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=123</id>
		<title>ET Customer Invoice Details</title>
		<link rel="alternate" type="text/html" href="https://wiki-reporting.qms-portal.aero/index.php?title=ET_Customer_Invoice_Details&amp;diff=123"/>
		<updated>2025-07-17T09:53:11Z</updated>

		<summary type="html">&lt;p&gt;Collins.bahati: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This report was developed as a custom request from the Brazil-based Operations team to enable them to quickly generate an invoice report for sharing with carrier ET.&lt;br /&gt;
&lt;br /&gt;
It forms part of an ongoing effort to streamline their workflow and support fast, efficient invoice generation and communication with the carrier.&lt;br /&gt;
&lt;br /&gt;
== Filters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Filter&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Site&lt;br /&gt;
|This is locked to the Brazil site&lt;br /&gt;
|-&lt;br /&gt;
|Carrier&lt;br /&gt;
|This is locked to ET Brazil&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|Allows the user to specifically select the customer they want to view the booking details for. Can only select a single customer, or show all. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data Import Calculations ==&lt;br /&gt;
[WIP]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Calculations ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Columns&lt;br /&gt;
!Calculation&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|master_airwaybill&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Customer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Flight_Number&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Depart Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Issue Date&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Exchange_rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Fixed_exRate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|origin&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Destination&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gross_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|chargeable_weight&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Rate Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Buying Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|AWB Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Agent&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Over&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax USD&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax (charge currency)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Tax BRL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (USD)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier (BRL)&lt;br /&gt;
|Due Carrier (BRL)  = if [Exchange_rate] = null or [Exchange_rate] = 0 then &amp;quot;NOEXR&amp;quot; else [Due Carrier (USD)] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the Due Carrier amount in BRL by multiplying [Due Carrier (USD)] by the [Exchange_rate].&lt;br /&gt;
&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns the text &amp;quot;NOEXR&amp;quot; to indicate that no valid exchange rate exists.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from USD to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Total Revenue Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Invoice Customer Total (Sales BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Commision (BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|HAE Margin BRL&lt;br /&gt;
|HAE Margin BRL = &lt;br /&gt;
if ([Exchange_rate] = null or [Exchange_rate] = 0) then null &lt;br /&gt;
&lt;br /&gt;
else [HAE Commission] * [Exchange_rate]&lt;br /&gt;
|This formula calculates the HAE Margin amount in BRL by multiplying [HAE Commission 2] by the [Exchange_rate].&lt;br /&gt;
If the [Exchange_rate] is null or zero, the formula returns null to prevent an invalid calculation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it performs the conversion from the commission value to BRL.&lt;br /&gt;
|-&lt;br /&gt;
|ET Refund (Cost BRL)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Selling Rate Currency&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Mode Of Payment&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Due Carrier Total&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Collins.bahati</name></author>
	</entry>
</feed>