azaharizaman / nexus-cash-management
Atomic package for managing bank accounts, bank statement imports, cash reconciliation, and liquidity forecasting
Package info
github.com/azaharizaman/nexus-cash-management
pkg:composer/azaharizaman/nexus-cash-management
Requires
- php: ^8.3
- azaharizaman/nexus-accounting: dev-main
- psr/log: ^3.0
Requires (Dev)
- azaharizaman/nexus-machine-learning: dev-main
- azaharizaman/nexus-query-engine: dev-main
- phpunit/phpunit: ^11.0
Suggests
- azaharizaman/nexus-currency: dev-main
- azaharizaman/nexus-import: dev-main
- azaharizaman/nexus-payable: dev-main
- azaharizaman/nexus-period: dev-main
- azaharizaman/nexus-receivable: dev-main
- azaharizaman/nexus-sequencing: dev-main
- azaharizaman/nexus-setting: dev-main
- azaharizaman/nexus-workflow: dev-main
This package is auto-updated.
Last update: 2026-05-05 02:37:45 UTC
README
Atomic, stateless package for managing bank accounts, bank statement imports, cash reconciliation, and liquidity forecasting—strictly decoupled from GL ownership.
Overview
The Nexus\CashManagement package provides comprehensive cash and bank account management capabilities within the Nexus ERP ecosystem. It focuses on:
- Bank Account Management: Master data for company bank accounts with multi-currency support
- Statement Import: Configurable CSV import with duplicate detection and validation
- Automatic Reconciliation: AI-assisted matching of bank transactions to ERP records (Payments, Receipts, GL entries)
- Manual Reconciliation: Review and approval workflow for unmatched transactions
- Cash Flow Forecasting: Deterministic and AI-powered multi-scenario forecasting
- Cash Position Tracking: Real-time cash position across all bank accounts
Core Philosophy
Strict Decoupling
This package adheres to the "Logic in Packages, Implementation in Applications" principle:
- Framework-Agnostic: Pure PHP with zero Laravel dependencies
- Contract-Driven: All dependencies expressed via interfaces
- Stateless Operations: No GL posting—only reconciliation and classification
- Integration via Events: Consumes
Nexus\Importevents for statement data
Separation of Concerns
Nexus\Import → Parses CSV files → Emits StatementLineDTO[]
Nexus\CashManagement → Consumes DTOs → Creates BankStatement entities → Matches transactions
Nexus\Finance → Receives post commands → Creates Journal Entries
Architecture
Key Design Decisions
- AuditLogger for Timeline (V1): All reconciliation events logged for user-facing timeline
- EventStream Optional (V2): Available for large enterprises requiring SOX compliance and temporal queries
- Manual GL Posting: Reconciliation engine creates
PendingAdjustmententities; user manually posts to GL - Auto-Reversal: Rejected pending adjustments automatically reverse payment applications via workflow
- AI Governance: Model versioning tracked in
PendingAdjustmentfor explainability
Integration Points
Nexus\Finance: GL account validation, journal entry postingNexus\Receivable: Payment application matching and reversalNexus\Payable: Payment matching for outflowsNexus\Period: Period validation for transaction datesNexus\Currency: Multi-currency exchange rates (V2)Nexus\Sequencing: Auto-numbering for statements and reconciliationsNexus\Import: CSV file parsing and standardizationNexus\Setting: Feature flags and configurationNexus\Workflow: High-value variance escalation and reversal approvalNexus\Intelligence(optional): AI-powered classification and forecastingNexus\QueryEngine(optional): Cash Conversion Cycle and bank fee analysis
Features
Bank Account Management
$bankAccount = $cashManager->createBankAccount( tenantId: $tenantId, accountCode: '1000-01', glAccountId: $glAccountId, accountNumber: '1234567890', bankName: 'Maybank', bankCode: 'MBB', accountType: BankAccountType::CHECKING, currency: 'MYR', csvImportConfig: [ 'date_column' => 'Transaction Date', 'description_column' => 'Description', 'debit_column' => 'Debit', 'credit_column' => 'Credit', 'balance_column' => 'Balance' ] );
Statement Import
// Import via Nexus\Import package (emits FileImportedEvent) // BankStatementImportedListener consumes event and creates entities $result = $cashManager->reconcileStatement($statementId); echo "Matched: {$result->getMatchedCount()}\n"; echo "Unmatched: {$result->getUnmatchedCount()}\n";
Cash Flow Forecasting
$parameters = ScenarioParametersVO::fromScenarioType( ForecastScenarioType::BASELINE, horizonDays: 90 ); $forecast = $cashFlowForecaster->forecast($tenantId, $parameters); if ($forecast->hasNegativeBalance()) { // Alert: Liquidity risk detected }
Pending Adjustment Posting
// User reviews unmatched transaction $cashManager->postPendingAdjustment( pendingAdjustmentId: $adjustmentId, glAccount: '6200', // Bank Fees Expense postedBy: $userId ); // If user rejects (wrong match): $cashManager->rejectPendingAdjustment( pendingAdjustmentId: $adjustmentId, reason: 'Incorrect match - customer deposit', rejectedBy: $userId ); // Triggers automatic payment application reversal + GL workflow
Value Objects
BankAccountNumber: Validated bank account with IBAN/SWIFT supportStatementPeriod: Date range with overlap detectionReconciliationTolerance: Amount/date variance thresholdsCashPosition: Point-in-time balance snapshotCSVColumnMapping: Import configurationScenarioParametersVO: Forecast scenario parametersForecastResultVO: Persistable forecast outputStatementHash: Cryptographic deduplicationAIModelVersion: Semantic versioning for AI models
Enums
BankAccountType: CHECKING, SAVINGS, CREDIT_CARD, MONEY_MARKET, LINE_OF_CREDITBankAccountStatus: ACTIVE, INACTIVE, CLOSED, SUSPENDEDBankTransactionType: DEPOSIT, WITHDRAWAL, TRANSFER, FEE, INTEREST, etc.ReconciliationStatus: PENDING, MATCHED, VARIANCE_REVIEW, RECONCILED, UNMATCHED, REJECTEDMatchingConfidence: HIGH, MEDIUM, LOW, MANUALForecastScenarioType: OPTIMISTIC, BASELINE, PESSIMISTIC, CUSTOM
Exceptions
BankAccountNotFoundExceptionDuplicateStatementExceptionPartialOverlapExceptionReconciliationExceptionReversalRequiredExceptionInvalidStatementFormatExceptionUnmatchedTransactionsException
Multi-Currency Support (V2)
The package schema is V2-ready with nullable columns:
transaction_currencyexchange_ratefunctional_amount
Multi-currency activation requires:
$featureManager->isEnabled('multi_currency_banking')
Dependencies
azaharizaman/nexus-finance- GL integrationazaharizaman/nexus-receivable- Payment applicationazaharizaman/nexus-payable- Payment matchingazaharizaman/nexus-period- Period validationazaharizaman/nexus-currency- Exchange ratesazaharizaman/nexus-sequencing- Auto-numberingazaharizaman/nexus-import- Statement parsingazaharizaman/nexus-setting- Configurationazaharizaman/nexus-workflow- Approval processes
Optional Dependencies
azaharizaman/nexus-intelligence- AI classification/forecastingazaharizaman/nexus-query-engine- KPI calculation
Installation
composer require azaharizaman/nexus-cash-management:"*@dev"
📖 Documentation
Package Documentation
- Getting Started Guide - Quick start guide with prerequisites, concepts, and first integration
- API Reference - Complete documentation of all interfaces, value objects, enums, and exceptions
- Integration Guide - Laravel and Symfony integration examples with complete setup
- Basic Usage Example - Import statement, auto-reconcile, approve/reject adjustments
- Advanced Usage Example - Cash flow forecasting, AI feedback, high-value workflows, multi-currency
Additional Resources
IMPLEMENTATION_SUMMARY.md- Implementation progress, metrics, and architecture detailsREQUIREMENTS.md- Detailed requirements (58 requirements, 96.6% complete)TEST_SUITE_SUMMARY.md- Test coverage strategy and recommendationsVALUATION_MATRIX.md- Package valuation metrics ($140,576 estimated value)- See root
ARCHITECTURE.mdfor overall system architecture
License
MIT License. See LICENSE file for details.