Add "reste à dépenser" tile to the dashboard

Shows the total remaining depense budget for the selected period,
above the breakdown table — reuses the totals.reste figure already
computed per section, no new query.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jeremy bayse
2026-07-26 13:41:48 +02:00
co-authored by Claude Sonnet 5
parent 1b3906ade2
commit 5ef655d16f
2 changed files with 28 additions and 0 deletions
@@ -22,6 +22,11 @@
</div> </div>
</div> </div>
<div class="bg-surface shadow rounded-lg p-4 max-w-xs">
<p class="text-xs text-text-muted">Reste à dépenser</p>
<p class="mt-1 text-lg font-semibold text-negative">{{ number_format($sections['depense']['totals']['reste'], 2, ',', ' ') }} </p>
</div>
@php @php
$colors = [ $colors = [
'revenu' => ['bg' => 'bg-positive-fill', 'row' => 'bg-positive-surface/40'], 'revenu' => ['bg' => 'bg-positive-fill', 'row' => 'bg-positive-surface/40'],
+23
View File
@@ -50,6 +50,29 @@ it('filters tracked and budget to a single month when a period is selected', fun
expect($sections['depense']['totals']['budget'])->toBe(270.0); expect($sections['depense']['totals']['budget'])->toBe(270.0);
}); });
it('computes the remaining depense budget total for the tile', function (): void {
$user = User::factory()->create();
$household = $user->currentHousehold;
$loyer = $household->categories()->create(['name' => 'Loyer', 'type' => 'depense', 'position' => 1]);
$courses = $household->categories()->create(['name' => 'Courses', 'type' => 'depense', 'position' => 2]);
$loyer->budgetLines()->create(['household_id' => $household->id, 'year' => 2026, 'month' => null, 'amount' => 1000]);
$courses->budgetLines()->create(['household_id' => $household->id, 'year' => 2026, 'month' => null, 'amount' => 400]);
$household->transactions()->create([
'category_id' => $loyer->id, 'user_id' => $user->id,
'date' => '2026-03-05', 'date_effective' => '2026-03-05', 'amount' => 1000,
]);
$household->transactions()->create([
'category_id' => $courses->id, 'user_id' => $user->id,
'date' => '2026-03-05', 'date_effective' => '2026-03-05', 'amount' => 150,
]);
$component = Livewire::actingAs($user)->test(Index::class)->set('year', 2026)->set('period', '3');
expect($component->viewData('sections')['depense']['totals']['reste'])->toBe(250.0);
});
it('excludes zero-tracked categories from chart data and caps it at 6', function (): void { it('excludes zero-tracked categories from chart data and caps it at 6', function (): void {
$user = User::factory()->create(); $user = User::factory()->create();
$household = $user->currentHousehold; $household = $user->currentHousehold;