PHP Interface yii2tech\balance\ManagerInterface

Since: 1.0
Author: Paul Klimov ([email protected])
Exibir arquivo Open project: yii2tech/balance

Public Methods

Method Description
calculateBalance ( array | mixed $account ) : integer | float Calculates current account balance summarizing all related transactions.
decrease ( array | mixed $account, integer | float $amount, array $data = [] ) : mixed Decreases account current balance ('credit' operation).
increase ( array | mixed $account, integer | float $amount, array $data = [] ) : mixed Increases account current balance ('debit' operation).
revert ( mixed $transactionId, array $data = [] ) : array | mixed Reverts specified transaction.
transfer ( array | mixed $from, array | mixed $to, integer | float $amount, array $data = [] ) : array Transfers amount from one account to the other one.

Method Details

calculateBalance() public method

Calculates current account balance summarizing all related transactions.
public calculateBalance ( array | mixed $account ) : integer | float
$account array | mixed account ID or filter condition.
return integer | float current balance.

decrease() public method

Decreases account current balance ('credit' operation).
public decrease ( array | mixed $account, integer | float $amount, array $data = [] ) : mixed
$account array | mixed account ID or filter condition.
$amount integer | float amount.
$data array extra data, which should be associated with the transaction.
return mixed transaction ID.

increase() public method

Increases account current balance ('debit' operation).
public increase ( array | mixed $account, integer | float $amount, array $data = [] ) : mixed
$account array | mixed account ID or filter condition.
$amount integer | float amount.
$data array extra data, which should be associated with the transaction
return mixed transaction ID.

revert() public method

This method does not deletes original transaction, but creates new one, which compensate it. If transaction has been created via ManagerInterface::transfer method, 2 transactions will be created affecting both accounts used at ManagerInterface::transfer.
public revert ( mixed $transactionId, array $data = [] ) : array | mixed
$transactionId mixed ID of the transaction to be reverted.
$data array extra transaction data
return array | mixed transaction ID or list of transaction IDs.

transfer() public method

Transfers amount from one account to the other one.
public transfer ( array | mixed $from, array | mixed $to, integer | float $amount, array $data = [] ) : array
$from array | mixed account ID or filter condition.
$to array | mixed account ID or filter condition.
$amount integer | float amount.
$data array extra data, which should be associated with the transaction.
return array list of created transaction IDs.