Edit Template



Once a new template is saved, the document’s Mediacannot be changed. 


Clone Template

You may create a new template as a clone of an existing one. For this, open the template you want to clone and click the Clone button. The cloned template inherits all of the parameters from the original template and can then be customized as desired.


NOTE: When you clone templates that have taxes included in the rate, a cloned invoice template will not inherit the taxes defined in the post processing rules. Therefore, you need to define these taxes on the Custom Taxes page and assign them to a customer or customer class.


Edit Template


The Media tab is present for all types of templates, and shows the media available for download. For Invoice Templates, the Media tab contains a link to the PortaBilling® Layout Designer, which allows you to customize the appearance of your invoices and receipts.




The content of the Header, Fields, Columns, and Footer tabs is arranged in a similar way, and allows flexible mapping of information related to user documents and information in the PortaBilling® database.


Column Description


Description of template components.

Target Column

Defines the mapping of template information to the original / destination document.


Data format.

  • Choose a format from the list, or

  • select Other if the desired format is not available. Provide a format definition in the following field.

Other Format Rule

Perl code. Active only if Format = “Other:”

Post Processing Rule

Perl code.



You can use the PortaBilling template engine to handle the import or export of data from PortaBilling . Since the template processor knows nothing about the format of your data, you will have to provide it with detailed instructions. You will have to tell the template processor about the file format of the input file, where the useful data is located inside that file, and how to format the data. Of course, you will enter these instructions as a template definition, so that:



PortaBilling provides a ready-to-use invoicing functionality. You can design how your invoices will look. Invoices are created automatically based on calls the customer has made; they are stored as a PDF file and can be viewed online or printed. They are also automatically emailed to the customer if he has an email address set up in his properties.

Only customers (both resellers and retail customers) are invoiced, since only they have all the information required for invoicing, such as address, taxpayer ID, and so forth. Individual accounts are not invoiced.

Each customer has his own billing period, which could be:

When the current billing period is over (for example, on the first day of the month) a summary of all the calls made by the customer is calculated. Customer call statistics are generated and stored on the server (optionally, they can also be mailed to the customer automatically) and an invoice is created.


NOTE: Billing period is based on the customer's time zone.


Statistics are generated with a sufficient delay to make sure that the billing period for a particular customer (according to that customer's time zone) has ended. Also, statistics calculation takes place only at a certain time of day (usually during night hours, when there is the least amount of activity in the system).


There are two methods available for calculating the invoice total:


All charges during the period

This is the simpler method. The invoice contains all of the call charges for the specified period, with the invoice total equaling the sum of these charges. Balance adjustments, refunds and payments made by a customer via the online payment system are not included, since these refer to transactions which have already been made and will not occur again.

Including the previous balance

The invoice total will be calculated as:


Previous invoice total

+ Sum of all charges during the period (call-related or manual charges)

- Sum of all payments or refunds made during the period


Invoice Template

The invoice template is a specially formatted HTML document, which is created using the PortaBilling Layout Designer. It defines how the invoice should look, with information on fonts, colors, pictures, and placement of the components. When you view the invoice on the web interface, or when the invoice is automatically emailed to the customer, the template engine takes the invoice template and simply fills in the data fields with their real values. The result of this processing could be an HTML document or a PDF file.


Two predefined invoice templates are supplied with PortaBilling:


Single-page invoice

This is a traditional-style invoice. It consists of a single page with an invoice header (your company name, customer name, etc.), invoice fields (invoice number, invoice date), and invoice footer (subtotal, total).

Multi-page invoice

This template's first page is identical to the single-page invoice template. In addition to this, it may contain multiple pages with details of calls related to the invoice.


Data for an invoice may have a very complex structure. In order to facilitate such cases, data within the template is split into different groups, called "template components", so that it can be managed separately.

We can clearly identify a few independent groups of data for Invoice:



For Invoices, Media tab contains link to PortaBilling Layout Designer, which allows to perform the customization of the look of your invoices and receipts.


A header contains data fields with global data for the object. On the invoice this would be the invoice number or the name of the company issuing the invoice.

Page Header & Footer

This template component is available only for printable forms in which data is split across several pages. Data fields defined in it will be placed at the top/bottom of each printed page.


Similar to the Header, this component contains global data for the object to be processed. Data fields are split between the Header and Fields simply for convenience, with the Header containing the main parameters, while auxiliary parameters are included in Fields.

Columns (repeating groups)

This is the most important component, since it describes the variable portion of the data. For example, some entries have the same structure and format. However, there are many rows in the file, and each row is an independent object. Thus, you define how one single row of data is to be formatted, and this will then be applied to all rows in the file.


Contains additional data about the object; for example, invoice totals.