azaharizaman/nexus-chart-of-account 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

azaharizaman/nexus-chart-of-account

Composer 安装命令:

composer require azaharizaman/nexus-chart-of-account

包简介

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

README 文档

README

Framework-Agnostic Chart of Accounts Management Package

PHP Version License

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

composer require azaharizaman/nexus-chart-of-account

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

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

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

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

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

Write operations for accounts (CQRS Command model).

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

Account Types

Type Normal Balance Balance Sheet? Example Accounts
Asset Debit Yes Cash, Inventory, Equipment
Liability Credit Yes Accounts Payable, Loans
Equity Credit Yes Common Stock, Retained Earnings
Revenue Credit No Sales Revenue, Service Income
Expense Debit No Wages, Rent, Utilities

Value Objects

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

  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

This package is consumed by:

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

Related Documentation

License

MIT License - See LICENSE for details.

azaharizaman/nexus-chart-of-account 适用场景与选型建议

azaharizaman/nexus-chart-of-account 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 azaharizaman/nexus-chart-of-account 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 azaharizaman/nexus-chart-of-account 我们能提供哪些服务?
定制开发 / 二次开发

基于 azaharizaman/nexus-chart-of-account 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-04