azaharizaman/nexus-budget 问题修复 & 功能扩展

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

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

azaharizaman/nexus-budget

Composer 安装命令:

composer require azaharizaman/nexus-budget

包简介

Financial budget management and control plane for Nexus ERP

README 文档

README

Enterprise-grade budget management and financial control plane for the Nexus ERP system.

Overview

The Nexus\Budget package provides comprehensive budget allocation, commitment tracking, variance analysis, and financial forecasting capabilities. It serves as the financial control layer that enforces spending limits across all ERP modules through event-driven integration.

Key Features

🎯 Core Capabilities

  • Budget Allocation: Multi-dimensional budgeting by department, project, GL account, or cost center
  • Dual-Currency Tracking: Full support for functional and reporting currencies with exchange rate snapshots
  • Line-Item Granularity: Precise commitment and actual tracking at the transaction line level
  • Hierarchical Budgets: Unlimited budget hierarchy for multi-year capital projects and organizational structures
  • Revenue Budget Support: Inverted variance logic for revenue targets

🔄 Event-Driven Integration

  • Automatic Encumbrance: Budget commitments on PO approval via Procurement package
  • Actual Recording: Automatic actual posting from Journal Entries via Finance package
  • Period Controls: Budget locking on period close via Period package
  • Workflow Approvals: Multi-level approval routing for overrides via Workflow package

📊 Advanced Analytics

  • Variance Analysis: Real-time variance calculation with revenue budget logic
  • Budget Forecasting: AI-powered predictions via Intelligence package integration
  • Performance Dashboards: Manager KPI scoring and department rankings
  • Utilization Alerts: Proactive notifications at configurable thresholds (50%, 75%, 90%)

🔐 Financial Controls

  • Zero-Based Budgeting: ZBB methodology support with mandatory justification
  • Rollover Policies: Configurable handling of unused funds (Expire, Auto-Roll, Require Approval)
  • Approval Hierarchies: Tiered approval levels (Manager, Director, CFO, Board)
  • Variance Investigations: Automated workflow triggers for significant variances
  • Budget Simulations: "What-if" scenario testing before commitment

Architecture

Framework Agnosticism

This package contains pure PHP logic and is completely framework-agnostic:

  • ✅ No Laravel dependencies in /src
  • ✅ All dependencies via contracts (interfaces)
  • ✅ Readonly constructor property promotion
  • ✅ Native PHP 8.3 enums with business logic
  • ✅ Immutable value objects
  • ✅ PSR-3 logging, PSR-14 event dispatching

Integration Points

Package Integration Purpose
Nexus\Period Fiscal period validation, period locking
Nexus\Finance Variance calculation from GL actuals
Nexus\Procurement PO commitment (encumbrance) tracking
Nexus\Workflow Multi-level approval routing
Nexus\Currency Dual-currency conversion and rate snapshots
Nexus\Party Organizational hierarchy consolidation
Nexus\Intelligence AI-powered overrun predictions
Nexus\Notifier Budget utilization alerts
Nexus\AuditLogger Complete audit trail
Nexus\Setting Configurable thresholds and policies

Installation

1. Add to Root Composer

{
    "repositories": [
        {
            "type": "path",
            "url": "./packages/Budget"
        }
    ]
}

2. Install Package

composer require azaharizaman/nexus-budget:"*@dev"

3. Register Service Provider (Laravel)

In apps/Atomy/config/app.php:

'providers' => [
    // ...
    App\Providers\BudgetServiceProvider::class,
],

4. Run Migrations

php artisan migrate

Core Concepts

Budget Allocation Formula

Available = Allocated - Committed - Actual
  • Allocated: Original budget amount approved for the period
  • Committed: PO encumbrances (funds reserved but not yet spent)
  • Actual: Posted journal entry amounts (actual spending)
  • Available: Remaining funds available for new commitments

Budget Types

  • Operational: Day-to-day operating expenses (Manager approval)
  • Capital: Long-term asset investments (CFO approval)
  • Project: Project-specific budgets (Director approval)
  • Revenue: Revenue targets with inverted variance logic (CFO approval)

Budgeting Methodologies

  • Incremental: Budget based on prior period with adjustments
  • Zero-Based (ZBB): Every expense requires justification from zero

Rollover Policies

Policy Behavior
Expire Unused funds zeroed at period end
Auto-Roll Automatic carry-forward to next period
Require Approval Workflow approval required for rollover

Quick Start

Create a Budget

use Nexus\Budget\Contracts\BudgetManagerInterface;
use Nexus\Budget\Enums\BudgetType;
use Nexus\Budget\Enums\BudgetingMethodology;
use Nexus\Budget\Enums\RolloverPolicy;
use Nexus\Uom\ValueObjects\Money;

$budgetManager = app(BudgetManagerInterface::class);

$budget = $budgetManager->createBudget([
    'period_id' => '01JCEXAMPLE',
    'department_id' => 'DEPT-001',
    'budget_type' => BudgetType::Operational,
    'budgeting_methodology' => BudgetingMethodology::Incremental,
    'rollover_policy' => RolloverPolicy::Expire,
    'allocated_amount' => Money::of(100000, 'MYR'),
    'functional_currency_code' => 'USD',
]);

Check Budget Availability

$result = $budgetManager->checkAvailability(
    budgetId: $budget->getId(),
    requestedAmount: Money::of(15000, 'MYR')
);

if ($result->isAvailable()) {
    echo "Budget available: " . $result->getAvailableAmount()->format();
} else {
    echo "Insufficient: " . $result->getShortfall()->format();
}

Commit Budget (Encumbrance)

use Nexus\Budget\Exceptions\BudgetExceededException;

