InvoiceDelivery extends Component
Invoice Delivery component
Consolidates invoice creation and delivery. Supports email, interfax, and postalmethods.
Table of Contents
Properties
| $components | |
| $helpers | |
| $models | |
| $company | |
| $company_settings | |
| $invoices | |
| $language |
Methods
| __construct() | Initialize the Invoice Delivery object |
| deliverInvoices() | Delivers a set of invoices using the given delivery method. All invoices are compiled together into a single document. |
| downloadInvoices() | Offers for download a set of invoices. All invoices are compiled together into a single document. |
| errors() | Returns an errors raised |
| trimSettings() | Removes all settings not relevant to invoices from a list of settings |
| buildDocument() | Generates a PDF document for the given invoices on a specific invoice template |
| buildInvoices() | Takes an array of invoices and constructs a single document object containing all invoice data (e.g. can create a single PDF containing multiple invoices). |
| getInvoices() | Fetches invoices and groups them by client ID |
| primeCompany() | Sets the company and company settings properties for the current company |
Properties
$components
protected
mixed
$components
$helpers
protected
mixed
$helpers
$models
protected
mixed
$models
$company
private
object
$company
An object representing the company being processed
$company_settings
private
array<string|int, mixed>
$company_settings
Company settings
$invoices
private
array<string|int, mixed>
$invoices
An array of stdClass objects representing invoices
$language
private
string
$language
The language code to use for all email correspondence
Methods
__construct()
Initialize the Invoice Delivery object
public
__construct() : mixed
deliverInvoices()
Delivers a set of invoices using the given delivery method. All invoices are compiled together into a single document.
public
deliverInvoices(array<string|int, mixed> $invoice_ids, string $delivery_method[, mixed $deliver_to = null ][, string $from_staff_id = null ][, array<string|int, mixed> $options = null ]) : mixed
Parameters
- $invoice_ids : array<string|int, mixed>
-
An array of invoice IDs to deliver
- $delivery_method : string
-
The delivery method (email, interfax, postalmethods)
- $deliver_to : mixed = null
-
The destination of the invoices, a string or array of email addresses or fax numbers (optional, can not override invoice postal address)
- $from_staff_id : string = null
-
The ID of the staff member this invoice is to be delivered from (optional)
- $options : array<string|int, mixed> = null
-
An array of additional options to pass and may include:
- base_client_url The base URL to the client interface
- email_template The email template name to use (optional)
- email_tags An array of key/value tag replacements (optional)
- language The language to use (optional, defaults to the invoice client's language, or the system's language otherwise)
downloadInvoices()
Offers for download a set of invoices. All invoices are compiled together into a single document.
public
downloadInvoices(array<string|int, mixed> $invoice_ids[, array<string|int, mixed> $options = null ]) : mixed
Parameters
- $invoice_ids : array<string|int, mixed>
-
A numerically-indexed array of invoice IDs from which to download
- $options : array<string|int, mixed> = null
-
An array of options including (optional):
- language The language to use (optional, defaults to the invoice client's language, or the system's language otherwise)
errors()
Returns an errors raised
public
errors() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of errors, boolean false if no errors were set
trimSettings()
Removes all settings not relevant to invoices from a list of settings
protected
trimSettings(array<string|int, mixed> $settings[, mixed $company_id = null ]) : array<string|int, mixed>
Parameters
- $settings : array<string|int, mixed>
-
The list of settings to filter
- $company_id : mixed = null
Return values
array<string|int, mixed> —The filtered list of settings
buildDocument()
Generates a PDF document for the given invoices on a specific invoice template
private
buildDocument(string $language, bool $include_address[, array<string|int, mixed> $invoices = null ]) : InvoiceTemplates
Parameters
- $language : string
-
The language for all invoices in the document
- $include_address : bool
-
True to include the address on the invoice
- $invoices : array<string|int, mixed> = null
-
A numerically indexed array of invoice objects
Return values
InvoiceTemplates —The document of the invoices
buildInvoices()
Takes an array of invoices and constructs a single document object containing all invoice data (e.g. can create a single PDF containing multiple invoices).
private
buildInvoices(array<string|int, mixed> $invoices[, bool $include_address = true ][, array<string|int, mixed> $options = null ]) : object
Parameters
- $invoices : array<string|int, mixed>
- $include_address : bool = true
-
True to include address information on the invoices, false otherwise
- $options : array<string|int, mixed> = null
-
An array of options including (optional):
- language The language to use (optional, defaults to the invoice client's language, or the system's language otherwise)
Return values
object —The object containing the build invoices
getInvoices()
Fetches invoices and groups them by client ID
private
getInvoices(array<string|int, mixed> $invoice_ids[, bool $merge = false ]) : array<string|int, mixed>
Parameters
- $invoice_ids : array<string|int, mixed>
-
An array of invoice ID numbers to fetch
- $merge : bool = false
-
True to merge all invoices together in single large array, false to keep invoices divided by client ID
Return values
array<string|int, mixed> —An array of stdClass invoice object grouped by client ID (if $merge is true 1st index is numeric, otherwise 1st index is client ID, 2nd index is numeric)
primeCompany()
Sets the company and company settings properties for the current company
private
primeCompany([int $company_id = null ]) : mixed
Parameters
- $company_id : int = null
-
The ID of the company to prime