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', or 'void' - 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: -
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
|
private
|
#
setMeta( integer $invoice_id, string $key, mixed $value )
Sets meta data for the given invoice
Sets meta data for the given invoice
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to set meta data for
- $key
string $key The key of the invoice meta data
- $value
mixed $value The value to store for this meta field
|
private
|
#
unsetMeta( integer $invoice_id, string $key = null )
Deletes any meta on the given invoice ID
Deletes any meta on the given invoice ID
Parameters
- $invoice_id
integer $invoice_id The invoice ID to unset meta data for
- $key
string $key The key to unset, null will unset all keys
|
private
mixed
|
#
getMeta( integer $invoice_id, string $key = null )
Fetches the meta fields for this invoice.
Fetches the meta fields for this invoice.
Parameters
- $invoice_id
integer $invoice_id The invoice ID to fetch meta data for
- $key
string $key The key to fetch if fetching only a single meta field, null to fetch all
meta fields
Returns
mixed An array of stdClass objects if fetching all meta data, a stdClass object if
fetching a specific meta field, boolean false if fetching a specific meta field
that does not exist
|
private
integer
|
#
addLine( integer $invoice_id, array $vars )
Adds a line item to an existing invoice
Adds a line item to an existing invoice
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to add a line item to
- $vars
array $vars A list of line item vars including: - service_id The service ID attached
to this line item - 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 - order The order number of the
line item (optional, default is the last)
Returns
integer The ID of the line item created
|
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 (required) - 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', or 'void' - currency
The currency this invoice is created in (required) - 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
|
private
|
#
deleteLine( integer $line_id )
Permanently removes an invoice line item and its corresponding line item
taxes
Permanently removes an invoice line item and its corresponding line item
taxes
Parameters
- $line_id
integer $line_id The line item ID
|
private
|
#
deleteRecurringLine( integer $line_id )
Permanently removes a recurring invoice line item
Permanently removes a recurring invoice line item
Parameters
- $line_id
integer $line_id The line item ID
|
private
|
#
addLineTax( integer $line_id, integer $tax_id, boolean $cascade = false )
Adds a new line item tax
Parameters
- $line_id
integer $line_id The line item ID
- $tax_id
integer $tax_id The tax ID
- $cascade
boolean $cascade Whether or not this tax rule should cascade over other rules
|
private
|
#
deleteLineTax( integer $line_id )
Permanently removes an invoice line item's tax rule
Permanently removes an invoice line item's tax rule
Parameters
- $line_id
integer $line_id The line item ID
|
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
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
|
private
array
|
#
getLineTaxes( integer $invoice_line_id )
Fetches all tax info attached to the line item
Fetches all tax info attached to the line item
Parameters
- $invoice_line_id
integer $invoice_line_id The ID of the invoice line item to fetch tax info for
Returns
array An array of stdClass objects each representing a tax rule
See
|
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" - 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" - 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" - 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
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
|
private
Record
|
#
searchInvoices( string $query )
Partially constructs the query for searching invoices
Partially constructs the query for searching invoices
Parameters
- $query
string $query The value to search invoices for
Returns
Record
The partially constructed query Record object
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
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
|
private
Record
|
#
getInvoice( integer $invoice_id )
Partially constructs the query required by Invoices::get() and others
Partially constructs the query required by Invoices::get() and others
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to fetch
Returns
Record
The partially constructed query Record object
|
private
Record
|
#
getInvoices( integer $client_id = null, string $status = "open", array $options = array() )
Partially constructs the query required by Invoices::getList() and
Invoices::getListCount()
Partially constructs the query required by Invoices::getList() and
Invoices::getListCount()
Parameters
- $client_id
integer $client_id The client ID (optional, default null to fetch 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" - 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
- $options
array $options A list of additional options - autodebit_date The autodebit date to
fetch invoices; for use with the "to_autodebit" or "pending_autodebit" statuses
Returns
Record
The partially constructed query Record object
|
private
Record
|
#
getRecurringInvoice( integer $invoice_recur_id )
Partially constructs the query required by Invoices::getRecurring() and
others
Partially constructs the query required by Invoices::getRecurring() and
others
Parameters
- $invoice_recur_id
integer $invoice_recur_id The recurring invoice ID to fetch
Returns
Record
The partially constructed query Record object
|
private
Record
|
#
getRecurringInvoices( integer $client_id = null, boolean $group = true )
Partially constructs the query required by both Invoices::getRecurringList()
and Invoices::getRecurringListCount()
Partially constructs the query required by both Invoices::getRecurringList()
and Invoices::getRecurringListCount()
Parameters
- $client_id
integer $client_id The client ID
- $group
boolean $group True to group the query as required, false to not group at all (grouping
should still be done)
Returns
Record
The partially constructed query Record object
|
private
float
|
#
getPreviousDue( integer $client_id, string $currency )
Retrieves the previous due amount for the given client in the given
currency
Retrieves the previous due amount for the given client in the given
currency
Parameters
- $client_id
integer $client_id The client ID
- $currency
string $currency The ISO 4217 3-character currency code
Returns
float The previous amount due for this client
|
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" - 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
|
private
array
|
#
getNextInvoiceVars( array $vars, array $client_settings )
Updates $vars with the subqueries to properly set the previous_due,
id_format, and id_value fields when creating an invoice or converting a draft to
an active invoice
Updates $vars with the subqueries to properly set the previous_due,
id_format, and id_value fields when creating an invoice or converting a draft to
an active invoice
Parameters
- $vars
array $vars An array of invoice data from Invoices::add() or Invoices::edit()
- $client_settings
array $client_settings An array of client settings
Returns
array An array of invoice data now including the proper subqueries for setting the
previous_due, id_format and id_value fields
|
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 )
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)
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
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 )
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
|
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 )
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)
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
The
|
#
amountDue( integer $client_id, string $currency )
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
Returns
The amount due (float)
|
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','void','active'] (or 'all' for all
active/draft/void)
Returns
array An array of stdClass objects, each representing a currency in use
|
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
|
private
array
|
#
getRules( array $vars )
Returns the rule set for adding/editing invoices
Returns the rule set for adding/editing invoices
Parameters
- $vars
array $vars The input vars
Returns
array Invoice rules
|
private
array
|
#
getRecurringRules( array $vars )
Returns the rule set for adding/editing recurring invoices
Returns the rule set for adding/editing recurring invoices
Parameters
- $vars
array $vars The input vars
Returns
array Invoice rules
|
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 and ensures it is greater than 0, if no qty is
set or if quanity is less than or equal to 0, quanity will be set at 1
Converts quantity to a float and ensures it is greater than 0, if no qty is
set or if quanity is less than or equal to 0, quanity will be set at 1
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 tax ID's that apply to this client
|
private
boolean
|
#
taxUpdateRequired( integer $invoice_id, array $lines, array $delete_items )
Identifies whether or not the given invoice with its updated line items and
deleted items requires tax rules to be updated when saved. This method doesn't
check whether the tax rules have been updated, just whether the invoice has been
changed such that the updated tax rules would need to be updated. There's no
consequence in updating tax when the tax rules have not changed.
Identifies whether or not the given invoice with its updated line items and
deleted items requires tax rules to be updated when saved. This method doesn't
check whether the tax rules have been updated, just whether the invoice has been
changed such that the updated tax rules would need to be updated. There's no
consequence in updating tax when the tax rules have not changed.
Parameters
- $invoice_id
integer $invoice_id The ID of the invoice to evaluate
- $lines
array $lines An array of line items including: - id The ID of the line item (if
available) - tax Whether or not the line items is taxable (true/false) - amount
The amount per quantity for the line item - qty The quantity of the line item
- $delete_items
array $delete_items An array of items to be deleted from the invoice
Returns
boolean True if the invoice has been modified in such a way to warrant updating the tax
rules applied, false otherwise
See
|
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
|