Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Accounts
  • ApiKeys
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • ModuleClientMeta
  • ModuleManager
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • Taxes
  • Themes
  • Transactions
  • Users

Class Transactions

Transaction management

Model
Extended by AppModel
Extended by Transactions
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/transactions.php

Methods summary

public
# __construct( )

Initialize Transactions

Initialize Transactions

Overrides

AppModel::__construct
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

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

Transactions::getByTransactionId()
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

Transactions::get()
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

Services::getList()
public array
# search( string $query, integer $page = 1 )

Search transactions

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

Transactions::search()
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, string $currency = null )

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
$currency
string
$currency The ISO 4217 3-character currency code (optional)

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 float
# getTotalCredit( integer $client_id, string $currency )

Retrieves the total credit amount available to the client in the given currency

Retrieves the total credit amount available to the client in the given currency

Parameters

$client_id
integer
$client_id The ID of the client to fetch a credit value for
$currency
string
$currency The ISO 4217 3-character currency code

Returns

float
The total credit available to the client in the given currency
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. Each invoice must be in the transaction's currency to be applied

Applies a transaction to a list of invoices. Each invoice must be in the transaction's currency to be applied

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)
public mixed
# applyFromCredits( integer $client_id, string $currency = null, array $amounts = array() )

Applies available client credits in the given currency to all open invoices, starting from the oldest. If specific amounts are specified, credits will only be applied to the invoices given.

Applies available client credits in the given currency to all open invoices, starting from the oldest. If specific amounts are specified, credits will only be applied to the invoices given.

Parameters

$client_id
integer
$client_id The ID of the client whose invoices to apply from credits
$currency
string
$currency The ISO 4217 3-character currency code. Must be set if $amounts are specified (optional, null will apply from all currencies; default null)
$amounts
array
$amounts A numerically-indexed array of specific amounts to apply to given invoices: - invoice_id The invoice ID - amount The amount to apply to this invoice (optional, default 0.00)

Returns

mixed
Void, or an array indexed by a credit's transaction ID, containing the amounts that were actually applied, including: - invoice_id The invoice ID - amount The amount that was applied to this invoice
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. Only used if $validate_trans_id is false (optional)

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
# getDebitTypes( )

Retrieves a set of key/value pairs representing transaction debit types and language

Retrieves a set of key/value pairs representing transaction debit types and language

Returns

array
An array of key/value pairs representing transaction debit types and their names
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

Adds a transaction type

Parameters

$vars
array
$vars An array of transaction types including: - name The transaction type name - type The transaction debit type ('debit' or 'credit') - 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 - type The transaction debit type ('debit' or 'credit') - 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
# validateCurrencyAmounts( integer $transaction_id, array $amounts )

Validates whether the invoice amounts being applied are in the transaction's currency

Validates whether the invoice amounts being applied are in the transaction's currency

Parameters

$transaction_id
integer
$transaction_id The ID of the transaction
$amounts
array
$amounts An array of apply amounts including: - invoice_id The invoice ID - amount The amount to apply to this invoice (optional)

Returns

boolean
True if each invoice is in the transaction's currency, or false otherwise
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

Methods inherited from AppModel

_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()

Methods inherited from Model

affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

Properties inherited from AppModel

$replacement_keys

Blesta API documentation generated by ApiGen 2.8.0