otim-otim/bookkeeper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

otim-otim/bookkeeper

最新稳定版本:1.0.1

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

统计信息

  • 总下载量: 221
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固