PHPackages                             azaharizaman/nexus-chart-of-account - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-chart-of-account

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-chart-of-account
===================================

Nexus Chart of Account Package - Framework-agnostic chart of accounts management for general ledger

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

Since May 5Pushed 1mo agoCompare

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

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

Nexus\\ChartOfAccount
=====================

[](#nexuschartofaccount)

**Framework-Agnostic Chart of Accounts Management Package**

[![PHP Version](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

Overview
--------

[](#overview)

`Nexus\ChartOfAccount` is an **atomic package** that provides framework-agnostic chart of accounts management for general ledger systems. This package focuses exclusively on account structure, hierarchy, and master data management.

As an atomic package, it:

- **Owns the Truth** - Defines AccountInterface and account structure
- **Is Framework-Agnostic** - Pure PHP with no database or framework dependencies
- **Is Contract-Driven** - All persistence via repository interfaces

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

[](#installation)

```
composer require azaharizaman/nexus-chart-of-account
```

Features
--------

[](#features)

- ✅ Hierarchical chart of accounts with unlimited depth
- ✅ Five standard account types (Asset, Liability, Equity, Revenue, Expense)
- ✅ Debit/Credit normal balance awareness
- ✅ Header (group) accounts vs. postable (leaf) accounts
- ✅ Account activation/deactivation without deletion
- ✅ Flexible account code formats (numeric, alphanumeric, dot/dash-separated)
- ✅ Account code value object with validation
- ✅ Parent-child type inheritance validation

Quick Start
-----------

[](#quick-start)

```
use Nexus\ChartOfAccount\Contracts\AccountManagerInterface;
use Nexus\ChartOfAccount\Enums\AccountType;

// Inject the manager (via DI container)
public function __construct(
    private readonly AccountManagerInterface $accountManager
) {}

// Create an account
$account = $this->accountManager->createAccount([
    'code' => '1000',
    'name' => 'Cash and Cash Equivalents',
    'type' => AccountType::Asset->value,
    'is_header' => true,
]);

// Create a child account
$childAccount = $this->accountManager->createAccount([
    'code' => '1000-001',
    'name' => 'Petty Cash',
    'type' => AccountType::Asset->value,
    'parent_id' => $account->getId(),
    'is_header' => false,
]);

// Find accounts
$account = $this->accountManager->findByCode('1000');
$children = $this->accountManager->findChildren($account->getId());
```

Architecture
------------

[](#architecture)

```
src/
├── Contracts/           # Interfaces
│   ├── AccountInterface.php
│   ├── AccountQueryInterface.php
│   ├── AccountPersistInterface.php
│   └── AccountManagerInterface.php
├── Enums/
│   └── AccountType.php
├── ValueObjects/
│   └── AccountCode.php
├── Services/
│   └── AccountManager.php
└── Exceptions/
    ├── ChartOfAccountException.php
    ├── AccountNotFoundException.php
    ├── DuplicateAccountCodeException.php
    ├── InvalidAccountException.php
    └── AccountHasChildrenException.php

```

Contracts
---------

[](#contracts)

### `AccountInterface`

[](#accountinterface)

Defines the structure of a chart of accounts entry.

```
interface AccountInterface
{
    public function getId(): string;
    public function getCode(): string;
    public function getName(): string;
    public function getType(): AccountType;
    public function getParentId(): ?string;
    public function isHeader(): bool;
    public function isActive(): bool;
    public function getDescription(): ?string;
    public function getCreatedAt(): DateTimeImmutable;
    public function getUpdatedAt(): DateTimeImmutable;
}
```

### `AccountQueryInterface`

[](#accountqueryinterface)

Read operations for accounts (CQRS Query model).

```
interface AccountQueryInterface
{
    public function find(string $id): ?AccountInterface;
    public function findByCode(string $code): ?AccountInterface;
    public function findAll(array $filters = []): array;
    public function findChildren(string $parentId): array;
    public function findByType(AccountType $type): array;
    public function codeExists(string $code, ?string $excludeId = null): bool;
}
```

### `AccountPersistInterface`

[](#accountpersistinterface)

Write operations for accounts (CQRS Command model).

```
interface AccountPersistInterface
{
    public function save(AccountInterface $account): AccountInterface;
    public function delete(string $id): void;
}
```

Account Types
-------------

[](#account-types)

TypeNormal BalanceBalance Sheet?Example AccountsAssetDebitYesCash, Inventory, EquipmentLiabilityCreditYesAccounts Payable, LoansEquityCreditYesCommon Stock, Retained EarningsRevenueCreditNoSales Revenue, Service IncomeExpenseDebitNoWages, Rent, UtilitiesValue Objects
-------------

[](#value-objects)

### `AccountCode`

[](#accountcode)

Immutable value object for account codes with validation.

```
use Nexus\ChartOfAccount\ValueObjects\AccountCode;

$code = AccountCode::fromString('1000-001');
$code->getValue();      // '1000-001'
$code->getLevel();      // 1 (based on dash separators)
$code->getParent();     // AccountCode('1000')
$code->isParentOf($child); // bool
```

Business Rules
--------------

[](#business-rules)

1. **Account Codes Must Be Unique** - Within tenant scope
2. **Type Inheritance** - Child accounts inherit parent's root type
3. **Header Accounts Not Postable** - Only leaf accounts can have journal entries
4. **Deletion Prevention** - Accounts with children or transactions cannot be deleted
5. **Activation/Deactivation** - Preserves history without deletion

Integration
-----------

[](#integration)

This package is consumed by:

- `Nexus\JournalEntry` - For account validation during posting
- `Nexus\AccountingOperations` - For coordinated financial workflows

Related Documentation
---------------------

[](#related-documentation)

- [ARCHITECTURE.md](../../ARCHITECTURE.md) - System architecture
- [CODING\_GUIDELINES.md](../../CODING_GUIDELINES.md) - Coding standards
- [REQUIREMENTS.md](REQUIREMENTS.md) - Package requirements

License
-------

[](#license)

MIT License - See [LICENSE](LICENSE) for details.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance93

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-chart-of-account/health.svg)

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

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

515135.1M619](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8955.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M199](/packages/illuminate-broadcasting)

PHPackages © 2026

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