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:
parent
f9bf0ea5ff
commit
a71626a350
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue