PHP code example of azaharizaman / nexus-payable

1. Go to this page and download the library: Download azaharizaman/nexus-payable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

azaharizaman / nexus-payable example snippets


use Nexus\Payable\Contracts\PayableManagerInterface;

$payableManager = app(PayableManagerInterface::class);

// Create vendor with payment terms and tolerance
$vendor = $payableManager->createVendor([
    'code' => 'VEND-001',
    'name' => 'ABC Supplies Ltd',
    'payment_terms' => 'net_30',
    'qty_tolerance_percent' => 5.0,
    'price_tolerance_percent' => 2.0,
    'tax_id' => '12-3456789',
    'bank_details' => [
        'account_number' => '1234567890',
        'bank_name' => 'ABC Bank',
        'swift_code' => 'ABCMYKL'
    ]
]);

// Submit vendor bill for matching
$bill = $payableManager->submitBill([
    'vendor_id' => $vendor->getId(),
    'bill_number' => 'INV-2025-001',
    'bill_date' => '2025-11-20',
    'due_date' => '2025-12-20',
    'currency' => 'USD',
    'lines' => [
        [
            'description' => 'Office Supplies',
            'quantity' => 100,
            'unit_price' => 25.00,
            'gl_account' => '5100-10',
            'po_line_reference' => 'PO-2025-001-L1'
        ]
    ]
]);

use Nexus\Payable\Contracts\ThreeWayMatcherInterface;

$matcher = app(ThreeWayMatcherInterface::class);

// Perform matching against PO and GRN
$matchResult = $matcher->match($bill->getId());

if ($matchResult->isMatched()) {
    // Bill can be posted to GL
    $payableManager->postBillToGL($bill->getId());
} else {
    // Review variances manually
    $variances = $matchResult->getVariances();
}

// Schedule payment
$schedule = $payableManager->schedulePayment($bill->getId());

// Process payment and post to GL
$payment = $payableManager->processPayment($schedule->getId(), [
    'payment_date' => '2025-12-15',
    'payment_method' => 'bank_transfer',
    'bank_account' => '1000-01',
    'reference' => 'PAY-2025-001'
]);

src/
├── Contracts/              # 6 Interfaces
│   ├── PayableManagerInterface.php
│   ├── VendorRepositoryInterface.php
│   ├── VendorBillRepositoryInterface.php
│   ├── ThreeWayMatcherInterface.php
│   ├── PaymentSchedulerInterface.php
│   └── PaymentAllocationInterface.php
├── Services/               # Business logic
│   ├── PayableManager.php
│   ├── VendorManager.php
│   ├── BillProcessor.php
│   ├── MatchingEngine.php
│   ├── PaymentScheduler.php
│   └── PaymentProcessor.php
├── ValueObjects/           # Immutable domain objects
│   ├── VendorBillNumber.php
│   ├── PaymentTerm.php (enum)
│   ├── MatchingTolerance.php
│   ├── VendorStatus.php (enum)
│   ├── BillStatus.php (enum)
│   ├── MatchingStatus.php (enum)
│   └── PaymentStatus.php (enum)
└── Exceptions/             # Domain exceptions
    ├── PayableException.php (base)
    ├── VendorNotFoundException.php
    ├── BillNotFoundException.php
    ├── BillAlreadyMatchedException.php
    ├── MatchingToleranceExceededException.php
    ├── ThreeWayMatchFailedException.php
    ├── InvalidPaymentTermException.php
    ├── PaymentScheduleException.php
    └── InsufficientCreditException.php