|
@@ 47-67 (lines=21) @@
|
| 44 |
|
* @return Wallet |
| 45 |
|
* @throws Exception |
| 46 |
|
*/ |
| 47 |
|
public function incrementBalance($transaction) |
| 48 |
|
{ |
| 49 |
|
if (is_numeric($transaction)) { |
| 50 |
|
$amount = $this->convertToWalletTypeInteger($transaction); |
| 51 |
|
$this->increment('raw_balance', $amount); |
| 52 |
|
$this->createWalletLedgerEntry($amount, $this->raw_balance); |
| 53 |
|
|
| 54 |
|
return $this; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
if (! $transaction instanceof WalletTransaction) { |
| 58 |
|
throw new Exception('Increment balance expects parameter to be a float or a WalletTransaction object.'); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
$this->increment('raw_balance', $transaction->getAmount()); |
| 62 |
|
|
| 63 |
|
// Record in ledger |
| 64 |
|
$this->createWalletLedgerEntry($transaction, $this->raw_balance); |
| 65 |
|
|
| 66 |
|
return $this; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
/** |
| 70 |
|
* @param $transaction WalletTransaction|integer|float|double |
|
@@ 74-94 (lines=21) @@
|
| 71 |
|
* @return Wallet |
| 72 |
|
* @throws Exception |
| 73 |
|
*/ |
| 74 |
|
public function decrementBalance($transaction) |
| 75 |
|
{ |
| 76 |
|
if (is_numeric($transaction)) { |
| 77 |
|
$amount = $this->convertToWalletTypeInteger($transaction); |
| 78 |
|
$this->decrement('raw_balance', $amount); |
| 79 |
|
$this->createWalletLedgerEntry($amount, $this->raw_balance, 'decrement'); |
| 80 |
|
|
| 81 |
|
return $this; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
if (! $transaction instanceof WalletTransaction) { |
| 85 |
|
throw new Exception('Decrement balance expects parameter to be a number or a WalletTransaction object.'); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
$this->decrement('raw_balance', $transaction->getAmount()); |
| 89 |
|
|
| 90 |
|
// Record in ledger |
| 91 |
|
$this->createWalletLedgerEntry($transaction, $this->raw_balance, 'decrement'); |
| 92 |
|
|
| 93 |
|
return $this; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
/** |
| 97 |
|
* @param $transaction |