azaharizaman/nexus-general-ledger
Composer 安装命令:
composer require 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
README 文档
README
Central transaction hub for all financial entries in the Nexus ERP system.
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
- 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
composer require azaharizaman/nexus-general-ledger
Requirements
- PHP ^8.3
- azaharizaman/nexus-common ^1.0
- brick/math ^0.12
Usage
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
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
$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
Core Interfaces
| Interface | Description |
|---|---|
SubledgerPostingInterface |
Interface for subledgers to post to GL |
IdGeneratorInterface |
Framework-agnostic unique ID generation |
DatabaseTransactionInterface |
Framework-agnostic transaction management |
Repository Interfaces (CQRS)
| Interface | Description |
|---|---|
LedgerQueryInterface |
Read operations for Ledgers |
LedgerPersistInterface |
Write operations for Ledgers |
LedgerAccountQueryInterface |
Read operations for LedgerAccounts |
LedgerAccountPersistInterface |
Write operations for LedgerAccounts |
TransactionQueryInterface |
Read operations for Transactions |
TransactionPersistInterface |
Write operations for Transactions |
Models (Entities)
| Entity | Description |
|---|---|
Ledger |
Immutable ledger entity |
LedgerAccount |
Immutable ledger account entity |
Transaction |
Immutable transaction entity |
TrialBalance |
Immutable trial balance report entity |
TrialBalanceLine |
Individual line in a trial balance |
Value Objects
| Value Object | Description |
|---|---|
AccountBalance |
Represents balance with debit/credit type |
TransactionDetail |
Transaction metadata for posting |
PostingResult |
Result of a posting operation |
SubledgerPostingRequest |
Request from a subledger |
ValidationResult |
Result of a validation check |
Exceptions
| Exception | Description |
|---|---|
GeneralLedgerException |
Base GL exception |
LedgerNotFoundException |
Ledger not found |
LedgerAlreadyActiveException |
Ledger already active |
LedgerAlreadyClosedException |
Ledger already closed |
LedgerArchivedException |
Ledger is archived |
AccountNotFoundException |
Account not found |
PeriodClosedException |
Posting to closed period |
InvalidPostingException |
Posting validation failed |
TransactionAlreadyReversedException |
Double reversal attempted |
LedgerEntryNotFoundException |
Entry not found |
DuplicatePostingException |
Duplicate posting detected |
InvalidTransactionException |
Transaction state is invalid |
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
MIT License
azaharizaman/nexus-general-ledger 适用场景与选型建议
azaharizaman/nexus-general-ledger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 azaharizaman/nexus-general-ledger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 azaharizaman/nexus-general-ledger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-04