PHP code example of azaharizaman / nexus-treasury

1. Go to this page and download the library: Download azaharizaman/nexus-treasury 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-treasury example snippets


use Nexus\Treasury\Services\TreasuryManager;
use Nexus\Treasury\ValueObjects\TreasuryPolicyData;

// Create policy data
$policyData = TreasuryPolicyData::fromArray([
    'name' => 'Corporate Treasury Policy',
    'description' => 'Main treasury policy for corporate operations',
    'minimum_cash_balance' => 100000.00,
    'minimum_cash_balance_currency' => 'USD',
    'maximum_single_transaction' => 500000.00,
    'maximum_single_transaction_currency' => 'USD',
    'approval_

use Nexus\Treasury\ValueObjects\AuthorizationLimit;

// Create an authorization limit for a user
$limit = new AuthorizationLimit(
    userId: 'user-123',
    roleId: null,
    amount: 25000.00,
    currency: 'USD',
    transactionType: 'payment'
);

$authLimit = $treasuryManager->createAuthorizationLimit($tenantId, $limit);

// Check if transaction 

// Submit a transaction for approval
$approval = $treasuryManager->submitForApproval(
    $tenantId,
    'payment',
    75000.00,
    'USD',
    'Vendor payment for services',
    'user-123'
);

// Get pending approvals for a user
$pendingApprovals = $treasuryManager->getPendingApprovals('approver-456');

// Approve the transaction
$approved = $treasuryManager->approveTransaction(
    $approval->getId(),
    'approver-456',
    'Approved - within budget'
);

// Or reject the transaction
$rejected = $treasuryManager->rejectTransaction(
    $approval->getId(),
    'approver-456',
    'Insufficient budget allocation'
);