try {
    $budgetManager->commitAmount(
        budgetId: $budget->getId(),
        amount: Money::of(5000, 'MYR'),
        accountId: 'ACC-5010', // GL Account
        sourceType: 'purchase_order_line',
        sourceId: 'PO-2024-001',
        sourceLineNumber: 1,
        costCenterId: 'CC-100'
    );
} catch (BudgetExceededException $e) {
    if ($e->requiresWorkflowApproval()) {
        // Trigger workflow approval
        $workflowId = $workflowAdapter->requestBudgetOverrideApproval(
            budgetId: $budget->getId(),
            requestedAmount: $e->getRequestedAmount(),
            requestorId: auth()->id(),
            reason: "Urgent procurement requirement"
        );
    }
}

Record Actual Spending

// Called automatically by JournalEntryPostedListener
$budgetManager->recordActual(
    budgetId: $budget->getId(),
    amount: Money::of(4850, 'MYR'),
    accountId: 'ACC-5010',
    sourceType: 'journal_entry_line',
    sourceId: 'JE-2024-056',
    sourceLineNumber: 3
);

Calculate Variance

$variance = $budgetManager->calculateVariance($budget->getId());

echo $variance->getStatusMessage();
// "Under budget: 50,150.00 MYR (50.15%)"

if ($variance->requiresInvestigation(threshold: 15.0)) {
    // Trigger investigation workflow
}

Transfer Budget Between Departments

$budgetManager->transferAllocation(
    fromBudgetId: 'BUDGET-DEPT-A',
    toBudgetId: 'BUDGET-DEPT-B',
    amount: Money::of(10000, 'MYR'),
    reason: 'Reallocation for project X'
);
// Requires workflow approval if configured

Configuration

Settings (via Nexus\Setting)

'budget.variance_analysis_period_count' => 6,           // Historical periods for burn rate
'budget.alert_threshold_percentage' => 85.0,            // Alert when utilization exceeds
'budget.investigation_threshold_percentage' => 15.0,    // Variance investigation trigger
'budget.workflow_threshold_amount' => 50000.00,         // Override approval threshold
'budget.workflow_manager_limit' => 10000.00,            // Manager approval limit
'budget.workflow_director_limit' => 50000.00,           // Director approval limit
'budget.realtime_po_check_threshold_pct' => 20.0,       // Real-time alert for large POs
'budget.notification_thresholds' => [50, 75, 90],       // Utilization alert tiers
'budget.max_hierarchy_depth' => 5,                      // Max budget nesting
'budget.simulation_expiration_days' => 30,              // Simulation auto-cleanup

Event Catalog

Published Events

  • BudgetCreatedEvent - New budget created
  • BudgetApprovedEvent - Budget approved
  • BudgetAllocatedEvent - Allocation amount set
  • BudgetCommittedEvent - Commitment recorded (includes utilization %)
  • BudgetActualRecordedEvent - Actual spending recorded
  • BudgetExceededEvent - Budget limit exceeded (for Notifier)
  • BudgetOverrideRequestedEvent - Override approval requested
  • BudgetReallocationRequestedEvent - Transfer approval requested
  • BudgetVarianceThresholdExceededEvent - Variance investigation needed
  • BudgetUtilizationAlertEvent - Utilization threshold crossed
  • BudgetLockedEvent - Budget locked for closed period

Subscribed Events

  • Nexus\Procurement\Events\PurchaseOrderApprovedEvent → Commit budget
  • Nexus\Procurement\Events\PurchaseOrderCancelledEvent → Release commitment
  • Nexus\Finance\Events\JournalEntryPostedEvent → Record actual
  • Nexus\Period\Events\PeriodClosedEvent → Lock budgets, process rollovers
  • Nexus\Workflow\Events\WorkflowApprovedEvent → Process approved overrides

API Reference

BudgetManagerInterface

createBudget(array $data): BudgetInterface
allocate(string $budgetId, Money $amount): void
commitAmount(string $budgetId, Money $amount, string $accountId, ...): void
releaseCommitment(string $budgetId, Money $amount, ...): void
recordActual(string $budgetId, Money $amount, ...): void
calculateVariance(string $budgetId): BudgetVariance
checkAvailability(string $budgetId, Money $requestedAmount): BudgetAvailabilityResult
lockBudget(string $budgetId): void
transferAllocation(string $fromBudgetId, string $toBudgetId, Money $amount, string $reason): void
amendBudget(string $budgetId, Money $newAmount, string $reason): void
createSimulation(string $baseBudgetId, array $modifications): BudgetInterface

BudgetAnalyticsRepositoryInterface

getConsolidatedBudget(string $parentDepartmentId, string $periodId): BudgetConsolidation
getBurnRateByDepartment(string $periodId): array
getVarianceTrends(string $budgetId, int $periodCount): array
getDepartmentRankings(string $periodId, int $limit): array
getManagerPerformanceScore(string $managerId, string $periodId): ManagerPerformanceScore
getUtilizationBreakdown(string $periodId): array

Testing

# Package tests (framework-agnostic)
vendor/bin/phpunit packages/Budget/tests

# Atomy integration tests
php artisan test --filter Budget

📖 Documentation

Package Documentation

Additional Resources

  • IMPLEMENTATION_SUMMARY.md - Implementation progress and metrics
  • REQUIREMENTS.md - Detailed requirements (45 requirements documented)
  • TEST_SUITE_SUMMARY.md - Test coverage and results
  • VALUATION_MATRIX.md - Package valuation metrics (estimated value: $599,035)
  • See root ARCHITECTURE.md for overall system architecture

License

MIT License - see LICENSE file for details.

Support

For questions or issues, please refer to the main Nexus documentation or contact the development team.

azaharizaman/nexus-budget 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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