PHP code example of azaharizaman / nexus-period

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


use Nexus\Period\Services\PeriodManager;
use Nexus\Period\Enums\PeriodType;

// Check if posting is allowed for a specific date
$canPost = $periodManager->isPostingAllowed(
    new \DateTimeImmutable('2024-11-15'),
    PeriodType::Accounting
);

// Close the current accounting period
$periodManager->closePeriod(
    $periodId,
    'Monthly close for October 2024',
    $userId
);

// Lock a closed period (prevents any further changes)
$periodManager->lockPeriod(
    $periodId,
    'Year-end finalization',
    $userId
);

// Lock all periods in a fiscal year
$lockedCount = $periodManager->lockFiscalYear(
    '2024',
    PeriodType::Accounting,
    'Annual audit completed',
    $userId
);

// Get all periods for a fiscal year
$periods = $periodManager->getPeriodsForFiscalYear('2024', PeriodType::Accounting);

// Unlock a locked period (exceptional case,