Quotation line items

Prev Next

Now that Linda understands the layout of the header and footer as well as the main structure, she turns her attention to the Quotation posts. Vijay, the Salesforce developer is by her side to better understand the code.

Quotation line items

This part of the code covers the main table of the Quotation, divided into three parts:

  • Headers

  • Quotation line items

  • Subtotals and totals

Let's start with the headers.

Main table headers

By default, the following columns are provided in the template:

  • Description

  • Unit price excl. VAT

  • Quantity

  • Discount rate (displayed only if applicable)

  • VAT (%)

  • Amount excl. tax

<!-- Lignes en-tête produits -->

<tr>

<th class="alignleft">                     

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Designation__c.Label}

</th>

<th class="aligncenter">            

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Prix_Unitaire_HT__c.Label}

</th>

<th class="aligncenter">                           

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Quantite__c.Label}

</th>

<th class="aligncenter" style="display:{!IF(sofactoapp__Offre__c.sofactoapp__Afficher_la_remise__c, '', 'none')}">

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Taux_de_Remise__c.Label}

</th>

<th class="aligncenter"> 

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Taux_de_TVA_list__c.Label}

</th>

<th class="aligncenter">   

{!$ObjectType.sofactoapp__Poste_Offre__c.Fields.sofactoapp__Montant_HT__c.Label}

</th>

</tr>

Note: we always use the label available in the application to display this information. If you use these labels, the English translation is already handled. If you want to change these headers, we recommend using the custom labels.

There is only one conditional column, namely the discount rate which is only displayed if the Show discount box is ticked on the quotation.

The relation between objects

Like the relation between Invoice line item and Invoice, the Quotation line Item object has an N<>1 relation with the Quotation object.

VIjay explains to Linda that it is impossible to retrieve "child" object fields via our usual paths. Here is an article on this subject:  Customize your Visualforce template.

Notre page ne saura pas de quel enregistrement elle doit prendre les champs.

To be able to display the information of the invoice line, we will use apex : repeat. This allows us to go through all the invoice line items to insert the information on the PDF.
We have another thing to consider: The order of the lines may be important for our business case. Therefore, we will string together apex : repeat.

The first apex:repeat uses an extension specified at the top of the page (extensions="sofactoapp.OffreProcessingControllerExtension") which calls a code. This code generates a "map" - a logical table - listing all the Quotation items in the order chosen on the Quotation record.

<apex:repeat value="{!orderedOfferLineItems}" var="orderedLigne" id="orderedLignes">

The second apex:repeat runs through this logical table to ensure its display on the PDF template.

<apex:repeat value="{!sofactoapp__Offre__c.sofactoapp__Postes_d_offre__r}" var="ligne" id="lignes">

The condition set in the apex:OutputPanel tag ensures that this loop stops as soon as the end of the logical array is reached.

 <apex:outputPanel layout="none" rendered="{!ligne.Id == orderedLigne}">

This is why this section is surrounded by two tags:

  • apex:repeat and

  • apex:OutputPanel.

<apex:repeat value="{!orderedOfferLineItems}" var="orderedLigne" id="orderedLignes">

<apex:repeat value="{!sofactoapp__Offre__c.sofactoapp__Postes_d_offre__r}" var="ligne" id="lignes">

<apex:outputPanel layout="none" rendered="{!ligne.Id == orderedLigne}">

<td>...</td>

<td>...</td>

<td>...</td>

...

</apex:outputPanel>

</apex:repeat>

</apex:repeat>

This <td> framing structure contains the code to display the information in the body of the table.
The rows are then taken from the Quotation object.  

Designation

This cell displays by default the fields :

  • Description (Quotation line item).
  • Description (Product) - If the Show product details on invoice box is checked.
  • Detailed description (Product) - If the box Display detailed products on the invoice is ticked.

Unit price

  • If the Show discount box is checked, the unit price excluding VAT field is displayed.
    If the Show discount box is not checked, the unit price excluding VAT after discount field is displayed.

Quantity

  • The quantity indicated on the Quotation line item is taken over.

VAT rate

  • The rate indicated on the Quotation line item is included.

Total amount excl. taxes

  • The total amount before tax represented on the Quotation line item is included.