fannypack / ledger
ledger implementation for laravel
Installs: 286
Dependents: 0
Suggesters: 0
Security: 0
Stars: 29
Watchers: 10
Forks: 13
Open Issues: 2
Requires
- illuminate/database: ~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0
- illuminate/routing: ~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0
- illuminate/support: ~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0
- illuminate/validation: ~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0
- nesbot/carbon: ^1.26.3 || ^2.0
This package is auto-updated.
Last update: 2024-12-05 21:00:19 UTC
README
This is a simple/basic implementation of a ledger in laravel 5
Actions supported
- RECORDING DEBITS
- RECORDING CREDITS
- BALANCE COMPUTATION
Installation
git clone https://github.com/mpaannddreew/laravel-ledger.git
Register service provider
FannyPack\Ledger\LedgerServiceProvider::class,
Register Facade Register service provider
'Ledger' => FannyPack\Ledger\Facades\Ledger::class,
After the service provider is registered run this command
php artisan vendor:publish --tag=ledger
Run migrations
php artisan migrate
This command will copy the library's vue components into your codebase
Register package routes in your app's RouteServiceProvider
Ledger::routes();
Usage
Using it with your models, add
namespace App; use FannyPack\Ledger\Traits\Ledgerable; use Illuminate\Database\Eloquent\Model; class Account extends Model { use Ledgerable; }
Show available balance
$account = Account::find(1); $balance = Ledger::balance($account);
or
$account = Account::find(1); $balance = $account->balance();
Record a credit entry
$account = Account::find(1); Ledger::credit($account, $to, $amount, $reason);
or
$account = Account::find(1); $account->credit($to, $amount, $reason);
Record a debit entry
$account = Account::find(1); Ledger::debit($account, $from, $amount, $reason);
or
$account = Account::find(1); $account->debit($from, $amount, $reason);
Recording debits and credits in one transaction
$account = Account::find(1); $account2 = Account::find(2); $account3 = Account::find(3); Ledger::transfer($account, [$account2, $account3], $amount, $reason); // or Ledger::transfer($account, $account2, $amount, $reason); Ledger::transfer($account, $account3, $amount, $reason);
or
$account = Account::find(1); $account2 = Account::find(2); $account3 = Account::find(3); $account->transfer([$account2, $account3], $amount, $reason); // or $account->transfer($account2, $amount, $reason); $account->transfer($account3, $amount, $reason);
Retrieving all entries of a ledgerable
$account = Account::find(1); $entries = $account->entries();
Retrieving all debits of a ledgerable
$account = Account::find(1); debits = $account->debits();
Retrieving all credits of a ledgerable
$account = Account::find(1); debits = $account->credits();
Using the provided Ledger.vue component in your blade templates
<ledger></ledger>
Bugs
For any bugs found, please email me at andrewmvp007@gmail.com or register an issue at issues