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:
co-authored by
Claude Sonnet 5
parent
1b3906ade2
commit
5ef655d16f
@@ -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);
|
||||
});
|
||||
|
||||
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 {
|
||||
$user = User::factory()->create();
|
||||
$household = $user->currentHousehold;
|
||||
|
||||
Reference in New Issue
Block a user