feat(currency): add Saudi Riyal (SAR) (#461)

## What

Adds Saudi Riyal (SAR) as a supported currency for both user primary
currency and account currency.

## Why

SAR is fully supported by the `@fawazahmed0/currency-api` conversion
backend (verified rates are returned), so it works end-to-end with the
existing conversion system.

## Changes

- `config/currencies.php`: add SAR with `allows_primary: true`,
`allows_account: true`
- Tests mirroring the BRL cases in `AccountTest` and `ProfileUpdateTest`

## Testing

- `php artisan test` on both settings test files — 32 passed
- `vendor/bin/pint --dirty` — clean
This commit is contained in:
Víctor Falcón 2026-06-01 08:52:21 +02:00 committed by GitHub
parent f9bf0ea5ff
commit a71626a350
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 0 deletions

View File

@ -122,6 +122,12 @@ return [
'allows_primary' => true,
'allows_account' => true,
],
[
'code' => 'SAR',
'name' => 'Saudi Riyal',
'allows_primary' => true,
'allows_account' => true,
],
[
'code' => 'BTC',
'name' => 'Bitcoin',

View File

@ -73,6 +73,8 @@ test('cashflow summary returns income, expense, net, and savings rate', function
});
test('cashflow analytics convert foreign currency transactions to user currency', function () {
$this->travelTo(now()->startOfMonth()->addDays(14));
$date = now()->startOfMonth()->addDays(4);
$from = $date->copy()->startOfMonth()->toDateString();
$to = $date->copy()->endOfMonth()->toDateString();

View File

@ -170,6 +170,25 @@ it('accepts Brazilian real when creating account', function () {
]);
});
it('accepts Saudi riyal when creating account', function () {
actingAs($this->user);
$response = $this->post(route('accounts.store'), [
'name' => 'Saudi Account',
'bank_id' => $this->bank->id,
'currency_code' => 'SAR',
'type' => AccountType::Checking->value,
]);
$response->assertRedirect();
assertDatabaseHas('accounts', [
'user_id' => $this->user->id,
'bank_id' => $this->bank->id,
'currency_code' => 'SAR',
]);
});
it('accepts bitcoin when creating account', function () {
actingAs($this->user);

View File

@ -91,6 +91,25 @@ test('profile accepts Brazilian real as primary currency', function () {
expect($user->refresh()->currency_code)->toBe('BRL');
});
test('profile accepts Saudi riyal as primary currency', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->patch(route('profile.update'), [
'name' => 'Test User',
'email' => 'test@example.com',
'currency_code' => 'SAR',
'month_start_day' => 1,
]);
$response
->assertSessionHasNoErrors()
->assertRedirect(route('account.edit'));
expect($user->refresh()->currency_code)->toBe('SAR');
});
test('profile rejects bitcoin as primary currency', function () {
$user = User::factory()->create();