You now need to output the net totals, the VAT and the total amount in the invoice footer. You can simply insert these values if they are held as fields in the database.
In our case, however, you must first calculate the values. To do this, you use the "Sum()" aggregate function. This function totals the values that are passed to it.
Since the totals are to be output at the end of the table, you define a footer for this purpose.
1. Click the "Append Line" button in the mini toolbar and then click "Footer".
Figure 2.56: Add new line
2. You have not yet defined a line for this line type so you will be asked whether you want to use an existing line definition from one of the other line types. This wouldn't save any time at this point. Therefore, choose the "Single field or free content" option.
Figure 2.57: Applying a line definition
3. The formula wizard will open to allow you to define the contents of the first column. Enter "Subtotal", not forgetting to enclose it in quotation marks.
4. Once you have created the first line, add another column to it for the aggregation. Use the "Sum()" function for aggregating values. You can either type it in directly in the result field in the formula wizard or you can select the function from the list of aggregate functions by double-clicking. As a parameter, enter the value to be aggregated � in this case Quantity*ItemPrice.
Figure 2.58: Totaling with Sum()
5. The entire line should now be moved a little to the right. Hold down the Ctrl key and drag the column separator on the extreme left at the outer edge of the table to the right. An empty column will be inserted automatically as a spacer on the extreme left.
6. You must also format the total field as currency, give both columns the same background color as the header line and set the "Top" margin to 0.1 inch to correspond with the "Bottom" margin of the header line.
7. As these footers are only to be output on the last page, even in the case of multiple page invoices, you must now specify the "Lastpage()" or "LastFooterThisTable()" function for the "Appearance Condition" line property.
Figure 2.59: Object dialog with 3 columns
8. You have now defined the first footer and the invoice looks like this:
Figure 2.60: Preview (footer)