cod-glo / cgaccounting
Accounting package for Laravel
1.0.21
2025-01-02 05:58 UTC
Requires
- php: ^7.3|^8.0
- illuminate/database: ^8.0|^9.0|^10.0
- illuminate/support: ^8.0|^9.0|^10.0
- mpdf/mpdf: dev-development
- nesbot/carbon: ^2.0
README
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, such as accpkg_accounts
and accpkg_entries
.
3. Run Account Seeder
To seed the database with initial account data, run the seeder command:
php artisan db:seed --class=CodGlo\\CGAccounting\\Seeders\\AccountSeeder
This command will populate the accpkg_accounts
table with the necessary parent and sub-accounts.
Usage
AccountingService
The AccountingService
class provides methods to handle accounting operations such as crediting and debiting accounts.
Credit an Amount to an Account
use CodGlo\CGAccounting\Services\AccountingService; $accountingService = new AccountingService(); $result = $accountingService->credit('fromAccount', 'toAccount', 100.0, 'ref123', 'type1', 'Payment for services'); if ($result === true) { echo "Transaction successful!"; } else { echo "Error: " . $result; }
Debit an Amount from an Account
use CodGlo\CGAccounting\Services\AccountingService; $accountingService = new AccountingService(); $result = $accountingService->debit('fromAccount', 'toAccount', 50.0, 'ref456', 'type2', 'Refund for services'); if ($result === true) { echo "Transaction successful!"; } else { echo "Error: " . $result; }
Get Account Details
use CodGlo\CGAccounting\Services\AccountingService; $accountingService = new AccountingService(); $account = $accountingService->getAccount('accountName'); echo "Account ID: " . $account->id;
AccountingReportService
The AccountingReportService
class provides methods to generate various accounting reports.
Generate Profit and Loss Report
use CodGlo\CGAccounting\Services\AccountingReportService; $reportService = new AccountingReportService('Company Name', 'Address', 'Phone', 'Email'); $reportUrl = $reportService->generateProfitAndLossReport('2024-01-01', '2024-12-31'); echo "Report URL: " . $reportUrl;
Generate Cash Flow Report
use CodGlo\CGAccounting\Services\AccountingReportService; $reportService = new AccountingReportService('Company Name', 'Address', 'Phone', 'Email'); $reportUrl = $reportService->generateCashFlow('2024-01-01', '2024-12-31'); echo "Report URL: " . $reportUrl;
Generate Balance Sheet
use CodGlo\CGAccounting\Services\AccountingReportService; $reportService = new AccountingReportService('Company Name', 'Address', 'Phone', 'Email'); $reportUrl = $reportService->generateBalanceSheet('2024-12-31'); echo "Report URL: " . $reportUrl;