百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

eloquent-ifrs

> 编程语言
开源

以符合国际财务报告准则 (IFRS) 的报告为重点的精确双帐务会计

362 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

以符合国际财务报告准则 (IFRS) 的报告为重点的精确双帐务会计

Eloquent IFRS

This Package enables any Laravel application to generate International Financial Reporting Standards compatible Financial Statements by providing a fully featured and configurable Double Entry accounting subsystem.

The package supports multiple Entities (Companies), Account Categorization, Transaction assignment, Start of Year Opening Balances and accounting for VAT Transactions. Transactions are also protected against tampering via direct database changes ensuring the integrity of the Ledger. Outstanding amounts for clients and suppliers can also be displayed according to how long they have been outstanding using configurable time periods (Current, 31 - 60 days, 61 - 90 days etc). Finally, the package supports the automated posting of forex difference transactions both within the reporting period as well as translating foreign denominated account balances at a set closing rate.

This package is a community initiative of microbooks.io.

Table of contents

  • Eloquent IFRS
    • Table of contents
    • Installation
      • For production
      • For development
    • Configuration
    • Usage
      • DB Collision
      • Examples
    • Changelog
    • Getting Involved
    • Contributing
    • Roadmap
    • License
    • References

Installation

Use composer to Install the package into your laravel or lumen application. Eloquent IFRS requires PHP version 8.2 and Laravel (Eloquent) version 11 and above.

For production

php
composer require "ekmungai/eloquent-ifrs"

If using Lumen, make sure to register the package with your application by adding the IFRSServiceProvider to the app.php in the bootstrap folder.

php
register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(IFRSServiceProvider::class);
  ...
}
...
?>

Before running the migrations, make sure your application's users table already exists. Eloquent IFRS extends that table (adding entity_id and destroyed_at) and references it from ifrs_recycled_objects, but it never creates it: the migration fails with an explicit message if the table configured through ifrs.user_model is missing. In practice this means the users migration of your application must be dated before 2014_10_12_000000, which is the case for the migration shipped with Laravel. The package only creates its own prefixed table when ifrs.user_model points at IFRS\User.

The primary key of your users table may be a big integer, an integer, a uuid or any other string type, and it may carry a name other than id: the foreign key column is derived from the actual column definition.

Then run migrations to create the database tables.

php
php artisan migrate

For development

Clone this repo, and then run Composer in local repo root to pull in dependencies.

php
git clone [email protected]/ekmungai/eloquent-ifrs eloquent-ifrs
cd eloquent-ifrs
composer update

To run the tests:

php
cd eloquent-ifrs
vendor/bin/phpunit

Configuration

The package installs with the default settings as regards the names of Accounts/Transactions Types, Report Titles and Section names as well as Accounts Codes. To adjust these settings use the Laravel artisan publish command to install the ifrs configuration to your application's config folder where you can edit it.

php
php artisan vendor:publish

Usage

Full documentation for this package can be found here.

DB Collision

Publish configuration file with vendor:publish if your User model is different from App\User and update the namespace of your User model.

Open your User model and implement the below interfaces and also include the trait as well.

php

Examples

This simple example covers the four scenarios to demonstrate the use of the package. First, a description of a Cash Sale to a customer, then a Credit Sale (Invoice) to a client, then a Cash Purchase for an operations expense and finally a Credit Purchase (Bill) from a Supplier for a non operations purpose (Asset Purchase).

First we'll setup the Company (Reporting Entity) and required Accounts to record the Transactions. (Assuming that a registered User already exists):

php
use IFRS\Models\Entity;
use IFRS\Models\Currency;

$entity = Entity::create([
    "name" => "Example Company",
]);

//Entities require a reporting currency
$currency = Currency::create([
    "name" => "Euro",
    "currency_code" => "EUR"
]);

// Set the currency as the Entity's Reporting Currency 
$entity->currency_id = $currency->id;
$entity->save();

We also need the VAT Rates that apply to the Entity:

php
use IFRS\Models\Vat;

$outputVat = Vat::create([
    'name' => "Standard Output Vat",
    'code' => "O",
    'rate' => 20,
    'account_id' => Account::create([
        'name' => "Sales VAT Account",
        'account_type' => Account::CONTROL,
    ])
]);

