PHPackages                             azaharizaman/nexus-procurement - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-procurement

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-procurement
==============================

Framework-agnostic procurement management package for purchase requisitions, purchase orders, goods receipts, and 3-way matching

v0.1.0-alpha1(1mo ago)02↓100%2MITPHPPHP ^8.2

Since May 5Pushed 1mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (2)

Nexus\\Procurement
==================

[](#nexusprocurement)

**Framework-agnostic procurement management package for Nexus ERP**

The Procurement package provides a comprehensive, pure PHP solution for purchase requisitions, purchase orders, goods receipts, 3-way matching, and vendor quote management. It follows strict contract-driven design principles and integrates seamlessly with the Nexus monorepo architecture.

Features
--------

[](#features)

- ✅ **Pure PHP 8.3+** - No framework dependencies in core logic
- ✅ **Contract-Driven** - All data structures and operations defined via interfaces
- ✅ **Purchase Requisition Management** - Complete workflow from draft to approval to PO conversion
- ✅ **Purchase Order Processing** - Create POs from requisitions or directly with budget validation
- ✅ **Goods Receipt Notes (GRN)** - Record and validate received goods against purchase orders
- ✅ **3-Way Matching Engine** - Validate Invoice-PO-GRN alignment (&lt;500ms for 100 lines)
- ✅ **Vendor Quote Management** - RFQ process and quote comparison
- ✅ **Segregation of Duties** - Requester ≠ Approver ≠ Receiver ≠ Payment Authorizer
- ✅ **Budget Controls** - PO cannot exceed requisition by &gt;10% without re-approval
- ✅ **Multi-Tenant** - Tenant-scoped requisitions, POs, and GRNs

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

[](#installation)

```
composer require azaharizaman/nexus-procurement:"*@dev"
```

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

[](#architecture)

### Package Structure

[](#package-structure)

```
packages/Procurement/
├── src/
│   ├── Contracts/              # 19 Interfaces
│   │   ├── ProcurementManagerInterface.php
│   │   ├── RequisitionInterface.php
│   │   ├── RequisitionLineInterface.php
│   │   ├── RequisitionRepositoryInterface.php
│   │   ├── PurchaseOrderInterface.php
│   │   ├── PurchaseOrderLineInterface.php
│   │   ├── PurchaseOrderRepositoryInterface.php
│   │   ├── GoodsReceiptNoteInterface.php
│   │   ├── GoodsReceiptLineInterface.php
│   │   ├── GoodsReceiptRepositoryInterface.php
│   │   ├── VendorQuoteInterface.php
│   │   ├── VendorQuoteRepositoryInterface.php
│   │   └── ... (7 analytics repository interfaces)
│   ├── Services/               # 6 Business Logic Services
│   │   ├── ProcurementManager.php
│   │   ├── RequisitionManager.php
│   │   ├── PurchaseOrderManager.php
│   │   ├── GoodsReceiptManager.php
│   │   ├── MatchingEngine.php
│   │   └── VendorQuoteManager.php
│   └── Exceptions/             # 10 Domain Exceptions
│       ├── ProcurementException.php
│       ├── RequisitionNotFoundException.php
│       ├── PurchaseOrderNotFoundException.php
│       ├── GoodsReceiptNotFoundException.php
│       ├── InvalidRequisitionDataException.php
│       ├── InvalidRequisitionStateException.php
│       ├── InvalidPurchaseOrderDataException.php
│       ├── InvalidGoodsReceiptDataException.php
│       ├── BudgetExceededException.php
│       └── UnauthorizedApprovalException.php
├── composer.json
├── LICENSE
└── README.md

```

### Core Principles

[](#core-principles)

1. **Logic in Packages, Implementation in Applications**

    - Package defines **what** (interfaces, services, value objects)
    - Application defines **how** (Eloquent models, repositories, migrations)
2. **Framework Agnostic**

    - Zero Laravel dependencies in `src/`
    - No `Illuminate\*` classes
    - No Eloquent models
    - No database queries
3. **Dependency Injection**

    - Constructor injection for all dependencies
    - Interface-based dependencies only

Usage Examples
--------------

[](#usage-examples)

### Create Purchase Requisition

[](#create-purchase-requisition)

```
use Nexus\Procurement\Contracts\ProcurementManagerInterface;

$procurement = app(ProcurementManagerInterface::class);

$requisition = $procurement->createRequisition(
    tenantId: 'tenant-001',
    requesterId: 'user-123',
    data: [
        'number' => 'REQ-2025-001',
        'description' => 'Office supplies for Q1',
        'department' => 'Administration',
        'lines' => [
            [
                'item_code' => 'PAPER-A4',
                'description' => 'A4 Paper 500 sheets',
                'quantity' => 10,
                'unit' => 'box',
                'estimated_unit_price' => 25.00,
            ],
        ],
    ]
);
```

### Approve Requisition (with Segregation of Duties)

[](#approve-requisition-with-segregation-of-duties)

```
use Nexus\Procurement\Exceptions\UnauthorizedApprovalException;

try {
    $approvedRequisition = $procurement->approveRequisition(
        requisitionId: $requisition->getId(),
        approverId: 'manager-456' // Must NOT be the requester
    );
} catch (UnauthorizedApprovalException $e) {
    // BUS-PRO-0095 violation: Requester tried to approve own requisition
}
```

### Convert Requisition to Purchase Order

[](#convert-requisition-to-purchase-order)

```
use Nexus\Procurement\Exceptions\BudgetExceededException;

try {
    $po = $procurement->convertRequisitionToPO(
        tenantId: 'tenant-001',
        requisitionId: $requisition->getId(),
        creatorId: 'buyer-789',
        poData: [
            'number' => 'PO-2025-001',
            'vendor_id' => 'vendor-xyz',
            'lines' => [
                [
                    'requisition_line_id' => $requisition->getLines()[0]->getId(),
                    'quantity' => 10,
                    'unit_price' => 24.50, // Within 10% of estimate
                    'unit' => 'box',
                    'item_code' => 'PAPER-A4',
                    'description' => 'A4 Paper 500 sheets',
                ],
            ],
        ]
    );
} catch (BudgetExceededException $e) {
    // PO exceeds requisition by more than 10%
}
```

### Record Goods Receipt

[](#record-goods-receipt)

```
$grn = $procurement->recordGoodsReceipt(
    tenantId: 'tenant-001',
    poId: $po->getId(),
    receiverId: 'warehouse-clerk-001', // Must NOT be PO creator
    receiptData: [
        'number' => 'GRN-2025-001',
        'received_date' => '2025-11-20',
        'lines' => [
            [
                'po_line_reference' => 'PO-2025-001-L001',
                'quantity_received' => 10, // Cannot exceed PO quantity
                'unit' => 'box',
            ],
        ],
    ]
);
```

### Three-Way Matching

[](#three-way-matching)

```
$matchResult = $procurement->performThreeWayMatch(
    poLine: $poLine,
    grnLine: $grnLine,
    invoiceLineData: [
        'quantity' => 10,
        'unit_price' => 24.50,
        'line_total' => 245.00,
    ]
);

if ($matchResult['matched']) {
    echo "✅ Auto-approved: {$matchResult['recommendation']}";
} else {
    echo "⚠️  Manual review: {$matchResult['recommendation']}";
    print_r($matchResult['discrepancies']);
}
```

Business Rules
--------------

[](#business-rules)

Integration Points
------------------

[](#integration-points)

- **Nexus\\Payable**: Provides PO and GRN data for 3-way matching and handles vendor bill payments
- **Nexus\\Inventory**: Manages stock levels, which are updated upon successful goods receipt
- **Nexus\\Finance**: Receives journal entries for all procurement-related financial events
- **Nexus\\Budget**: Provides budget data for validation against requisitions and purchase orders
- **Nexus\\Workflow**: Requisition approval workflows and multi-step approval processes
- **Nexus\\Uom**: Unit of measurement validation
- **Nexus\\Currency**: Multi-currency support
- **Nexus\\AuditLogger**: Comprehensive change tracking
- **Nexus\\Sequencing**: Auto-numbering for REQ/PO/GRN

Exception Handling
------------------

[](#exception-handling)

All domain exceptions extend `ProcurementException`:

```
use Nexus\Procurement\Exceptions\{
    RequisitionNotFoundException,
    PurchaseOrderNotFoundException,
    GoodsReceiptNotFoundException,
    InvalidRequisitionDataException,
    InvalidRequisitionStateException,
    InvalidPurchaseOrderDataException,
    InvalidGoodsReceiptDataException,
    BudgetExceededException,
    UnauthorizedApprovalException
};

try {
    $requisition = $procurement->getRequisition($requisitionId);
} catch (RequisitionNotFoundException $e) {
    // Handle requisition not found
}

try {
    $approved = $procurement->approveRequisition($id, $approverId);
} catch (UnauthorizedApprovalException $e) {
    // Handle unauthorized approval attempt
}
```

Performance
-----------

[](#performance)

- **3-Way Matching**: &lt;500ms for 100-line invoices (PER-PRO-0341)
- **Requisition Creation**: &lt;200ms with eager loading
- **PO Generation**: &lt;300ms with budget validation

Requirements Addressed
----------------------

[](#requirements-addressed)

This package addresses all requirements in REQUIREMENTS.md:

- ✅ BUS-PRO-0041 to BUS-PRO-0124: 15 Business requirements
- ✅ FUN-PRO-0235 to FUN-PRO-0271: 7 Functional requirements
- ✅ PER-PRO-0327 to PER-PRO-0353: 5 Performance requirements
- ✅ REL-PRO-0389 to REL-PRO-0407: 4 Reliability requirements
- ✅ SEC-PRO-0441 to SEC-PRO-0470: 6 Security requirements
- ✅ USE-PRO-0508 to USE-PRO-0548: 7 User stories

**Total:** 44 requirements

Testing
-------

[](#testing)

Package tests use mocks for all repository implementations:

```
use Nexus\Procurement\Services\ProcurementManager;
use Nexus\Procurement\Contracts\RequisitionRepositoryInterface;
use PHPUnit\Framework\TestCase;

class ProcurementManagerTest extends TestCase
{
    public function test_create_requisition(): void
    {
        $mockRepo = $this->createMock(RequisitionRepositoryInterface::class);
        $mockRepo->expects($this->once())
            ->method('create')
            ->willReturn($this->createMock(RequisitionInterface::class));

        $manager = new ProcurementManager($mockRepo, ...);
        // ... test logic
    }
}
```

📖 Documentation
---------------

[](#-documentation)

### Package Documentation

[](#package-documentation)

- **[Getting Started Guide](docs/getting-started.md)** - Quick start guide with prerequisites, core concepts, and first integration
- **[API Reference](docs/api-reference.md)** - Complete documentation of all 19 interfaces, 6 services, and 10 exceptions
- **[Integration Guide](docs/integration-guide.md)** - Laravel and Symfony integration examples with complete setup instructions
- **[Basic Usage Example](docs/examples/basic-usage.php)** - Simple usage patterns for requisitions, POs, and GRNs
- **[Advanced Usage Example](docs/examples/advanced-usage.php)** - Advanced scenarios including ML extractors and batch matching

### Additional Resources

[](#additional-resources)

- `IMPLEMENTATION_SUMMARY.md` - Implementation progress, metrics, and key design decisions
- `REQUIREMENTS.md` - All 44 requirements with status tracking
- `TEST_SUITE_SUMMARY.md` - Test coverage metrics and test inventory
- `VALUATION_MATRIX.md` - Package valuation metrics for funding assessment
- See root `../../ARCHITECTURE.md` for overall system architecture
- See `../../docs/NEXUS_PACKAGES_REFERENCE.md` for package ecosystem reference

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.7% 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 (472 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (141 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

515135.1M619](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8955.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M199](/packages/illuminate-broadcasting)

PHPackages © 2026

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