diff --git a/config/currencies.php b/config/currencies.php index b66400f4..aef176a9 100644 --- a/config/currencies.php +++ b/config/currencies.php @@ -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', diff --git a/tests/Feature/CashflowAnalyticsTest.php b/tests/Feature/CashflowAnalyticsTest.php index 4eda19bb..4e9e0c23 100644 --- a/tests/Feature/CashflowAnalyticsTest.php +++ b/tests/Feature/CashflowAnalyticsTest.php @@ -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(); diff --git a/tests/Feature/Settings/AccountTest.php b/tests/Feature/Settings/AccountTest.php index 790fc985..52131aae 100644 --- a/tests/Feature/Settings/AccountTest.php +++ b/tests/Feature/Settings/AccountTest.php @@ -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); diff --git a/tests/Feature/Settings/ProfileUpdateTest.php b/tests/Feature/Settings/ProfileUpdateTest.php index de71c6bb..479c7c35 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -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();