$inputVat = Vat::create([
    'name' => "Standard Input Vat",
    'code' => "I",
    'rate' => 10,
    'account_id' =>  Account::create([
        'name' => "Input VAT Account",
        'account_type' => Account::CONTROL,
    ])
]);

Now we'll set up some Accounts:

…

Now we will create some Transactions in the Ledger, afterwards we will generate some reports. First though, it require a reporting period:

php
use IFRS\Models\ReportingPeriod;

$period = ReportingPeriod::create([
    'period_count' => 1,
    'calendar_year' => 2022,
]);

Now that all Accounts are prepared, we can create the first Transaction, a Cash Sale:

php
use IFRS\Transactions\CashSale;

$cashSale = CashSale::create([
    'account_id' => $bankAccount->id,
    'date' => Carbon::now(),
    'narration' => "Example Cash Sale",
]); // Intermediate save does not record the transaction in the Ledger

So far the Transaction has only one side of the double entry, so we create a Line Item for the other side:

php
use IFRS\models\LineItem;

$cashSaleLineItem = LineItem::create([
    'account_id' => $revenueAccount->id,
    'narration' => "Example Cash Sale Line Item",
    'quantity' => 1,
    'amount' => 100,
]);

$cashSaleLineItem->addVat($outputVat);
$cashSale->addLineItem($cashSaleLineItem);
$cashSale->post(); // This posts the Transaction to the Ledger

The rest of the transactions:

…

We can assign the receipt to partially clear the Invoice above:

php
use IFRS\Models\Assignment;

echo $clientInvoice->clearedAmount; //0: Currently the Invoice has not been cleared at all
echo $clientReceipt->balance; //50: The Receipt has not been assigned to clear any transaction

$assignment = Assignment::create([
    'assignment_date'=> Carbon::now(),
    'transaction_id' => $clientReceipt->id,
    'cleared_id' => $clientInvoice->id,
    'cleared_type'=> $clientInvoice->clearedType,
    'amount' => 50,
]);

echo $clientInvoice->clearedAmount; //50
echo $clientReceipt->balance; //0: The Receipt has been assigned fully to the Invoice

The Income Statement (Profit and Loss):

…

The Balance Sheet:

…

While the Income Statement and Balance Sheet are the ultimate goal for end year (IFRS) reporting, the package also provides intermediate period reports including Account Statement, which shows a chronological listing of all Transactions posted to an account ending with the current balance for the account; and Account Schedule, which is similar to an Account Statement with the difference that rather than list all Transactions that constitute the ending balance the report only shows the outstanding (Uncleared) Transactions.

In the above example:

php
use IFRS\Reports\AccountStatement;
use IFRS\Reports\AccountSchedule;

$transactions = new AccountStatement($clientAccount)->getTransactions();

dd($transactions);

array:2[
  ["transaction" => ClientInvoice, "debit" => 120, "credit" => 0, "balance" => 120],
  ["transaction" => ClientReceipt, "debit" => 0, "credit" => 50, "balance" => 70]
]

$transactions = new AccountSchedule($clientAccount, $currency)->getTransactions();

dd($transactions);

array:1[
  ["transaction" => ClientInvoice, "amount" => 120, "cleared" => 50, "balance" => 70],
]

Changelog

Please see CHANGELOG for more information about recent changes.

Getting Involved

I am acutely aware that as a professionally trained Accountant I may have used some conventions, definitions and styles that while seemingly obvious to me, might not be so clear to another developer. I would therefore welcome and greatly appreciate any feedback on the ease of use of the package so I can make it more useful to as many people as possible.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Write tests for the feature
  4. Commit your changes (git commit -am 'Add some fooBar')
  5. Push to the branch (git push origin feature/fooBar)
  6. Create a new Pull Request

Roadmap

  • Add Cashflow Statement
  • Laravel 8 Compatibility
  • Add Multicurrency support
  • Expand Taxation Functionality

License

This software is distributed for free under the MIT License

References

  • This package is heavily influenced by chippyash/simple-accounts-3 and scottlaurent/accounting.
  • Special thanks to paschaldev for his brilliant work in preventing collisions with already existing db tables.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言