2017 © Pedro Pelรกez
 

library luca-accounts

Double Entry Transaction for PHP

image

s-mcdonald/luca-accounts

Double Entry Transaction for PHP

  • Saturday, November 11, 2017
  • by S-McDonald
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Luca // Accounting

Source Source, (*1)

Luca Accounting is a Double Entry Accounting system that can easily be implemented into your application. It validates and sorts transactions prior to committing them to your Database., (*2)


// Create a Transaction $txn = new Transaction( $date , 'Capital Contribution', [ new TransactionLine($cash_account_1, 100.00, 00.00), new TransactionLine($eqty_account_2, 00.00, 100.00), ] ); // Process the Transaction $system->transact($txn);

Documentation

, (*3)

Features

1) Follows Double Entry based accounting rules. 2) Built-in validation of transactions. 3) Sorts transaction (Dr|Cr) entries automatically prior to committing to the db. 4) Separate Debit and Credit entries., (*4)

, (*5)

Installation

Via Composer. Run the following command from your project's root., (*6)

composer require s-mcdonald/luca-accounts

, (*7)

Dependencies

  • Php 8.1

, (*8)

Quick-Start

1) Extend the abstract AccountSystem class and then Implement the AccountInterface to your Account model or entity., (*9)

      // Your\App\AccountSystem.php
      class AccountSystem extends \SamMcDonald\LucaAccounts\AbstractAccountSystem {
        ...
      }

      // Your\App\Account.php
      class Account implements \SamMcDonald\LucaAccounts\Contracts\AccountInterface {
        ...
      }

Example

<?php 

namespace Your\App;

use Your\App\AccountSystem;
use SamMcDonald\LucaAccounts\Components\Transaction;
use SamMcDonald\LucaAccounts\Components\TransactionLine;

class YourAccountingProgram
{
    public static function simpleTransaction() 
    {
        // Get a new instance of the Accounting System
        $system = new AccountSystem();

        // Register the transact function
        $system->register('transact', static function(Transaction $txn) {
             // Your logic to commit the transaction to DB
        });

        /*
         * Load the accounts you want to use in the Transaction.
         * This will most likely be a Model or Entity object.
         */
        $acc1 = Account::fetch('cash-account'); 
        $acc2 = Account::fetch('acc-rec-account'); 
        $acc3 = Account::fetch('inventory-account'); 

        /*
         * Make a purchase of stock request
         */
        $txn = new Transaction( new DateTimeImmutable('now') , 'Purchase of inventory', 
            [
                new TransactionLine($acc1, 000.00,  50.00),
                new TransactionLine($acc2, 000.00, 150.00),
                new TransactionLine($acc3, 200.00,   0.00),                 
            ]
        );

        /*
         * Perform the transaction
         */
        $system->transact($txn);
    } 
}

, (*10)

Files

s-mcdonald/luca-accounts/
            โ”‚    
            โ”” src/
              โ”‚    
              โ”œโ”€โ”€ Components/
              โ”‚   โ”‚
              โ”‚   โ”œโ”€โ”€ Transaction.php
              โ”‚   โ”‚            
              โ”‚   โ””โ”€โ”€ TransactionLine.php
              โ”‚            
              โ”‚            
              โ”œโ”€โ”€ Contracts/
              โ”‚   โ”‚
              โ”‚   โ”œโ”€โ”€ AccountInterface.php
              โ”‚   โ”‚            
              โ”‚   โ”œโ”€โ”€ TransactionInterface.php
              โ”‚   โ”‚
              โ”‚   โ””โ”€โ”€ TransactionLineInterface.php
              โ”‚            
              โ”‚  
              โ”œโ”€โ”€ Exceptions/
              โ”‚   โ”‚
              โ”‚   โ””โ”€โ”€ DoubleEntryException.php
              โ”‚   โ”‚
              โ”‚   โ””โ”€โ”€ InvalidTransactionLineEntryException.php
              โ”‚
              โ”‚
              โ”œโ”€โ”€ Enums/
              โ”‚   โ”‚
              โ”‚   โ””โ”€โ”€ AccountType.php 
              โ”‚    
              โ”œโ”€โ”€ Util/
              โ”‚   โ”‚
              โ”‚   โ””โ”€โ”€ EntryFormatter.php
              โ”‚
              โ”‚
              โ””โ”€โ”€ AbstractAccountSystem.php

License

Luca-Accounts is licensed under the terms of the MIT License (See LICENSE file for details)., (*11)

Name of Luca

Luca-Accounting was named after Luca Pacioli (The father of Accounting). He popularized the DoubleEntry book-keeping system., (*12)

The Versions

11/11 2017

dev-master

9999999-dev https://github.com/s-mcdonald/LucaAccounts

Double Entry Transaction for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

validator accounting accounts double entry sam mcdonald

11/11 2017

1.0.0

1.0.0.0 https://github.com/s-mcdonald/LucaAccounts

Double Entry Transaction for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

validator accounting accounts double entry sam mcdonald

11/11 2017

dev-develop

dev-develop https://github.com/s-mcdonald/LucaAccounts

Double Entry Transaction for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

validator accounting accounts double entry sam mcdonald