Invoice templates allow invoice documents to be downloaded in a variety of formats. All invoice templates must extend the InvoiceTemplate class.
Invoice Template Structure
Each invoice template is a directory in /components/invoice_templates/. From within that directory, each invoice template must consist of a class that matches the name of the invoice template. For example, the quickbooks_invoice template is identified by /components/invoice_templates/quickbooks_invoice/quickbooks_invoice.php. Invoice templates may have any other additional supporting classes and assets.
Templates that wish to take advantage of PDF formatting may take advantage of the TcpdfWrapper available in /components/invoice_templates/.
Call Structure
When an invoice template is initialized to render an invoice document, setMeta is called to set all invoice-related meta data. setCurrency is then called to pass the CurrencyFormat helper to the template. Next, setMimeType is invoked to tell the template what format to render the invoice document in. includeAddress is called to set whether or not address information should be included in the document. The template is told to build the document when makeDocument is passed an array of invoice objects. Generally only one invoice is rendered at a time, but in some cases multiple invoices will be included in the same document (e.g. multiple pages in a PDF file). Lastly, the document is output in one of three ways: fetch, stream, or download, one of which is invoked by the caller.