PHP code example of azaharizaman / nexus-journal-entry
1. Go to this page and download the library: Download azaharizaman/nexus-journal-entry 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-journal-entry example snippets
use Nexus\JournalEntry\ValueObjects\ExchangeRate;
$rate = new ExchangeRate('USD', 'MYR', '4.7500', new DateTimeImmutable());
$converted = $rate->convert(Money::of('100.0000', 'USD'));
// Account validation during posting
$account = $accountQuery->find($line->getAccountId());
if (!$account->isPostable()) {
throw new InvalidAccountException('Cannot post to header account');
}
if (!$account->isActive()) {
throw new InvalidAccountException('Account is inactive');
}
// Validate posting date is in open period
if (!$periodValidator->isOpen($entry->getPostingDate())) {
throw new PeriodClosedException('Cannot post to closed period');
}
// Generate next number via sequencing integration
$number = $sequencing->getNext('journal_entry');