Part 1: Journal Entry and General Ledger Structures
A. Journal Entry Structure & Form
A journal entry requires a header (for general information) and lines (for the debit/credit details). 1. Database Migrations (journal_entries & journal_entry_lines)
Create Journal Entry
- Entry Date:
[ 2023-10-27 ] - Description:
[ Payment for monthly office rent - Oct 2023 ] - Reference:
[ INV-RENT-1023 ]
| Account | Line Description | Cost Center | Debit | Credit |
|---|---|---|---|---|
[ 82100 - Rent Expense ] | Office Rent | [ CC-HCGA ] | [ 50,000.00 ] | [ ] |
[ 11100 - Cash - Operating ] | Payment from main account | [ ] | [ ] | [ 50,000.00 ] |
[ + Add Line ] |
- Debit:
50,000.00 - Credit:
50,000.00 - Balance:
0.00(Must be 0 to submit)
[ Save as Draft ] [ Submit for Approval ]
B. General Ledger (GL) Structure
The GL is the final, immutable record of all transactions, aggregated by account. It’s built from posted journal entries. Database Migration (general_ledger)
Part 2: The Journal Posting Process
This process ensures accuracy, control, and auditability.- Creation (Status:
draft): An accountant creates a journal entry. The system validates that Debits = Credits. The entry has no financial impact yet. - Verification (Status:
pending_approval): The entry is submitted. A manager or senior accountant receives a notification. They review the entry for correctness (accounts used, amounts, description, supporting documents). - Approval/Rejection (Status:
approved/rejected):
- If correct, the manager sets the status to
approved. Theapproved_byfield is populated. - If incorrect, it’s set to
rejectedwith a reason, and it goes back to the creator.
- Posting (Status:
posted): This is the crucial step that writes to the General Ledger. It should be an atomic, transactional process, often run as a scheduled job or triggered manually by an authorized user.
- The system fetches all journal entries with
status = 'approved'. - For each
journal_entry_linein the entry: - It calculates the last
balancefor the givenaccount_codefrom thegeneral_ledgertable. - It creates a new record in the
general_ledgertable. - The new
balanceis calculated:previous_balance + debit - credit. - After all lines are successfully written to the GL, the journal entry’s status is updated to
posted. - A
postedjournal entry should be immutable. It cannot be edited or deleted. To correct an error, a new reversing journal entry must be created and posted.
Part 3: Financial Statement Generators (Laravel Artisan Commands)
First, let’s assume you have an Eloquent ModelChartOfAccount for your dim_chart_of_accounts table.
A. Trial Balance Generator
This command shows the closing balance for each account, ensuring debits equal credits. Command:php artisan report:trial-balance --endDate=2023-12-31
B. Profit & Loss (Income Statement) Generator
This command uses the report mappers in the CoA to build the statement. Command:php artisan report:profit-loss --startDate=2023-01-01 --endDate=2023-12-31
C. Balance Sheet Generator
This is the most complex, as it needs the Net Income from the P&L calculation. Command:php artisan report:balance-sheet --endDate=2023-12-31

