PHPackages                             azaharizaman/nexus-financial-statements - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. azaharizaman/nexus-financial-statements

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

azaharizaman/nexus-financial-statements
=======================================

Financial statement structures, templates, and validation for GAAP/IFRS compliance

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

Since May 5Pushed 1mo agoCompare

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

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

Nexus\\FinancialStatements
==========================

[](#nexusfinancialstatements)

**Framework-Agnostic Financial Statement Generation Engine**

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

Overview
--------

[](#overview)

`Nexus\FinancialStatements` is a pure PHP package that provides the core engine for generating, validating, and formatting financial statements. It supports multiple compliance frameworks (GAAP, IFRS, local standards) and produces Balance Sheets, Income Statements, Cash Flow Statements, Statements of Changes in Equity, and Notes to Financial Statements.

This package is **framework-agnostic** and contains no database access, no HTTP controllers, and no framework-specific code. Consuming applications provide data through injected interfaces.

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

[](#installation)

```
composer require azaharizaman/nexus-financial-statements
```

Package Responsibilities
------------------------

[](#package-responsibilities)

ResponsibilityDescription**Statement Generation**Build complete financial statements from account balances**Multi-Framework Compliance**Support GAAP, IFRS, and custom compliance layouts**Section Organization**Group accounts into proper statement sections (Assets, Liabilities, etc.)**Validation**Ensure statements balance and meet compliance requirements**Export Adapters**Define contracts for PDF, Excel, HTML export (implementations in adapters)Key Concepts
------------

[](#key-concepts)

### Statement Types Supported

[](#statement-types-supported)

- **Balance Sheet** (Statement of Financial Position)
- **Income Statement** (Profit &amp; Loss)
- **Cash Flow Statement** (Direct &amp; Indirect methods)
- **Statement of Changes in Equity**
- **Notes to Financial Statements**
- **Trial Balance**

### Compliance Frameworks

[](#compliance-frameworks)

The package supports multiple compliance frameworks through layout templates:

- **GAAP** (US Generally Accepted Accounting Principles)
- **IFRS** (International Financial Reporting Standards)
- **Custom** (Tenant-defined layouts)

---

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

[](#architecture)

```
src/
├── Contracts/           # Interfaces defining the public API
├── Entities/            # Statement domain objects
├── ValueObjects/        # Immutable data structures
├── Enums/               # Statement types, formats, categories
├── Services/            # Business logic (validation, grouping)
├── Layouts/             # Compliance-specific statement layouts
└── Exceptions/          # Domain-specific errors

```

---

Contracts (Interfaces)
----------------------

[](#contracts-interfaces)

### Core Interfaces

[](#core-interfaces)

#### `FinancialStatementInterface`

[](#financialstatementinterface)

Base interface for all financial statement entities.

```
interface FinancialStatementInterface
{
    public function getId(): string;
    public function getTenantId(): string;
    public function getPeriodId(): string;
    public function getType(): StatementType;
    public function getGeneratedAt(): \DateTimeImmutable;
    public function getSections(): array;
    public function getMetadata(): StatementMetadata;
}
```

#### `StatementBuilderInterface`

[](#statementbuilderinterface)

Builds financial statements from raw account data.

```
interface StatementBuilderInterface
{
    /**
     * Build a financial statement of the specified type
     *
     * @param StatementType $type The type of statement to build
     * @param array $balances Account balances to include
     * @param StatementPeriod $period The reporting period
     * @param ComplianceFramework $framework Compliance framework to use
     * @return FinancialStatementInterface
     */
    public function build(
        StatementType $type,
        array $balances,
        StatementPeriod $period,
        ComplianceFramework $framework
    ): FinancialStatementInterface;
}
```

#### `StatementTemplateInterface`

[](#statementtemplateinterface)

Defines the structure and layout of a statement type.

```
interface StatementTemplateInterface
{
    public function getStatementType(): StatementType;
    public function getFramework(): ComplianceFramework;
    public function getSectionDefinitions(): array;
    public function getLineItemOrder(): array;
    public function getSubtotalRules(): array;
}
```

#### `StatementValidatorInterface`

[](#statementvalidatorinterface)

Validates statement integrity and compliance.

```
interface StatementValidatorInterface
{
    /**
     * Validate a financial statement
     *
     * @param FinancialStatementInterface $statement
     * @return ValidationResult
     * @throws StatementImbalanceException
     */
    public function validate(FinancialStatementInterface $statement): ValidationResult;

    /**
     * Check if statement meets compliance requirements
     */
    public function checkCompliance(
        FinancialStatementInterface $statement,
        ComplianceFramework $framework
    ): ComplianceCheckResult;
}
```

#### `ComplianceTemplateInterface`

[](#compliancetemplateinterface)

Provides compliance-specific formatting rules.

```
interface ComplianceTemplateInterface
{
    public function getFramework(): ComplianceFramework;
    public function getRequiredSections(): array;
    public function getRequiredDisclosures(): array;
    public function getAccountMappings(): array;
}
```

#### `StatementDataProviderInterface`

[](#statementdataproviderinterface)

Contract for consuming applications to provide account data.

```
interface StatementDataProviderInterface
{
    /**
     * Get account balances for a period
     *
     * @return array
     */
    public function getAccountBalances(
        string $tenantId,
        string $periodId,
        \DateTimeImmutable $asOfDate
    ): array;

    /**
     * Get comparative period balances
     */
    public function getComparativeBalances(
        string $tenantId,
        string $periodId,
        int $periodsBack = 1
    ): array;
}
```

#### `StatementExportAdapterInterface`

[](#statementexportadapterinterface)

Contract for export implementations (PDF, Excel, etc.).

```
interface StatementExportAdapterInterface
{
    public function export(
        FinancialStatementInterface $statement,
        StatementFormat $format,
        array $options = []
    ): ExportResult;

    public function supportsFormat(StatementFormat $format): bool;
}
```

---

Entities
--------

[](#entities)

### `BalanceSheet`

[](#balancesheet)

Represents a Statement of Financial Position.

- Assets = Liabilities + Equity (must balance)
- Supports current/non-current classification
- Comparative period support

### `IncomeStatement`

[](#incomestatement)

Represents a Profit &amp; Loss statement.

- Revenue - Expenses = Net Income
- Supports single-step and multi-step formats
- Gross profit calculation

### `CashFlowStatement`

[](#cashflowstatement)

Represents a Statement of Cash Flows.

- Operating, Investing, Financing activities
- Supports Direct and Indirect methods
- Beginning + Net Change = Ending Cash

### `StatementOfChangesInEquity`

[](#statementofchangesinequity)

Tracks equity movements over a period.

- Opening equity balances
- Comprehensive income
- Dividends and distributions
- Share transactions

### `NotesToFinancialStatements`

[](#notestofinancialstatements)

Supplementary disclosures and accounting policies.

### `TrialBalance`

[](#trialbalance)

Pre-statement verification of account balances.

- Debits must equal Credits
- Used for period-end verification

### `StatementSection`

[](#statementsection)

Groups related line items within a statement.

- Section name and order
- Subtotal calculations
- Nested sub-sections support

---

Value Objects
-------------

[](#value-objects)

### `LineItem`

[](#lineitem)

```
final readonly class LineItem
{
    public function __construct(
        public string $accountId,
        public string $accountName,
        public string $accountCode,
        public Money $amount,
        public Money $comparativeAmount,
        public int $displayOrder,
        public bool $isSubtotal = false
    ) {}
}
```

### `AccountBalance`

[](#accountbalance)

```
final readonly class AccountBalance
{
    public function __construct(
        public string $accountId,
        public string $accountCode,
        public string $accountName,
        public AccountCategory $category,
        public Money $debitBalance,
        public Money $creditBalance,
        public Money $netBalance
    ) {}
}
```

### `StatementMetadata`

[](#statementmetadata)

```
final readonly class StatementMetadata
{
    public function __construct(
        public string $preparedBy,
        public \DateTimeImmutable $preparedAt,
        public ?string $approvedBy,
        public ?\DateTimeImmutable $approvedAt,
        public ComplianceFramework $framework,
        public string $currency,
        public array $notes = []
    ) {}
}
```

### `StatementPeriod`

[](#statementperiod)

```
final readonly class StatementPeriod
{
    public function __construct(
        public string $periodId,
        public \DateTimeImmutable $startDate,
        public \DateTimeImmutable $endDate,
        public string $periodName,
        public bool $isClosed = false
    ) {}
}
```

### `ComplianceStandard`

[](#compliancestandard)

```
final readonly class ComplianceStandard
{
    public function __construct(
        public ComplianceFramework $framework,
        public string $version,
        public \DateTimeImmutable $effectiveDate,
        public array $requirements = []
    ) {}
}
```

---

Enums
-----

[](#enums)

### `StatementType`

[](#statementtype)

```
enum StatementType: string
{
    case BALANCE_SHEET = 'balance_sheet';
    case INCOME_STATEMENT = 'income_statement';
    case CASH_FLOW = 'cash_flow';
    case CHANGES_IN_EQUITY = 'changes_in_equity';
    case NOTES = 'notes';
    case TRIAL_BALANCE = 'trial_balance';
}
```

### `StatementFormat`

[](#statementformat)

```
enum StatementFormat: string
{
    case PDF = 'pdf';
    case EXCEL = 'excel';
    case HTML = 'html';
    case JSON = 'json';
    case CSV = 'csv';
}
```

### `AccountCategory`

[](#accountcategory)

```
enum AccountCategory: string
{
    case ASSET = 'asset';
    case LIABILITY = 'liability';
    case EQUITY = 'equity';
    case REVENUE = 'revenue';
    case EXPENSE = 'expense';
}
```

### `CashFlowMethod`

[](#cashflowmethod)

```
enum CashFlowMethod: string
{
    case DIRECT = 'direct';
    case INDIRECT = 'indirect';
}
```

### `ComplianceFramework`

[](#complianceframework)

```
enum ComplianceFramework: string
{
    case GAAP = 'gaap';
    case IFRS = 'ifrs';
    case LOCAL = 'local';
    case CUSTOM = 'custom';
}
```

---

Services
--------

[](#services)

### `StatementValidator`

[](#statementvalidator)

Validates statement integrity:

- Balance Sheet: Assets = Liabilities + Equity
- Trial Balance: Debits = Credits
- Cash Flow: Beginning + Changes = Ending

### `SectionGrouper`

[](#sectiongrouper)

Groups account balances into statement sections based on account categories and template definitions.

### `ComplianceChecker`

[](#compliancechecker)

Verifies statements meet compliance framework requirements:

- Required sections present
- Required disclosures included
- Proper account classifications

---

Layouts
-------

[](#layouts)

Pre-built compliance layouts:

- `GaapBalanceSheetLayout` - US GAAP balance sheet format
- `GaapIncomeStatementLayout` - US GAAP income statement format
- `IfrsBalanceSheetLayout` - IFRS balance sheet format
- `IfrsIncomeStatementLayout` - IFRS income statement format

---

Exceptions
----------

[](#exceptions)

ExceptionWhen Thrown`StatementImbalanceException`Balance sheet doesn't balance (A ≠ L + E)`InvalidLineItemException`Line item data is invalid`InvalidSectionException`Section configuration is invalid`TemplateNotFoundException`Requested compliance template not found---

Usage Example
-------------

[](#usage-example)

```
use Nexus\FinancialStatements\Contracts\StatementBuilderInterface;
use Nexus\FinancialStatements\Contracts\StatementDataProviderInterface;
use Nexus\FinancialStatements\Enums\StatementType;
use Nexus\FinancialStatements\Enums\ComplianceFramework;
use Nexus\FinancialStatements\ValueObjects\StatementPeriod;

final readonly class BalanceSheetGenerator
{
    public function __construct(
        private StatementBuilderInterface $builder,
        private StatementDataProviderInterface $dataProvider
    ) {}

    public function generate(string $tenantId, string $periodId): BalanceSheet
    {
        // Get account balances from consuming application
        $balances = $this->dataProvider->getAccountBalances(
            $tenantId,
            $periodId,
            new \DateTimeImmutable()
        );

        // Define the reporting period
        $period = new StatementPeriod(
            periodId: $periodId,
            startDate: new \DateTimeImmutable('2024-01-01'),
            endDate: new \DateTimeImmutable('2024-12-31'),
            periodName: 'FY 2024'
        );

        // Build the balance sheet
        return $this->builder->build(
            type: StatementType::BALANCE_SHEET,
            balances: $balances,
            period: $period,
            framework: ComplianceFramework::IFRS
        );
    }
}
```

---

Integration with Other Packages
-------------------------------

[](#integration-with-other-packages)

PackageIntegration`Nexus\Finance`Provides account balances via `StatementDataProviderInterface``Nexus\Period`Provides period information`Nexus\AccountPeriodClose`Triggers statement generation on period close`Nexus\Export`Implements `StatementExportAdapterInterface``Nexus\AuditLogger`Logs statement generation events---

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

[](#related-documentation)

- [ARCHITECTURE.md](../../ARCHITECTURE.md) - Overall system architecture
- [CODING\_GUIDELINES.md](../../CODING_GUIDELINES.md) - Coding standards
- [Nexus Packages Reference](../../docs/NEXUS_PACKAGES_REFERENCE.md) - All available packages

---

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

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 (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-financial-statements/health.svg)

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

###  Alternatives

[ziming/laravel-zxcvbn

Zxcvbn Password validation rule for Laravel

3064.3k](/packages/ziming-laravel-zxcvbn)

PHPackages © 2026

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