Skip to main content

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)
2. Standard Form Layout (Conceptual) A web form for creating a journal entry would look like this:
Create Journal Entry
  • Entry Date: [ 2023-10-27 ]
  • Description: [ Payment for monthly office rent - Oct 2023 ]
  • Reference: [ INV-RENT-1023 ]
Entry Lines: Totals:
  • 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.
  1. Creation (Status: draft): An accountant creates a journal entry. The system validates that Debits = Credits. The entry has no financial impact yet.
  2. 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).
  3. Approval/Rejection (Status: approved / rejected):
  • If correct, the manager sets the status to approved. The approved_by field is populated.
  • If incorrect, it’s set to rejected with a reason, and it goes back to the creator.
  1. 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_line in the entry:
  • It calculates the last balance for the given account_code from the general_ledger table.
  • It creates a new record in the general_ledger table.
  • The new balance is calculated: previous_balance + debit - credit.
  • After all lines are successfully written to the GL, the journal entry’s status is updated to posted.
  • A posted journal 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 Model ChartOfAccount 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