diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 6b8c66ab1..1d48ef5e3 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -37,7 +37,7 @@ class Accounts extends Controller // Handle transactions $transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->collect('paid_at'); - $transfers = Transfer::with('transaction')->all()->filter(function ($transfer) use($account) { + $transfers = Transfer::with('expense_transaction', 'income_transaction')->get()->filter(function ($transfer) use($account) { if ($transfer->expense_account->id == $account->id || $transfer->income_account->id == $account->id) { return true; } diff --git a/tests/Feature/Banking/AccountsTest.php b/tests/Feature/Banking/AccountsTest.php index 5469d63f5..2a5a8d203 100644 --- a/tests/Feature/Banking/AccountsTest.php +++ b/tests/Feature/Banking/AccountsTest.php @@ -82,6 +82,18 @@ class AccountsTest extends FeatureTestCase $this->assertSoftDeleted('accounts', $request); } + public function testItShouldShowAccount() + { + $request = $this->getRequest(); + + $account = $this->dispatch(new CreateAccount($request)); + + $this->loginAs() + ->get(route('accounts.show', $account->id)) + ->assertStatus(200) + ->assertSee($account->name); + } + public function getRequest() { return Account::factory()->enabled()->raw();