From 4dec0ab7ca14e3100ee2b584a22b39f8cdf8e110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Fri, 29 May 2026 16:33:21 +0200 Subject: [PATCH] feat: add BRL currency support (#453) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Add BRL (Brazilian Real) to supported currency list (`config/currencies.php`), allowed as both primary and account currency. ## API compatibility - Verified `@fawazahmed0/currency-api` supports BRL in both directions (e.g. USD→BRL ≈ 5.05). No conversion changes needed. ## Tests - Added BRL account-creation test (`AccountTest.php`). - Added BRL primary-currency test (`ProfileUpdateTest.php`). - Both pass. --- config/currencies.php | 6 ++++++ tests/Feature/Settings/AccountTest.php | 19 +++++++++++++++++++ tests/Feature/Settings/ProfileUpdateTest.php | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/config/currencies.php b/config/currencies.php index 7da5b083..b66400f4 100644 --- a/config/currencies.php +++ b/config/currencies.php @@ -116,6 +116,12 @@ return [ 'allows_primary' => true, 'allows_account' => true, ], + [ + 'code' => 'BRL', + 'name' => 'Brazilian Real', + 'allows_primary' => true, + 'allows_account' => true, + ], [ 'code' => 'BTC', 'name' => 'Bitcoin', diff --git a/tests/Feature/Settings/AccountTest.php b/tests/Feature/Settings/AccountTest.php index 8bb26f79..790fc985 100644 --- a/tests/Feature/Settings/AccountTest.php +++ b/tests/Feature/Settings/AccountTest.php @@ -151,6 +151,25 @@ it('accepts Pakistani rupee when creating account', function () { ]); }); +it('accepts Brazilian real when creating account', function () { + actingAs($this->user); + + $response = $this->post(route('accounts.store'), [ + 'name' => 'Brazil Account', + 'bank_id' => $this->bank->id, + 'currency_code' => 'BRL', + 'type' => AccountType::Checking->value, + ]); + + $response->assertRedirect(); + + assertDatabaseHas('accounts', [ + 'user_id' => $this->user->id, + 'bank_id' => $this->bank->id, + 'currency_code' => 'BRL', + ]); +}); + 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 f1abc12a..de71c6bb 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -72,6 +72,25 @@ test('profile accepts Pakistani rupee as primary currency', function () { expect($user->refresh()->currency_code)->toBe('PKR'); }); +test('profile accepts Brazilian real 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' => 'BRL', + 'month_start_day' => 1, + ]); + + $response + ->assertSessionHasNoErrors() + ->assertRedirect(route('account.edit')); + + expect($user->refresh()->currency_code)->toBe('BRL'); +}); + test('profile rejects bitcoin as primary currency', function () { $user = User::factory()->create();