cod-glo/cgaccounting
最新稳定版本:1.0.26
Composer 安装命令:
composer require cod-glo/cgaccounting
包简介
Accounting package for Laravel
关键字:
README 文档
README
A Laravel package for handling accounting operations, including account management, transactions, and generating financial reports such as profit and loss, balance sheets, and cash flow statements. Easily manage credits, debits, and generate reports with a simple API.
Features
- Account Management (Assets, Liabilities, Equity, Income, Expenses)
- Transaction Processing (Credits and Debits)
- Financial Report Generation
- Profit and Loss Statements
- Balance Sheets
- Cash Flow Statements
- Trial Balance Sheets
- Cheque Management (with status tracking and references)
- Database Migration and Seeding Support
- Built-in Account Types and Structures
- Flexible Transaction References and Descriptions
- Multi-tenancy support (via
MULTI_TENANCY_ENABLED)
Setup Instructions
1. Install via Composer
composer require cod-glo/cgaccounting
2. Run Migrations
To set up the database tables, run the migration commands:
php artisan migrate
This will create the required tables:
accpkg_accounts: Stores account information and hierarchiesaccpkg_entries: Records all transactions and balancescheques: Stores cheque details and status
3. Run Account Seeder
To seed the database with initial account data:
php artisan db:seed --class=CodGlo\\CGAccounting\\Seeders\\AccountSeeder
Usage
AccountingService
Handles all transaction-related operations.
Credit Transaction
use CodGlo\CGAccounting\Services\AccountingService; $accountingService = new AccountingService(); $result = $accountingService->credit( 'fromAccount', // Source account name 'toAccount', // Destination account name 100.0, // Amount 'ref123', // Reference ID (optional) 'type1', // Reference type (optional) 'Description', // Transaction description (optional) '2024-01-01' // Transaction date (optional) ); if ($result === true) { echo "Transaction successful!"; } else { echo "Error: " . $result; }
Debit Transaction
use CodGlo\CGAccounting\Services\AccountingService; $accountingService = new AccountingService(); $result = $accountingService->debit( 'fromAccount', // Source account name 'toAccount', // Destination account name 50.0, // Amount 'ref456', // Reference ID (optional) 'type2', // Reference type (optional) 'Refund', // Transaction description (optional) '2024-01-02' // Transaction date (optional) );
Get Account
$account = $accountingService->getAccount('Cash');
Get Account Transactions
$transactions = $accountingService->getAccountTransactions( $account->id, '2024-01-01', // Start date (optional) '2024-12-31', // End date (optional) 20 // Results per page (optional) );
Get General Ledger
$ledger = $accountingService->getGeneralLedger( '2024-01-01', // Start date (optional) '2024-12-31', // End date (optional) 50 // Results per page (optional) );
Cheque Management
Cheques are managed via the Cheque model. You can create, update status, and link cheques to transactions using ref_id and ref_type.
use CodGlo\CGAccounting\Models\Cheque; $cheque = new Cheque([ 'cheque_number' => '123456', 'cheque_date' => '2024-12-31', 'type' => 'out', 'amount' => 5000, 'payee_name' => 'Supplier Name', // ... other fields ]); $cheque->save(); // Update status $cheque->updateStatus('cleared');
AccountingReportService
Generate financial reports with customizable company information.
Initialize Report Service
use CodGlo\CGAccounting\Services\AccountingReportService; $reportService = new AccountingReportService( 'Company Name', 'Company Address', 'Phone Number', 'Email Address' );
Generate Reports
Profit and Loss Report
$reportUrl = $reportService->generateProfitAndLossReport( '2024-01-01', // Start date '2024-12-31', // End date 'output/path', // Optional output path 'pdf' // Optional format (pdf/html) );
Cash Flow Report
$reportUrl = $reportService->generateCashFlow( '2024-01-01', // Start date '2024-12-31' // End date );
Balance Sheet
$reportUrl = $reportService->generateBalanceSheet( '2024-12-31' // As of date );
Trial Balance Sheet
$reportUrl = $reportService->generateTrialBalanceSheet( '2024-12-31', // As of date 'output/path', // Optional output path 'pdf' // Optional format (pdf/html) );
Account Types
The package supports standard accounting types:
- Assets
- Liabilities
- Equity
- Income
- Expenses
Error Handling
The package includes validation for:
- Invalid amounts (zero or negative)
- Non-existent accounts
- Invalid account types
- Transaction constraints
Multi-Tenancy
If MULTI_TENANCY_ENABLED is set to true in your .env, the package will use the sqlite_company connection for models.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
cod-glo/cgaccounting 适用场景与选型建议
cod-glo/cgaccounting 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 218 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「laravel」 「Accounting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cod-glo/cgaccounting 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cod-glo/cgaccounting 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cod-glo/cgaccounting 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Access auditing middleware intended for use with Slim Framework applications
Accounting module for atmosphere and laravel
Simple ASCII output of array data
Library for working with monetary values, a BCMath library with rounding support.
Alfabank REST API integration
统计信息
- 总下载量: 218
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-28