PHPackages                             azaharizaman/nexus-general-ledger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. azaharizaman/nexus-general-ledger

ActiveLibrary[Database &amp; ORM](/categories/database)

azaharizaman/nexus-general-ledger
=================================

Atomic package for general ledger management - central transaction hub for all financial entries, ledger account management, transaction recording, balance calculation, and trial balance generation

v0.1.0-alpha1(1mo ago)00MITPHPPHP ^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-general-ledger)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-general-ledger)[ RSS](/packages/azaharizaman-nexus-general-ledger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

GeneralLedger Package
=====================

[](#generalledger-package)

Central transaction hub for all financial entries in the Nexus ERP system.

Purpose
-------

[](#purpose)

The **Nexus\\GeneralLedger** package is a Layer-1 atomic package that serves as the **central transaction hub** for all financial entries in the Nexus ERP system. The General Ledger (GL) is the core of any financial system - all journal entries from subledgers (Receivables, Payables, Assets, etc.) must ultimately be posted to the GL to ensure accounting accuracy and generate financial statements.

Key Features
------------

[](#key-features)

- **Ledger Master Data Management**: Create, update, and manage multiple ledgers per tenant (statutory and management ledgers)
- **Ledger Account Management**: Register and manage accounts within the ledger, integrating with ChartOfAccount
- **Journal Entry Posting**: Post validated journal entries to the general ledger with full audit trail
- **Account Balance Calculation**: Real-time calculation of debit/credit balances as of any date
- **Trial Balance Generation**: Generate comprehensive trial balance reports for all accounts
- **Multi-Entity Support**: Support for multiple entities (tenants) with isolated ledger data
- **Multi-Currency Support**: Handle transactions in multiple currencies with proper conversion
- **Subledger Integration**: Interfaces for AR, AP, and Assets subledgers to post transactions to GL
- **Fiscal Period Validation**: Enforce posting only to open accounting periods
- **Transaction Reversal**: Reverse posted transactions with full audit trail

Installation
------------

[](#installation)

```
composer require azaharizaman/nexus-general-ledger
```

### Requirements

[](#requirements)

- PHP ^8.3
- azaharizaman/nexus-common ^1.0
- brick/math ^0.12

Usage
-----

[](#usage)

### Creating a Ledger

[](#creating-a-ledger)

```
use Nexus\GeneralLedger\Services\LedgerService;
use Nexus\GeneralLedger\Enums\LedgerType;

// $ledgerService should be injected via IdGeneratorInterface
$ledger = $ledgerService->createLedger(
    tenantId: 'tenant-123',
    name: 'Statutory Ledger',
    type: LedgerType::STATUTORY,
    currency: 'USD',
    description: 'Main statutory ledger'
);

echo $ledger->id; // generated ID string
```

### Calculating Account Balances

[](#calculating-account-balances)

```
use Nexus\GeneralLedger\Services\TransactionService;

$balance = $transactionService->getAccountBalance(
    $account->id,
    new DateTimeImmutable('2024-01-31')
);

echo $balance->getAmount()->getAmount(); // Account balance as of date
echo $balance->balanceType->value; // debit or credit
```

### Generating Trial Balance

[](#generating-trial-balance)

```
$trialBalance = $trialBalanceService->generateTrialBalance(
    $ledger->id,
    'period-2024-01'
);

echo $trialBalance->totalDebits->getAmount();
echo $trialBalance->totalCredits->getAmount();
echo $trialBalance->isBalanced; // true if debits = credits

foreach ($trialBalance->lines as $line) {
    // Correctly access TrialBalanceLine properties
    $balance = $line->getNetBalance();
    echo $line->accountCode . ': ' . $balance->getAmount();
}
```

Interfaces
----------

[](#interfaces)

### Core Interfaces

[](#core-interfaces)

InterfaceDescription[`SubledgerPostingInterface`](src/Contracts/SubledgerPostingInterface.php)Interface for subledgers to post to GL[`IdGeneratorInterface`](src/Contracts/IdGeneratorInterface.php)Framework-agnostic unique ID generation[`DatabaseTransactionInterface`](src/Contracts/DatabaseTransactionInterface.php)Framework-agnostic transaction management### Repository Interfaces (CQRS)

[](#repository-interfaces-cqrs)

InterfaceDescription[`LedgerQueryInterface`](src/Contracts/LedgerQueryInterface.php)Read operations for Ledgers[`LedgerPersistInterface`](src/Contracts/LedgerPersistInterface.php)Write operations for Ledgers[`LedgerAccountQueryInterface`](src/Contracts/LedgerAccountQueryInterface.php)Read operations for LedgerAccounts[`LedgerAccountPersistInterface`](src/Contracts/LedgerAccountPersistInterface.php)Write operations for LedgerAccounts[`TransactionQueryInterface`](src/Contracts/TransactionQueryInterface.php)Read operations for Transactions[`TransactionPersistInterface`](src/Contracts/TransactionPersistInterface.php)Write operations for TransactionsModels (Entities)
-----------------

[](#models-entities)

EntityDescription[`Ledger`](src/Entities/Ledger.php)Immutable ledger entity[`LedgerAccount`](src/Entities/LedgerAccount.php)Immutable ledger account entity[`Transaction`](src/Entities/Transaction.php)Immutable transaction entity[`TrialBalance`](src/Entities/TrialBalance.php)Immutable trial balance report entity[`TrialBalanceLine`](src/Entities/TrialBalanceLine.php)Individual line in a trial balanceValue Objects
-------------

[](#value-objects)

Value ObjectDescription[`AccountBalance`](src/ValueObjects/AccountBalance.php)Represents balance with debit/credit type[`TransactionDetail`](src/ValueObjects/TransactionDetail.php)Transaction metadata for posting[`PostingResult`](src/ValueObjects/PostingResult.php)Result of a posting operation[`SubledgerPostingRequest`](src/ValueObjects/SubledgerPostingRequest.php)Request from a subledger[`ValidationResult`](src/ValueObjects/ValidationResult.php)Result of a validation checkExceptions
----------

[](#exceptions)

ExceptionDescription[`GeneralLedgerException`](src/Exceptions/GeneralLedgerException.php)Base GL exception[`LedgerNotFoundException`](src/Exceptions/LedgerNotFoundException.php)Ledger not found[`LedgerAlreadyActiveException`](src/Exceptions/LedgerAlreadyActiveException.php)Ledger already active[`LedgerAlreadyClosedException`](src/Exceptions/LedgerAlreadyClosedException.php)Ledger already closed[`LedgerArchivedException`](src/Exceptions/LedgerArchivedException.php)Ledger is archived[`AccountNotFoundException`](src/Exceptions/AccountNotFoundException.php)Account not found[`PeriodClosedException`](src/Exceptions/PeriodClosedException.php)Posting to closed period[`InvalidPostingException`](src/Exceptions/InvalidPostingException.php)Posting validation failed[`TransactionAlreadyReversedException`](src/Exceptions/TransactionAlreadyReversedException.php)Double reversal attempted[`LedgerEntryNotFoundException`](src/Exceptions/LedgerEntryNotFoundException.php)Entry not found[`DuplicatePostingException`](src/Exceptions/DuplicatePostingException.php)Duplicate posting detected[`InvalidTransactionException`](src/Exceptions/InvalidTransactionException.php)Transaction state is invalidArchitecture
------------

[](#architecture)

This package follows the Atomic Architecture pattern (Layer 1):

- **Contracts**: Interface definitions for domain contracts and repository patterns (CQRS)
- **Entities**: Domain entities (Ledger, Transaction, etc.)
- **ValueObjects**: Immutable data structures
- **Services**: Pure business logic (LedgerService, TransactionService)
- **Enums**: Type-safe enumerations
- **Exceptions**: Domain-specific exceptions

License
-------

[](#license)

MIT License

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance93

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-general-ledger/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-general-ledger/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-general-ledger)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[illuminate/database

The Illuminate Database package.

3.0k54.1M11.0k](/packages/illuminate-database)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.2M18](/packages/bavix-laravel-wallet)[brick/money

Money and currency library

1.9k40.4M139](/packages/brick-money)[illuminate/validation

The Illuminate Validation package.

18837.7M1.6k](/packages/illuminate-validation)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

377559.7k85](/packages/flow-php-etl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
