public
|
#
__construct( )
Initialize Invoices
Overrides
|
public
integer
|
#
add( array $vars )
Creates a new invoice using the given data
Creates a new invoice using the given data
Parameters
- $vars
array $vars An array of invoice data including: - client_id The client ID the invoice
belongs to - date_billed The date the invoice goes into effect - date_due The
date the invoice is due - date_closed The date the invoice was closed -
date_autodebit The date the invoice should be autodebited - status
'active','draft','proforma', or 'void' - currency The ISO 4217 3-character
currency code of the invoice - note_public Notes visible to the client -
note_private Notes visible only to staff members - lines A numerically indexed
array of line item info including: - service_id The service ID attached to this
line item (optional) - description The line item description - qty The quantity
for this line item (min. 1) - amount The unit cost (cost per quantity) for this
line item - tax Whether or not to tax the line item - term The term for the
recurring invoice as an integer 1-65535, if blank will not be considered for a
recurring invoice - period The period for the recurring invoice ('day', 'week',
'month', 'year') - duration The duration of the recurring invoice
('indefinitely' for forever or 'times' for a set number of times) -
duration_time The number of times an invoice should recur - recur_date_billed
The date the next invoice will be created - delivery A numerically indexed array
of delivery methods
Returns
integer The invoice ID, void on error
|
public
integer
|
#
addRecurring( array $vars )
Creates a new recurring invoice using the given data
Creates a new recurring invoice using the given data
Parameters
- $vars
array $vars An array of invoice data including: - client_id The client ID the invoice
belongs to - term The term as an integer 1-65535 (optional, default 1) - period
The period, 'day', 'week', 'month', 'year' - duration The number of times this
invoice will recur or null to recur indefinitely - date_renews The date the next
invoice will be created - currency The currency this invoice is created in -
note_public Notes visible to the client - note_private Notes visible only to
staff members - lines A numerically indexed array of line item info including: -
description The line item description - qty The quantity for this line item
(min. 1) - amount The unit cost (cost per quantity) for this line item - tax
Whether or not to tax the line item - delivery A numerically indexed array of
delivery methods
Returns
integer The recurring invoice ID, void on error
|
public
integer
|
#
edit( integer $invoice_id, array $vars )
Updates an invoice using the given data. If a new line item is added, or the
quantity, unit cost, or tax status of an item is updated the latest tax rules
will be applied to this invoice.
Updates an invoice using the given data. If a new line item is added, or the
quantity, unit cost, or tax status of an item is updated the latest tax rules
will be applied to this invoice.
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to update
- $vars
array $vars An array of invoice data (all optional unless noted otherwise) including:
- client_id The client ID the invoice belongs to - date_billed The date the
invoice goes into effect - date_due The date the invoice is due - date_closed
The date the invoice was closed - date_autodebit The date the invoice should be
autodebited - status 'active','draft','proforma', or 'void' - currency The ISO
4217 3-character currency code of the invoice - note_public Notes visible to the
client - note_private Notes visible only to staff members - lines A numerically
indexed array of line item info including: - id The ID for this line item
(required to update, else will add as new) - service_id The service ID attached
to this line item - description The line item description (if empty, along with
amount, will delete line item) - qty The quantity for this line item (min. 1) -
amount The unit cost (cost per quantity) for this line item (if empty, along
with description, will delete line item) - tax Whether or not to tax the line
item - term If editing a draft, the term for the recurring invoice as an integer
1-65535, if blank will not be considered for a recurring invoice - period If
editing a draft, the period for the recurring invoice ('day', 'week', 'month',
'year') - duration If editing a draft, the duration of the recurring invoice
('indefinitely' for forever or 'times' for a set number of times) -
duration_time If editing a draft, the number of times an invoice should recur -
recur_date_billed If editing a draft, the date the next invoice will be created
- delivery A numerically indexed array of delivery methods
Returns
integer The invoice ID, void on error
|
public
integer
|
#
editRecurring( integer $invoice_recur_id, array $vars )
Updates a recurring invoice using the given data. If a new line item is
added, or the quantity, unit cost, or tax status of an item is updated the
latest tax rules will be applied to this invoice.
Updates a recurring invoice using the given data. If a new line item is
added, or the quantity, unit cost, or tax status of an item is updated the
latest tax rules will be applied to this invoice.
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice to update
- $vars
array $vars An array of invoice data (all optional) including: - client_id The client
ID the recurring invoice belongs to - term The term as an integer 1-65535
(optional, default 1) - period The period, 'day', 'week', 'month', 'year' -
duration The number of times this invoice will recur or null to recur
indefinitely - date_renews The date the next invoice will be created -
date_last_renewed The date the last invoice was created (optional) - not
recommended to overwrite this value - currency The currency this invoice is
created in - note_public Notes visible to the client - note_private Notes
visible only to staff members - lines A numerically indexed array of line item
info including: - id The ID for this line item (required to update, else will
add as new) - description The line item description (if empty, along with
amount, will delete line item) - qty The quantity for this line item (min. 1) -
amount The unit cost (cost per quantity) for this line item (if empty, along
with description, will delete line item) - tax Whether or not to tax the line
item - delivery A numerically indexed array of delivery methods
Returns
integer The recurring invoice ID, void on error
|
public
boolean
|
#
addFromRecurring( integer $invoice_recur_id, array $client_settings = null )
Creates a new invoice if the given recurring invoice is set to be renewed
Creates a new invoice if the given recurring invoice is set to be renewed
Parameters
- $invoice_recur_id
integer $invoice_recur_id The recurring invoice ID
- $client_settings
array $client_settings A list of client settings belonging to this invoice's client
(optional)
Returns
boolean True if any invoices were created from this recurring invoice, false otherwise
|
public
|
#
deleteDraft( integer $invoice_id )
Permanently deletes a draft invoice
Permanently deletes a draft invoice
Parameters
- $invoice_id
integer $invoice_id The invoice ID of the draft invoice to delete
|
public
|
#
deleteRecurring( integer $invoice_recur_id )
Permanently removes a recurring invoice from the system
Permanently removes a recurring invoice from the system
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice to delete
|
public
integer
|
#
createFromServices( integer $client_id, array $service_ids, string $currency, string $due_date, boolean $allow_pro_rata = true, boolean $services_renew = false )
Creates an invoice from a set of services
Creates an invoice from a set of services
Parameters
- $client_id
integer $client_id The ID of the client to create the invoice for
- $service_ids
array $service_ids A numerically-indexed array of service IDs to generate line items
from
- $currency
string $currency The currency code to use to generate the invoice
- $due_date
string $due_date The date the invoice is to be due
- $allow_pro_rata
boolean $allow_pro_rata True to allow the services to be priced considering the package
pro rata details, or false otherwise (optional, default true)
- $services_renew
boolean $services_renew True if all of the given $service_ids are renewing services, or
false if all $service_ids are new services (optional, default false)
Returns
integer $invoice_id The ID of the invoice generated
|
public
integer
|
#
appendServices( integer $invoice_id, array $service_ids )
Edits an invoice to append a set of service IDs as line items
Edits an invoice to append a set of service IDs as line items
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to append to
- $service_ids
array $service_ids A numerically-indexed array of service IDs to generate line items
from
Returns
integer $invoice_id The ID of the invoice updated
|
public
boolean
|
#
setClosed( integer $invoice_id )
Sets the invoice to closed if the invoice has been paid in full, otherwise
removes any closed status previously set on the invoice. Only invoices with
status of 'active' can be closed.
Sets the invoice to closed if the invoice has been paid in full, otherwise
removes any closed status previously set on the invoice. Only invoices with
status of 'active' can be closed.
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to close or unclose
Returns
boolean True if the invoice was closed, false otherwise
|
public
mixed
|
#
get( integer $invoice_id )
Fetches the given invoice
Fetches the given invoice
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to fetch
Returns
mixed A stdClass object containing invoice information, false if no such invoice
exists
|
public
mixed
|
#
getRecurring( integer $invoice_recur_id )
Fetches the given recurring invoice
Fetches the given recurring invoice
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice to fetch
Returns
mixed A stdClass object containing recurring invoice information, false if no such
recurring invoice exists
|
public
mixed
|
#
getRecurringFromInvoices( integer $invoice_id )
Fetches the recurring invoice record that produced the given invoice ID
Fetches the recurring invoice record that produced the given invoice ID
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice created by a recurring invoice
Returns
mixed A stdClass object representing the recurring invoice, false if no such recurring
invoice exists or the invoice was not created from a recurring invoice
|
public
array
|
#
getTaxTotals( float $line_subtotal, array $taxes )
Calculates the amount of tax for each tax rule given that applies to the
given line sub total (which is unit cost * quantity). Also returns the line
total including inclusive tax rules as well as the total with all tax rules
Calculates the amount of tax for each tax rule given that applies to the
given line sub total (which is unit cost * quantity). Also returns the line
total including inclusive tax rules as well as the total with all tax rules
Parameters
- $line_subtotal
float $line_subtotal The subtotal (quanity * unit cost) for the line item
- $taxes
array $taxes An array of stdClass objects each representing a tax rule to be applied
to the line subtotal
Returns
array An array containing the following: - tax An array of tax rule applied amounts -
tax_subtotal The tax subtotal (all inclusive taxes applied) - tax_total All
taxes applied (inclusive and exclusive) - line_total The total for the line
including inclusive taxes - line_total_w_tax The total for the line including
all taxes (inclusive and exclusive)
|
public
array
|
#
getLineItems( integer $invoice_id )
Fetches all line items belonging to the given invoice
Fetches all line items belonging to the given invoice
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to fetch line items for
Returns
array An array of stdClass objects each representing a line item
|
public
array
|
#
getRecurringLineItems( integer $invoice_recur_id )
Fetches all line items belonging to the given recurring invoice
Fetches all line items belonging to the given recurring invoice
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice to fetch line items for
Returns
array An array of stdClass objects each representing a line item
|
public
array
|
#
getList( integer $client_id = null, string $status = "open", integer $page = 1, array $order_by = array('date_due'=>"ASC") )
Fetches a list of invoices for a client
Fetches a list of invoices for a client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get invoices for all
clients)
- $status
string $status The status type of the invoices to fetch (optional, default 'open') one
of the following: - open Fetches all active open invoices - closed Fetches all
closed invoices - past_due Fetches all active past due invoices - draft Fetches
all invoices with a status of "draft" - void Fetches all invoices with a status
of "void" - active Fetches all invoices with a status of "active" - proforma
Fetches all invoices with a status of "proforma" - to_autodebit Fetches all
invoices that are ready to be autodebited now, and which can be with an active
client and payment account to do so - pending_autodebit Fetches all invoice that
are set to be autodebited in the future, and which have an active client and
payment account to do so with - to_print Fetches all paper invoices set to be
printed - printed Fetches all paper invoices that have been set as printed -
pending Fetches all active invoices that have not been billed for yet -
to_deliver Fetches all invoices set to be delivered by a method other than paper
(i.e. deliverable invoices not in the list of those "to_print") - all Fetches
all invoices
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
array An array of stdClass objects containing invoice information, or false if no
invoices exist
|
public
integer
|
#
getListCount( integer $client_id = null, string $status = "open" )
Returns the total number of invoices returned from Invoices::getClientList(),
useful in constructing pagination for the getList() method.
Returns the total number of invoices returned from Invoices::getClientList(),
useful in constructing pagination for the getList() method.
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get invoice count for all
clients)
- $status
string $status The status type of the invoices to fetch (optional, default 'open') one
of the following: - open Fetches all active open invoices - closed Fetches all
closed invoices - past_due Fetches all active past due invoices - draft Fetches
all invoices with a status of "draft" - void Fetches all invoices with a status
of "void" - active Fetches all invoices with a status of "active" - proforma
Fetches all invoices with a status of "proforma" - to_autodebit Fetches all
invoices that are ready to be autodebited now, and which can be with an active
client and payment account to do so - pending_autodebit Fetches all invoice that
are set to be autodebited in the future, and which have an active client and
payment account to do so with - to_print Fetches all paper invoices set to be
printed - printed Fetches all paper invoices that have been set as printed -
pending Fetches all active invoices that have not been billed for yet -
to_deliver Fetches all invoices set to be delivered by a method other than paper
(i.e. deliverable invoices not in the list of those "to_print") - all Fetches
all invoices
Returns
integer The total number of invoices
See
|
public
array
|
#
getAll( integer $client_id = null, string $status = "open", array $order_by = array('date_due'=>"ASC"), string $currency = null )
Fetches all invoices for a client
Fetches all invoices for a client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get invoices for all
clients)
- $status
string $status The status type of the invoices to fetch (optional, default 'open') one
of the following: - open Fetches all active open invoices - closed Fetches all
closed invoices - past_due Fetches all active past due invoices - draft Fetches
all invoices with a status of "draft" - void Fetches all invoices with a status
of "void" - active Fetches all invoices with a status of "active" - proforma
Fetches all invoices with a status of "proforma" - to_autodebit Fetches all
invoices that are ready to be autodebited now, and which can be with an active
client and payment account to do so - pending_autodebit Fetches all invoice that
are set to be autodebited in the future, and which have an active client and
payment account to do so with - to_print Fetches all paper invoices set to be
printed - printed Fetches all paper invoices that have been set as printed -
pending Fetches all active invoices that have not been billed for yet -
to_deliver Fetches all invoices set to be delivered by a method other than paper
(i.e. deliverable invoices not in the list of those "to_print") - all Fetches
all invoices
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
- $currency
string $currency The currency code to limit results on (null = any currency)
Returns
array An array of stdClass objects containing invoice information
|
public
|
#
getAllWithService( integer $service_id, integer $client_id = null, string $status = "open", array $order_by = array('date_due'=>"ASC") )
Fetches all invoices that contain the given service
Fetches all invoices that contain the given service
Parameters
- $service_id
integer $service_id The ID of the service whose invoices to fetch
- $client_id
integer $client_id The client ID (optional, default null to get invoices for all
clients)
- $status
string $status The status type of the invoices to fetch (optional, default 'open') one
of the following: - open Fetches all active open invoices - closed Fetches all
closed invoices - past_due Fetches all active past due invoices - draft Fetches
all invoices with a status of "draft" - void Fetches all invoices with a status
of "void" - active Fetches all invoices with a status of "active" - proforma
Fetches all invoices with a status of "proforma" - to_autodebit Fetches all
invoices that are ready to be autodebited now, and which can be with an active
client and payment account to do so - pending_autodebit Fetches all invoice that
are set to be autodebited in the future, and which have an active client and
payment account to do so with - to_print Fetches all paper invoices set to be
printed - printed Fetches all paper invoices that have been set as printed -
pending Fetches all active invoices that have not been billed for yet -
to_deliver Fetches all invoices set to be delivered by a method other than paper
(i.e. deliverable invoices not in the list of those "to_print") - all Fetches
all invoices
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
|
public
array
|
#
getAllAutodebitableInvoices( integer $client_group_id, boolean $pending = false, string $days = "autodebit_days_before_due" )
Fetches all invoices for this company that are autodebitable by their
respective clients
Fetches all invoices for this company that are autodebitable by their
respective clients
Parameters
- $client_group_id
integer $client_group_id The client group ID
- $pending
boolean $pending True to fetch all invoices that will be ready to autodebit in the
future, or false to fetch all invoices ready to be autodebited (optional,
default false)
- $days
string $days The number of days before invoices are to be autodebited -
autodebit_days_before_due Use the autodebit days before due setting -
notice_pending_autodebit Use the autodebit days before due setting plus the
notice pending autodebit setting
Returns
array An array of client IDs, each containing an array of stdClass objects
representing invoice information
|
public
array
|
#
search( string $query, integer $page = 1 )
Search invoices
Parameters
- $query
string $query The value to search invoices for
- $page
integer $page The page number of results to fetch (optional, default 1)
Returns
array An array of invoices that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of invoices returned from Invoices::search(), useful
in constructing pagination
Return the total number of invoices returned from Invoices::search(), useful
in constructing pagination
Parameters
- $query
string $query The value to search invoices for
See
|
public
array
|
#
getAllRecurring( integer $client_id = null )
Fetches all recurring invoices for a client
Fetches all recurring invoices for a client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get recurring invoices for
all clients)
Returns
array An array of stdClass objects containing recurring invoice information
|
public
array
|
#
getAllRenewingRecurring( integer $client_group_id )
Fetches all renewing recurring invoices. That is, where the date_renews is
<= current date + the maximum invoice days before renewal for the current
client group and the recurring invoice has not already created all invoices to
be created.
Fetches all renewing recurring invoices. That is, where the date_renews is
<= current date + the maximum invoice days before renewal for the current
client group and the recurring invoice has not already created all invoices to
be created.
Parameters
- $client_group_id
integer $client_group_id The ID of the client group whose renewing recurring invoices to
fetch
Returns
array An array of stdClass objects, each representing a recurring invoice
|
public
array
|
#
getRecurringList( integer $client_id = null, integer $page = 1, array $order = array('id'=>"asc") )
Fetches a list of recurring invoices for a client
Fetches a list of recurring invoices for a client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get recurring invoices for
all clients)
- $page
integer $page The page to return results for
- $order
array $order The fields and direction to order by. Key/value pairs where key is the
field and value is the direction (asc/desc)
Returns
array An array of stdClass objects containing recurring invoice information
|
public
integer
|
#
getRecurringListCount( integer $client_id )
Return the total number of recurring invoices returned from
Invoices::getRecurringList(), useful in constructing pagination for the
getList() method.
Return the total number of recurring invoices returned from
Invoices::getRecurringList(), useful in constructing pagination for the
getList() method.
Parameters
- $client_id
integer $client_id The client ID
Returns
integer The total number of recurring invoices
See
|
public
mixed
|
#
getRecurringInfo( integer $invoice_id )
Evaluates the given invoice, performs necessary looks ups to determine if the
invoice is for a recurring invoice or service. Returns the term and period for
the recurring invoice or service.
Evaluates the given invoice, performs necessary looks ups to determine if the
invoice is for a recurring invoice or service. Returns the term and period for
the recurring invoice or service.
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice
Returns
mixed boolean false if the invoice is not for a recurring service or invoice,
otherwise an array of recurring info including: - amount The amount to recur -
term The term to recur - period The recurring period (day, week, month, year,
onetime) used in conjunction with term in order to determine the next recurring
payment
|
public
array
|
#
getPricingPeriods( )
Retrieves a list of recurring invoice periods
Retrieves a list of recurring invoice periods
Returns
array Key=>value pairs of recurring invoice pricing periods
|
public
mixed
|
#
getAutodebitDate( integer $invoice_id )
Retrieves the date that the given invoice should be autodebited. This
considers current client settings and autodebit accounts.
Retrieves the date that the given invoice should be autodebited. This
considers current client settings and autodebit accounts.
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice
Returns
mixed A string representing the UTC date that this invoice will be autodebited, or
false if the invoice cannot be autodebited
|
public
integer
|
#
getStatusCount( integer $client_id = null, string $status = "open" )
Retrieves the number of invoices given an invoice status for the given
client
Retrieves the number of invoices given an invoice status for the given
client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get invoice count for
company)
- $status
string $status The status type of the invoices to fetch (optional, default 'open') one
of the following: - open Fetches all active open invoices - closed Fetches all
closed invoices - past_due Fetches all active past due invoices - draft Fetches
all invoices with a status of "draft" - void Fetches all invoices with a status
of "void" - active Fetches all invoices with a status of "active" - proforma
Fetches all invoices with a status of "proforma" - to_print Fetches all paper
invoices set to be printed - printed Fetches all paper invoices that have been
set as printed - pending Fetches all active invoices that have not been billed
for yet - to_deliver Fetches all invoices set to be delivered by a method other
than paper (i.e. deliverable invoices not in the list of those "to_print")
Returns
integer The number of invoices of type $status for $client_id
|
public
integer
|
#
getRecurringCount( integer $client_id = null )
Retrieves the number of recurring invoices for the given client
Retrieves the number of recurring invoices for the given client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get recurring invoice count
for company)
Returns
integer The number of recurring invoices for $client_id
|
public
array
|
#
getDelivery( integer $invoice_id, boolean $sent = null )
Fetches all invoice delivery methods this invoice is assigned
Fetches all invoice delivery methods this invoice is assigned
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice
- $sent
boolean $sent True to get only invoice delivery records that have been sent, or false to
get only delivery records that have not been sent (optional, defaults to fetch
all)
Returns
array An array of stdClass objects containing invoice delivery log information
|
public
array
|
#
getAllDelivery( array $invoice_ids = null, string $delivery_method = null, string $status = "all" )
Fetches all invoice delivery records assigned to each of the given invoice
IDs
Fetches all invoice delivery records assigned to each of the given invoice
IDs
Parameters
- $invoice_ids
array $invoice_ids A list of invoice IDs (optional)
- $delivery_method
string $delivery_method The delivery method to filter by (e.g. "email"), (optional)
- $status
string $status The delivery status, either "all" for all, "unsent" for deliveries not
marked sent, or "sent" for deliveries marked sent (optional, default "all")
Returns
array An array of stdClass objects containing invoice delivery log information
|
public
array
|
#
getRecurringDelivery( integer $invoice_recur_id )
Fetches all invoice delivery methods this recurring invoice is assigned
Fetches all invoice delivery methods this recurring invoice is assigned
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice
Returns
array An array of stdClass objects containing invoice delivery log information
|
public
integer
|
#
addDelivery( integer $invoice_id, array $vars, integer $client_id )
Adds the invoice delivery status for the given invoice
Adds the invoice delivery status for the given invoice
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to update delivery status for
- $vars
array $vars An array of invoice delivery information including: - method The delivery
method
- $client_id
integer $client_id The ID of the client to add the delivery method under
Returns
integer The invoice delivery ID, void on error
|
public
integer
|
#
addRecurringDelivery( integer $invoice_recur_id, array $vars, integer $client_id )
Adds the invoice delivery status for the given recurring invoice
Adds the invoice delivery status for the given recurring invoice
Parameters
- $invoice_recur_id
integer $invoice_recur_id The ID of the recurring invoice to update delivery status for
- $vars
array $vars An array of invoice delivery information including: - method The delivery
method
- $client_id
integer $client_id The ID of the client to add the delivery method under
Returns
integer The recurring invoice delivery ID, void on error
|
public
|
#
getDeliveryList( string $method = null, integer $page = 1, array $order_by = array('date_sent' => "DESC") )
Fetches a list of invoice deliveries for the currently active company
Fetches a list of invoice deliveries for the currently active company
Parameters
- $method
string $method The delivery method to filter by (optional, default null for all)
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
|
public
integer
|
#
getDeliveryListCount( string $method = null )
Retrieves the total number of invoice deliveries for the currently active
company
Retrieves the total number of invoice deliveries for the currently active
company
Parameters
- $method
string $method The delivery method to filter by (optional, default null for all)
Returns
integer The total number of invoice deliveries
|
public
array
|
#
getDeliveryMethods( integer $client_id = null, integer $client_group_id = null, boolean $enabled = true )
Fetches all invoice delivery methods that are supported or enabled for this
company
Fetches all invoice delivery methods that are supported or enabled for this
company
Parameters
- $client_id
integer $client_id The ID of the client to fetch the delivery methods for
- $client_group_id
integer $client_group_id The ID of the client group to fetch the delivery methods for if
$client_id is not given
- $enabled
boolean $enabled If true, will only return delivery methods that are enabled for this
company, else all supported methods are returned
Returns
array An array of delivery methods in key/value pairs
|
public
|
#
delivered( integer $invoice_delivery_id, integer $company_id = null )
Marks the delivery status as sent
Marks the delivery status as sent
Parameters
- $invoice_delivery_id
integer $invoice_delivery_id The ID of the delivery item to mark as sent
- $company_id
integer $company_id The ID of the company whose invoice to mark delivered. Invoices not
belonging to the given company will be ignored (optional, default null to not
check the invoice company)
|
public
|
#
deleteDelivery( integer $invoice_delivery_id )
Removes the invoice delivery record
Removes the invoice delivery record
Parameters
- $invoice_delivery_id
integer $invoice_delivery_id The ID of the delivery item to delete
|
public
|
#
deleteRecurringDelivery( integer $invoice_delivery_id )
Removes the recurring invoice delivery record
Removes the recurring invoice delivery record
Parameters
- $invoice_delivery_id
integer $invoice_delivery_id The ID of the recurring delivery item to delete
|
public
array
|
#
calcLineTotals( integer $client_id, array $vars, array $tax_rules = null, integer $client_group_id = null )
Calculate the subtotal, tax, and total of a set of line items
Calculate the subtotal, tax, and total of a set of line items
Parameters
- $client_id
integer $client_id The ID of the client to calculate the line totals for
- $vars
array $vars An array of invoice info including: - lines A numerically indexed array of
line items including: - qty The quantity of each line item - amount The unit
cost per quantity - tax Whether or not this line items is taxable - currency The
currency to use (optional, defaults to the client's default currency)
- $tax_rules
array A numerically indexed array of stdClass objects each representing a tax rule to
apply to this client or client group. Must be provided if $client_id not
specified
- $client_group_id
integer $client_group_id The ID of the client group to calculate line totals for
Returns
array An array containing the following keys, void on error: - subtotal - total -
total_w_tax - tax - total_due Optionally set if $vars['amount_paid'] given and
> 0
|
public
float
|
#
amountDue( integer $client_id, string $currency, string $status = "open" )
Calculates the client's amount due in the given currency. This sums all
existing open invoices for the given currency.
Calculates the client's amount due in the given currency. This sums all
existing open invoices for the given currency.
Parameters
- $client_id
integer $client_id The client ID to calculate on
- $currency
string $currency The ISO 4217 3-character currency code
- $status
string $status The status type of the invoices whose amount due to fetch (optional,
default 'open') one of the following: - open Fetches all active open invoices -
closed Fetches all closed invoices - past_due Fetches all active past due
invoices - draft Fetches all invoices with a status of "draft" - void Fetches
all invoices with a status of "void" - active Fetches all invoices with a status
of "active" - proforma Fetches all invoices with a status of "proforma" -
to_autodebit Fetches all invoices that are ready to be autodebited now, and
which can be with an active client and payment account to do so -
pending_autodebit Fetches all invoice that are set to be autodebited in the
future, and which have an active client and payment account to do so with -
to_print Fetches all paper invoices set to be printed - printed Fetches all
paper invoices that have been set as printed - pending Fetches all active
invoices that have not been billed for yet - to_deliver Fetches all invoices set
to be delivered by a method other than paper (i.e. deliverable invoices not in
the list of those "to_print") - all Fetches all invoices
Returns
float The amount due
|
public
array
|
#
invoicedCurrencies( integer $client_id, string $status = "active" )
Returns an array of all currency the given client has been invoiced in
Returns an array of all currency the given client has been invoiced in
Parameters
- $client_id
integer $client_id
- $status
string $status The status type of the invoices to fetch (optional, default 'active') -
['open','closed','past_due','draft','proforma','void','active'] (or 'all' for
all active/draft/proforma/void)
Returns
array An array of stdClass objects, each representing a currency in use
|
public
float
|
#
getSubtotal( integer $invoice_id )
Calculates the subtotal of the given invoice ID
Calculates the subtotal of the given invoice ID
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to calculate the subtotal of
Returns
float The subtotal of the invoice
|
public
float
|
#
getTotal( integer $invoice_id )
Calculates the total (subtotal + tax) of the given invoice ID
Calculates the total (subtotal + tax) of the given invoice ID
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to calculate the total of
Returns
float The total of the invoice
|
public
array
|
#
makeLinesFromItems( array $vars )
Creates a list of line items from the given set of items, discounts, and
taxes
Creates a list of line items from the given set of items, discounts, and
taxes
Parameters
- $vars
array $vars A key/value array, including: - items An array of stdClass items from
which to create the line items, each including: - description The line item
description to set - price The unit price of the line item - qty The line
quantity - discounts An array of stdClass discounts applied to the line,
including: - description The coupon description - amount The amount of discount
- type The type of discount - total The total amount discounted from the line -
taxes An array of stdClass taxes applied to the line, including: - description
The tax description - amount The amount of tax - type The type of tax - total
The total amount taxed from the line
Returns
array An array of line items, each including: - service_id The ID of the service to
which the line belongs - description The line description - qty The line
quantity - amount The unit price - order The line item order relative to other
line items - tax True or false, whether the item is taxable
See
|
public
array
|
#
getItemTotals( array $items, array $discounts = array(), array $taxes = array() )
Retrieves a list of items and their totals
Retrieves a list of items and their totals
Parameters
- $items
array $items An array of items including: - price The unit price of the item - qty The
item quantity (optional, default 1) - description The item description
(optional)
- $discounts
array $discounts An array of applicable discounts including (optional): - amount The
discount amount - type The discount type ('amount' or 'percent') - description
The discount description (optional) - apply An array of item indexes to which
the discount applies (optional, defaults to all)
- $taxes
array $taxes An array containing arrays of applicable taxes where each array group
represents taxes to cascade on each other; including (optional): - amount The
tax amount - type The tax type ('exclusive' or 'inclusive') - description The
tax description (optional) - apply An array of item indexes to which the tax
applies (optional, defaults to all)
Returns
array An array containing: - items An array of items and pricing information about
each item - totals An array of pricing information about all items - discounts
An array of discounts - taxes An array of taxes
|
public
float
|
#
getPaid( integer $invoice_id )
Calculates the total paid on the given invoice ID
Calculates the total paid on the given invoice ID
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to calculate the total paid on
Returns
float The total paid on the invoice
|
public
array
|
#
getStatuses( )
Retrieves a list of invoice statuses and language
Retrieves a list of invoice statuses and language
Returns
array A key/value array of statuses and their language
|
public
array
|
#
getTypes( )
Fetches the available invoice types
Fetches the available invoice types
Returns
array A key/value array of invoice types
|
public
boolean
|
#
validateStatus( string $status )
Validates the invoice 'status' field
Validates the invoice 'status' field
Parameters
- $status
string $status The status to check
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateIsDraft( integer $invoice_id )
Validates that the given invoice is a draft invoice
Validates that the given invoice is a draft invoice
Parameters
- $invoice_id
integer $invoice_id The invoice ID
Returns
boolean True if the given invoice is a draft, and false otherwise
|
public
boolean
|
#
validateDeliveryMethods( array $methods = null )
Validates that the delivery options match the available set
Validates that the delivery options match the available set
Parameters
- $methods
array $methods A key=>value array of delivery methods (e.g. "email"=>true)
Returns
boolean True if at least one delivery method was given, false otherwise
|
public
boolean
|
#
validateAmountApplied( integer $invoice_id )
Checks if the given invoice has any payments applied to it
Checks if the given invoice has any payments applied to it
Parameters
- $invoice_id
integer $invoice_id The invoice ID to check
Returns
boolean True if the invoice has payments applied to it, false otherwise
|
public
boolean
|
#
validateDateDueAfterDateBilled( string $date_due, string $date_billed )
Validates that the given date due is on or after the date billed
Validates that the given date due is on or after the date billed
Parameters
- $date_due
string $date_due The date the invoice is due
- $date_billed
string $date_billed The date the invoice is billed
Returns
boolean True if the date due is on or after the date billed, false otherwise
|
public
boolean
|
#
validateDuration( mixed $duration )
Validates the recurring invoice duration
Validates the recurring invoice duration
Parameters
- $duration
mixed $duration An integer idenfying the number of the times the recurring invoice
should recur, null for indefinitely
Returns
boolean True if the duration is valid, false otherwise
|
public
boolean
|
#
validatePeriod( string $period )
Validates the recurring invoice period
Validates the recurring invoice period
Parameters
- $period
string $period The period type
Returns
boolean True if validated, false otherwise
|
public
|
#
isInstanceOf( mixed $field, mixed $class )
Checks if the given $field is a reference of $class
Checks if the given $field is a reference of $class
|
public
float
|
#
primeQuantity( mixed $qty )
Converts quantity to a float, if no qty is set, a value of 1 is assumed.
Converts quantity to a float, if no qty is set, a value of 1 is assumed.
Parameters
- $qty
mixed $qty The quantity to be primed, may be an integer, float, or fractional string
Returns
float The quanity rounded to 4 decimal places
|
public
array
|
#
getTaxRules( integer $client_id )
Retrieves all active tax rules that apply to the given client
Retrieves all active tax rules that apply to the given client
Parameters
- $client_id
integer $client_id The client ID
Returns
array A numerically indexed array of stdClass objects each representing a tax rule to
apply to this client
|
public
array
|
#
getTaxRulesByLocation( integer $company_id, string $country, string $state )
Retrieves all active tax rules that apply to the given company and
location
Retrieves all active tax rules that apply to the given company and
location
Parameters
- $company_id
integer $company_id The ID of the company to fetch tax rules on
- $country
string $country The ISO 3166-1 alpha2 country code to fetch tax rules on
- $state
string $state 3166-2 alpha-numeric subdivision code to fetch tax rules on
Returns
array A numerically indexed array of stdClass objects each representing a tax rule to
apply to this company and location
|
public
string
|
#
createPayHash( integer $client_id, integer $invoice_id )
Creates a Payment Hash that may be used to temporarily authenticate a user's
access to pay an invoice, or invoices
Creates a Payment Hash that may be used to temporarily authenticate a user's
access to pay an invoice, or invoices
Parameters
- $client_id
integer $client_id The client ID to create the hash for
- $invoice_id
integer $invoice_id The ID of the invoice to create the hash for (if null will allow the
hash to work for any invoice belonging to the client)
Returns
string A hash built based upon the parameters provided
|
public
boolean
|
#
verifyPayHash( integer $client_id, integer $invoice_id, string $hash )
Verifies the Payment Hash is valid
Verifies the Payment Hash is valid
Parameters
- $client_id
integer $client_id The client ID to verify the hash for
- $invoice_id
integer $invoice_id The ID of the invoice to verify the hash for
- $hash
string $hash The original hash to verify against
Returns
boolean True if the hash is valid, false otherwise
|