Download the PHP package michael-orenda/general-ledger without Composer

On this page you can find all versions of the php package michael-orenda/general-ledger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package general-ledger

General Ledger Package

A robust, test-driven General Ledger (GL) package for Laravel 12 designed as a reusable component for accounting systems. Written to be embedded as a package in larger host applications.


Table of contents

  1. Overview
  2. Key Concepts
  3. Requirements
  4. Installation
  5. Configuration
  6. Database Migrations & Seeds
  7. Models & Relationships
  8. Services
  9. Controllers & Routes (API)
  10. Validation & Business Rules
  11. Database Constraints & Triggers
  12. Events & Listeners
  13. Testing
  14. Security & Concurrency
  15. Packaging & Release
  16. Troubleshooting
  17. Examples & Use-Cases
  18. Contributing
  19. Changelog
  20. License

Overview

This package provides a General Ledger implementation that follows standard double-entry accounting principles, shaped for multi-organisation, multi-fiscal-period systems. It aims to be:

Primary capabilities:


Key Concepts


Requirements


Installation

Install via composer (package name to replace with the published packagist name):

Publish config, migrations and seeds (if the package provides publishable assets):

Run migrations:

Seed default Chart of Accounts and a sample organisation (optional):


Configuration

config/general-ledger.php (sensible defaults):

Explaination of key options:


Database Migrations & Seeds

The package includes the following recommended tables:

Migrations should include indexes on organisation_id, fiscal_period_id and ledger_account_id for performance.

Seeders


Models & Relationships

Outline of essential Eloquent models and their core relationships:

Add docblocks and typed properties on each model for clarity and static analysis support.


Services

This section documents all service classes in the General Ledger package, their responsibilities, invariants, and example usage patterns. These services are the only supported way to interact with the ledger at the domain level. Controllers, commands, and sub-ledgers must call services — never manipulate models directly.

Design rule: Services encapsulate business invariants. Models remain persistence-focused.


AccountLedgerService

Purpose

Produces a ledger (running balance) for a single account over a date or fiscal-period range.

Responsibilities

Typical Use Cases

Example

Returns


AuditTrailService

Purpose

Provides a read-only, immutable audit trail of all ledger activity.

Responsibilities

Important Rule

Audit data is never mutated — even reversals create new entries.

Example


GeneralLedgerReportService

Purpose

Produces the official General Ledger report used for statutory reporting.

Responsibilities

Example


LedgerQueryService

Purpose

Low-level query abstraction for ledger entries.

Responsibilities

Example


LedgerPostingService

Purpose

Lowest-level service responsible for inserting ledger entries.

Important

You should never call this directly from controllers. Use JournalPostingService instead.

Responsibilities

Used internally by:


JournalPostingService

Purpose

Primary entry point for posting accounting transactions.

Responsibilities

Example

Throws


JournalReversalService / ReversalJournalService

Purpose

Creates a reversing journal for an existing journal.

Responsibilities

Example

Rule

Reversals must always post into an open fiscal period.


TrialBalanceService

Purpose

Produces a Trial Balance for a given period or date.

Responsibilities

Example

If the trial balance does not balance, period close must be blocked.


OpeningBalanceService

Purpose

Generates opening balances for a new fiscal period.

Responsibilities

Example


PeriodCloseService / FiscalPeriodCloseService

Purpose

Safely closes a fiscal period.

Responsibilities

  1. Generate Trial Balance
  2. Validate balance correctness
  3. Generate opening balances for next period
  4. Lock the period (DB + application)
  5. Emit PeriodClosed event

Example

Hard Guarantees


All core business logic lives in service classes. Keep controllers thin.

JournalPostingService

Responsibilities:

Example usage:

Important checks inside post():

Transaction handling:

PeriodCloseService

Responsibilities:

Example:

OpeningBalanceService

Generates the opening balances for a new fiscal period from previous period totals and retained earnings transformations. Should be idempotent — calling it multiple times should not duplicate balances.


Controllers & Routes (API)

Provide API endpoints namespaced under /api/general-ledger or similar. Use API resources for consistent responses.

Example routes:

Controller responsibilities:

Example API Request — Post Journal

POST /api/general-ledger/journals

Payload:

Success: HTTP 201 with created journal details. Failure: HTTP 422 with validation errors or HTTP 409 if period closed.


Validation & Business Rules

  1. Journals must be balanced (total debits == total credits).
  2. Every entry must reference a valid ledger account.
  3. Cannot post into a closed period — enforce at service-level and with DB-level constraints/triggers.
  4. Opening balances must be posted to the first period of the fiscal year only through the OpeningBalanceService.
  5. Avoid floating point rounding errors: store amounts as integers representing the smallest currency unit (e.g., cents) or use decimal(20,4) depending on requirements.

Database Constraints & Triggers

To prevent accidental posting to closed periods at the DB level (MySQL example):

Create similar triggers for BEFORE UPDATE and BEFORE DELETE depending on policy. In the migration files, add these triggers conditionally (guard with if (Schema::hasTable('fiscal_periods')) { ... }).

Note: not all DBs support triggers or SIGNAL semantics. If you need Postgres, implement plpgsql triggers or prefer application-level enforcement.


Events & Listeners

Emit meaningful domain events:

Listeners can:

Example event dispatch:


Testing

Suggested tests:

Run tests:


Security & Concurrency


Packaging & Release

Suggested git commit message for major release:


Troubleshooting

If you run into issues, enable detailed logs (set APP_DEBUG=true) and inspect laravel.log.


Examples & Use-Cases

Posting a Sales Invoice (from a SubLedger)

  1. The invoice module builds a Journal payload.
  2. It validates business rules (customer exists, amount positive).
  3. Calls JournalPostingService::post($payload).
  4. The GL persists entries, emits JournalPosted and the invoice marks itself posted_to_gl.

Closing a Period (end of month)

  1. Admin triggers POST /api/general-ledger/periods/{id}/close.
  2. Controller calls PeriodCloseService::close() inside a transaction.
  3. Service computes retained earnings transfers and creates opening balances for the next period.
  4. fiscal_period.is_closed set to true and DB triggers now block further inserts.

Contributing

  1. Fork repository
  2. Create feature branch: feature/awesome-thing
  3. Implement code + tests
  4. Submit PR and ensure CI passes

Coding standards: PSR-12, typed properties where helpful, docblocks for public APIs.


Changelog


License

MIT — see LICENSE in the repository.


Appendix: Helpful Snippets

DB Transaction skeleton (service):

Check balanced:

Trigger creation in migration (MySQL):

Add migration content carefully and conditionally — see up()/down() examples in package migrations.


If you'd like, I can also:

Tell me which of those you want and I will generate them next.


All versions of general-ledger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/routing Version ^12.0
michael-orenda/chart-of-accounts Version ^1.0
michael-orenda/fiscal Version ^1.0
rminchrist/organisations Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package michael-orenda/general-ledger contains the following files

Loading the files please wait ...