2017 © Pedro Peláez
 

library ledger

ledger implementation for laravel

image

fannypack/ledger

ledger implementation for laravel

  • Monday, October 30, 2017
  • by mpaannddreew
  • Repository
  • 3 Watchers
  • 7 Stars
  • 73 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 52 % Grown

The README.md

About this library

This is a simple/basic implementation of a ledger in laravel 5, (*1)

Actions supported

  • RECORDING DEBITS
  • RECORDING CREDITS
  • BALANCE COMPUTATION

Installation

git clone https://github.com/mpaannddreew/laravel-ledger.git, (*2)

Register service provider, (*3)

FannyPack\Ledger\LedgerServiceProvider::class,

Register Facade Register service provider, (*4)

'Ledger' => FannyPack\Ledger\Facades\Ledger::class,

After the service provider is registered run this command, (*5)

php artisan vendor:publish --tag=ledger

Run migrations, (*6)

php artisan migrate

This command will copy the library's vue components into your codebase, (*7)

Register package routes in your app's RouteServiceProvider, (*8)

Ledger::routes();

Usage

Using it with your models, add, (*9)

namespace App;

use FannyPack\Ledger\Traits\Ledgerable;
use Illuminate\Database\Eloquent\Model;

class Account extends Model
{
    use Ledgerable;
}

Show available balance, (*10)

$account = Account::find(1);
$balance = Ledger::balance($account);

or, (*11)

$account = Account::find(1);
$balance = $account->balance();

Record a credit entry, (*12)

$account = Account::find(1);
Ledger::credit($account, $to, $amount, $reason);

or, (*13)

$account = Account::find(1);
$account->credit($to, $amount, $reason);

Record a debit entry, (*14)

$account = Account::find(1);
Ledger::debit($account, $from, $amount, $reason);

or, (*15)

$account = Account::find(1);
$account->debit($from, $amount, $reason);

Recording debits and credits in one transaction, (*16)

$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, (*17)

$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, (*18)

$account = Account::find(1);
$entries = $account->entries();

Retrieving all debits of a ledgerable, (*19)

$account = Account::find(1);
debits = $account->debits();

Retrieving all credits of a ledgerable, (*20)

$account = Account::find(1);
debits = $account->credits();

Using the provided Ledger.vue component in your blade templates, (*21)

<ledger></ledger>

Bugs

For any bugs found, please email me at andrewmvp007@gmail.com or register an issue at issues, (*22)

The Versions

30/10 2017

dev-master

9999999-dev

ledger implementation for laravel

  Sources   Download

MIT

The Requires

 

by Mpande Andrew

laravel php library ledger

30/10 2017

dev-dev-master

dev-dev-master

ledger implementation for laravel

  Sources   Download

MIT

The Requires

 

by Mpande Andrew

laravel php library ledger

12/09 2017

v1.0

1.0.0.0

ledger implementation for laravel

  Sources   Download

MIT

The Requires

 

by Mpande Andrew

laravel php library ledger