otim-otim/bookkeeper
Composer 安装命令:
composer require otim-otim/bookkeeper
包简介
A Laravel package for double-entry bookkeeping and accounting statements.
README 文档
README
A double-entry bookkeeping package for Laravel. Install it in any Laravel application to get a full chart of accounts, journal entry recording, and financial statement generation out of the box.
Installation
1. Add the package via Composer
composer require otimdibossman/bookkeeper
Laravel auto-discovery will automatically register the BookKeeperServiceProvider and the BookKeeper facade.
2. Run the migrations
php artisan migrate
Or publish the migrations to customise them first:
php artisan vendor:publish --tag=bookkeeper-migrations php artisan migrate
Quick Start
Create accounts
use OtimOtim\BookKeeper\Facades\BookKeeper; use OtimOtim\BookKeeper\Enums\AccountType; // Chart of accounts BookKeeper::createAccount('1000', 'Cash', AccountType::Asset); BookKeeper::createAccount('1100', 'Accounts Receivable', AccountType::Asset); BookKeeper::createAccount('2000', 'Accounts Payable', AccountType::Liability); BookKeeper::createAccount('3000', 'Owner Capital', AccountType::Equity); BookKeeper::createAccount('4000', 'Sales Revenue', AccountType::Revenue); BookKeeper::createAccount('5000', 'Cost of Goods', AccountType::Expense);
Record a journal entry (double-entry)
BookKeeper::record([ ['account' => '1000', 'type' => 'debit', 'amount' => 1500.00, 'memo' => 'Cash received'], ['account' => '4000', 'type' => 'credit', 'amount' => 1500.00, 'memo' => 'Sale of goods'], ], [ 'date' => '2024-03-01', 'memo' => 'Cash sale to customer', 'reference' => 'INV-2024-001', ]);
The package will throw UnbalancedEntryException if debits ≠ credits.
Transfer (convenience method)
// Debit Cash, Credit Revenue — in one call BookKeeper::transfer('1000', '4000', 2000.00, [ 'memo' => 'Payment received', 'reference' => 'PAY-001', ]);
Check an account balance
$balance = BookKeeper::balance('1000'); // current balance $balance = BookKeeper::balanceAsOf('1000', '2024-12-31'); // historical
Financial Statements
Balance Sheet
$sheet = BookKeeper::balanceSheet('2024-12-31'); // Returns: assets, liabilities, equity, totals, balanced (bool) dump($sheet['totals']); // ['assets' => 50000, 'liabilities' => 20000, 'equity' => 30000, 'liabilities_equity' => 50000]
Income Statement (Profit & Loss)
$pl = BookKeeper::incomeStatement('2024-01-01', '2024-12-31'); dump($pl['totals']); // ['revenue' => 80000, 'expenses' => 45000, 'net_income' => 35000]
Trial Balance
$trial = BookKeeper::trialBalance('2024-12-31'); dump($trial['balanced']); // true dump($trial['totals']); // ['debits' => 120000, 'credits' => 120000]
General Ledger
$account = BookKeeper::account('1000'); $ledger = BookKeeper::generalLedger($account, '2024-01-01', '2024-12-31'); // Returns all transaction lines for the account with running details
Direct Service Access
You can also inject the services directly:
use OtimOtim\BookKeeper\Services\AccountService; use OtimOtim\BookKeeper\Services\LedgerService; use OtimOtim\BookKeeper\Services\StatementService; class MyController { public function __construct( private AccountService $accounts, private LedgerService $ledger, private StatementService $statements, ) {} }
Account Types
| Type | Normal Balance | Statement |
|---|---|---|
Asset |
Debit | Balance Sheet |
Liability |
Credit | Balance Sheet |
Equity |
Credit | Balance Sheet |
Revenue |
Credit | Income Statement |
Expense |
Debit | Income Statement |
Database Tables
| Table | Purpose |
|---|---|
bookkeeper_accounts |
Chart of accounts |
bookkeeper_journal_entries |
Groups of balanced debits/credits |
bookkeeper_transactions |
Individual debit/credit lines |
Running Tests
composer install vendor/bin/phpunit
License
MIT
otim-otim/bookkeeper 适用场景与选型建议
otim-otim/bookkeeper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 221 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「ledger」 「Accounting」 「bookkeeping」 「double-entry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 otim-otim/bookkeeper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 otim-otim/bookkeeper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 otim-otim/bookkeeper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
General Ledger and Journal Accounting Package for Laravel with JSON API
PHP SDK for Ledga.io - Programmatic double-entry ledgers for finance, gaming and multi-tenant SaaS
Access auditing middleware intended for use with Slim Framework applications
Accounting module for atmosphere and laravel
Library for working with monetary values, a BCMath library with rounding support.
ledger implementation for laravel
统计信息
- 总下载量: 221
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-02