phpvms/app/Traits
Nabeel Shahzad 290544cdd8
fix(finance): default the journal currency when settings are absent
A fresh install dies creating the first airline:

    App\Models\Airline::initJournal(): Argument #1 ($currency_code)
    must be of type string, null given

setting() returns its $default for a key it cannot read -- retrieve()
throws SettingNotFound and the helper swallows it -- and the created
hook passed no default, so it handed null to a string parameter. The
'USD' default on initJournal() cannot help: an explicit argument always
beats a declared default, even when that argument is null.

The installer creates the airline and user in the same step, and the
settings seed is gated on a separate wizard step, so units.currency is
not guaranteed to exist by then. Every other reader of this setting
already names the fallback -- Money.php:59,74 and
PirepFinanceService.php:57,61 -- so this is the odd one out.

Airline and User are the only models using the trait; both are covered.
The suite could not have caught this because tests/Pest.php seeds
SettingsSeeder before every test, making an empty settings table
unreachable, so the new tests clear it explicitly.
2026-07-26 00:46:42 -05:00
..
ExpensableTrait.php [8.x] Refactor models and tests for slug handling and resource consistency (#2191) 2026-05-03 11:38:30 -05:00
FilesTrait.php [8.x] Refactor models and tests for slug handling and resource consistency (#2191) 2026-05-03 11:38:30 -05:00
HasNanoIds.php Fix/admin links (#2250) 2026-07-01 13:39:09 -05:00
HasSlug.php [8.x] feature: upgrade to Laravel 13 (#2204) 2026-05-06 11:27:21 -05:00
JournalTrait.php fix(finance): default the journal currency when settings are absent 2026-07-26 00:46:42 -05:00