public
|
#
__construct( )
Initialize Transactions
Overrides
|
public
integer
|
#
add( array $vars )
Adds a transaction to the system
Adds a transaction to the system
Parameters
- $vars
array $vars An array of tax info including: - client_id The client ID this transaction
applies to. - amount The transaction amount - currency The currency code of this
transaction - type The transaction type (cc, ach, other) - transaction_type_id
The transaction type ID (optional, default NULL) - account_id The account ID
(optional, default NULL) - gateway_id The gateway ID (optional, default NULL) -
transaction_id The gateway supplied transaction ID (optional, default NULL) -
parent_transaction_id The gateway supplied parent transaction ID (optional,
default null) - reference_id The gateway supplied reference ID (optional,
default NULL) - status The transaction status (optional, default 'approved') -
date_added The date the transaction was received (optional, defaults to current
date)
Returns
integer The ID of the transaction created, void on error
|
public
integer
|
#
edit( integer $transaction_id, array $vars, integer $staff_id = null )
Updates a transaction
Parameters
- $transaction_id
integer $transaction_id The transaction ID
- $vars
array $vars An array of tax info including: - amount The transaction amount (optional)
- currency The currency code of this transaction (optional) - type The
transaction type (cc, ach, other) (optional) - transaction_type_id The
transaction type ID (optional, default NULL) - account_id The account ID
(optional, default NULL) - gateway_id The gateway ID (optional, default NULL) -
transaction_id The gateway supplied transaction ID (optional, default NULL) -
parent_transaction_id The gateway supplied parent transaction ID (optional,
default null) - reference_id The reference ID (optional, default NULL) - status
The transaction status (optional, default 'approved') - date_added The date the
transaction was received (optional, defaults to current date)
- $staff_id
integer $staff_id The ID of the staff member that made the edit for logging purposes
Returns
integer The ID of the transaction created, void on error
|
public
|
#
delete( integer $transaction_id )
Removes a transaction from the system. This method has not been implemented
and may never be implemented for proper accounting purposes. Nevertheless it is
defined for circulatiry.
Removes a transaction from the system. This method has not been implemented
and may never be implemented for proper accounting purposes. Nevertheless it is
defined for circulatiry.
Parameters
- $transaction_id
integer $transaction_id The transaction ID to remove
|
public
mixed
|
#
get( integer $transaction_id )
Retrieves a transaction and any applied amounts
Retrieves a transaction and any applied amounts
Parameters
- $transaction_id
integer $transaction_id The ID of the transaction to fetch (that is, transactions.id NOT
transactions.transaction_id)
Returns
mixed A stdClass object representing the transaction, false if it does not exist
See
|
public
mixed
|
#
getByTransactionId( integer $transaction_id, integer $client_id = null, integer $gateway_id = null )
Retrieves a transaction and any applied amounts
Retrieves a transaction and any applied amounts
Parameters
- $transaction_id
integer $transaction_id The ID of the transaction to fetch (that is,
transactions.transaction_id NOT transactions.id)
- $client_id
integer $client_id The ID of the client to fetch a transaction for
- $gateway_id
integer $gateway_id The ID of the gateway used to process the transaction
Returns
mixed A stdClass object representing the transaction, false if it does not exist
See
|
private
Record
|
#
getTransaction( )
Returns a partially built query Record object used to fetch a single
transaction
Returns a partially built query Record object used to fetch a single
transaction
Returns
Record
The Record object representing this partial query
|
public
array
|
#
getList( integer $client_id = null, string $status = "approved", integer $page = 1, array $order_by = array('date_added'=>"DESC") )
Retrieves a list of transactions and any applied amounts for the given
client
Retrieves a list of transactions and any applied amounts for the given
client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get transactions for all
clients)
- $status
string $status The status type of the transactions to fetch (optional, default
'approved') - 'approved', 'declined', 'void', 'error', 'pending', 'returned'
- $page
integer $page The page to return results for
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
array An array of stdClass objects representing transactions, or false if none exist
|
public
integer
|
#
getListCount( integer $client_id = null, string $status = "approved" )
Returns the total number of transactions for a client, useful in constructing
pagination for the getList() method.
Returns the total number of transactions for a client, useful in constructing
pagination for the getList() method.
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get transactions for all
clients)
- $status
string $status The status type of the transactions to fetch (optional, default
'approved') - 'approved', 'declined', 'void', 'error', 'pending', 'returned'
Returns
integer The total number of transactions
See
|
public
array
|
#
search( string $query, integer $page = 1 )
Search transactions
Parameters
- $query
string $query The value to search transactions for
- $page
integer $page The page number of results to fetch (optional, default 1)
Returns
array An array of transactions that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of transactions returned from Transactions::search(),
useful in constructing pagination
Return the total number of transactions returned from Transactions::search(),
useful in constructing pagination
Parameters
- $query
string $query The value to search transactions for
See
|
private
Record
|
#
searchTransactions( string $query )
Partially constructs the query for searching transactions
Partially constructs the query for searching transactions
Parameters
- $query
string $query The value to search transactions for
Returns
Record
The partially constructed query Record object
See
|
private
Record
|
#
getTransactions( integer $client_id = null, string $status = "approved" )
Partially constructs the query required by Transactions::getList() and
Transactions:getListCount()
Partially constructs the query required by Transactions::getList() and
Transactions:getListCount()
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get transactions for all
clients)
- $status
string $status The status type of the transactions to fetch (optional, default
'approved') - 'approved', 'declined', 'void', 'error', 'pending', 'refunded',
'returned' (or 'all' for all
approved/declined/void/error/pending/refunded/returned)
Returns
Record
The partially constructed query Record object
|
public
array
|
#
getApplied( integer $transaction_id = null, integer $invoice_id = null )
Returns all invoices that have been applied to this transaction. Must supply
either a transaction ID, invoice ID or both.
Returns all invoices that have been applied to this transaction. Must supply
either a transaction ID, invoice ID or both.
Parameters
- $transaction_id
integer $transaction_id The ID of the transaction to fetch
- $invoice_id
integer $invoice_id The ID of the invoice to filter applied amounts on
Returns
array An array of stdClass objects representing applied amounts to invoices
|
public
float
|
#
getCreditedAmount( integer $transaction_id )
Returns the amount of payment for the given transaction ID that is currently
available as a credit
Returns the amount of payment for the given transaction ID that is currently
available as a credit
Parameters
- $transaction_id
integer $transaction_id The ID of the transaction to fetch a credit value for
Returns
float The amount of the transaction that is currently available as a credit
|
public
array
|
#
getCredits( integer $client_id )
Returns the amount of payment for the given client ID that is currently
available as a credit for each currency
Returns the amount of payment for the given client ID that is currently
available as a credit for each currency
Parameters
- $client_id
integer $client_id The ID of the client to fetch a credit value for
Returns
array A list of credits by currency containing: - transaction_id The transaction ID
that the credit belongs to - credit The total credit for this transaction
|
public
integer
|
#
getStatusCount( integer $client_id = null, string $status = "approved" )
Retrieves the number of transactions given a transaction status type for the
given client
Retrieves the number of transactions given a transaction status type for the
given client
Parameters
- $client_id
integer $client_id The client ID (optional, default null to get transactions for all
clients)
- $status
string $status The transaction status type (optional, default 'approved')
Returns
integer The number of transactions of type $status for $client_id
|
public
|
#
apply( integer $transaction_id, array $vars )
Applies a transaction to a list of invoices
Applies a transaction to a list of invoices
Parameters
- $transaction_id
integer transaction_id The transaction ID
- $vars
array $vars An array of transaction info including: - date The date in local time
(Y-m-d H:i:s format) the transaction was applied (optional, default to current
date/time) - amounts A numerically indexed array of amounts to apply including:
- invoice_id The invoice ID - amount The amount to apply to this invoice
(optional, default 0.00) - date The date/time the transaction was applied
(optional, default to current date/time)
|
public
boolean
|
#
verifyApply( array & $vars, boolean $validate_trans_id = true, float $total = null )
Verifies that transaction can be applied to a list of invoices
Verifies that transaction can be applied to a list of invoices
Parameters
- $vars
array $vars An array of transaction info including: - transaction_id The transaction
ID (only evaluated if $validate_trans_id is true) - date The date in UTC time
(Y-m-d H:i:s format) the transaction was applied (optional, default to current
date/time) - amounts A numerically indexed array of amounts to apply including:
- invoice_id The invoice ID - amount The amount to apply to this invoice
(optional, default 0.00)
- $validate_trans_id
boolean $validate_trans_id True to validate the transaction ID in $vars, false otherwise
- $total
float $total The total amount of the transaction used to ensure that the sum of the
apply amounts does not exceed the total transaction amount
Returns
boolean True if the transaction can be applied, false otherwise (sets Input errors on
failure)
|
public
|
#
unApply( integer $transaction_id, array $invoices = null )
Unapplies a transactions from one or more invoices.
Unapplies a transactions from one or more invoices.
Parameters
- $transaction_id
integer $transaction_id The ID of the transaction to unapply
- $invoices
array $invoice A numerically indexed array of invoice IDs to unapply this transaction
from, or null to unapply this transaction from any and all invoices
|
public
mixed
|
#
getTypes( )
Retrieves a list of all transaction types
Retrieves a list of all transaction types
Returns
mixed An array of stdClass objects representing transaction types, or false if none
exist
|
public
mixed
|
#
getType( integer $type_id )
Retrieves a single payment type
Retrieves a single payment type
Parameters
- $type_id
integer $type_id The payment type ID
Returns
mixed An array of stdClass objects representing a payment type, or false if one does
not exist
|
public
array
|
#
transactionTypeNames( )
Retrieves all transaction types and their name in key=>value pairs
Retrieves all transaction types and their name in key=>value pairs
Returns
array An array of key=>value pairs representing transaction types and their names
|
public
array
|
#
transactionStatusNames( )
Retrieves all transaction status values and their name in key/value pairs
Retrieves all transaction status values and their name in key/value pairs
Returns
array An array of key/value pairs representing transaction status values
|
public
integer
|
#
addType( array $vars )
Adds a transaction type
Parameters
- $vars
array $vars An array of transaction types including: - name The transaction type name
- is_lang Whether or not the 'name' parameter is a language definition 1 - yes,
0 - no (optional, default 0)
Returns
integer The transaction type ID created, or void on error
|
public
|
#
editType( integer $type_id, array $vars )
Updates a transaction type
Updates a transaction type
Parameters
- $type_id
integer $type_id The type ID to update
- $vars
array $vars An array of transaction types including: - name The transaction type name
- is_lang Whether or not the 'name' parameter is a language definition 1 - yes,
0 - no (optional, default 0)
|
public
|
#
deleteType( integer $type_id )
Delete a transaction type and update all affected transactions, setting their
type to null
Delete a transaction type and update all affected transactions, setting their
type to null
Parameters
- $type_id
integer $type_id The ID for this transaction type
|
public
boolean
|
#
validateType( string $type )
Validates a transaction's 'type' field
Validates a transaction's 'type' field
Parameters
- $type
string $type The type to check
Returns
boolean True if the type is validated, false otherwise
|
public
boolean
|
#
validateStatus( string $status )
Validates a transaction's 'status' field
Validates a transaction's 'status' field
Parameters
- $status
string $status The status to check
Returns
boolean True if the status is validated, false otherwise
|
public
boolean
|
#
validateApplyAmounts( array $amounts, float $total = null )
Validates whether the given amounts can be applied to the given invoices, or
if the amounts would exceed the amount due on the invoices. Also ensures the
invoices can have amounts applied to them.
Validates whether the given amounts can be applied to the given invoices, or
if the amounts would exceed the amount due on the invoices. Also ensures the
invoices can have amounts applied to them.
Parameters
- $amounts
array $amounts An array of apply amounts including: - invoice_id The invoice ID -
amount The amount to apply to this invoice (optional, default 0.00)
- $total
float $total The total amount of the transaction used to ensure that the sum of the
apply amounts does not exceed the total transaction amount
Returns
boolean True if the amounts given can can be applied to the invoices given, false if it
exceeds the amount due or the invoice can not receive payments
|
public
boolean
|
#
validatePositiveAmounts( array $amounts )
Validates whether each of the given amounts is greater than or equal to
zero
Validates whether each of the given amounts is greater than or equal to
zero
Parameters
- $amounts
array $amounts An array of apply amounts including: - invoice_id The invoice ID -
amount The amount to apply to this invoice (optional, default 0.00)
Returns
boolean True if all amounts are greater than or equal to zero, false otherwise
|
private
array
|
#
getTransactionRules( )
Returns the rule set for adding/editing transactions
Returns the rule set for adding/editing transactions
Returns
array Transaction rules
|
private
array
|
#
getTypeRules( )
Returns the rule set for adding/editing transaction types
Returns the rule set for adding/editing transaction types
Returns
array Transaction type rules
|