Show remaining budget in mobile category buttons
Each category button now displays "X € restants" below the name, alongside the existing progress gauge and percentage — so the user sees both how much of the budget is used and how much is left without leaving the entry form. Remaining is floored at 0 to match the gauge's 100% cap. categoryProgress now returns a ['pct', 'remaining'] pair per category instead of a bare percentage; tests updated accordingly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
613220f43a
commit
1b3906ade2
@@ -184,7 +184,7 @@ it('shows the recurrence again the following month after being confirmed', funct
|
||||
expect($component->viewData('pendingRecurrences')->pluck('id'))->toContain($recurring->id);
|
||||
});
|
||||
|
||||
it('computes the percentage of budget already tracked for a category this month', function (): void {
|
||||
it('computes the percentage and remaining budget already tracked for a category this month', function (): void {
|
||||
$this->travelTo(now()->setDate(2026, 3, 10));
|
||||
|
||||
$user = User::factory()->create();
|
||||
@@ -198,11 +198,13 @@ it('computes the percentage of budget already tracked for a category this month'
|
||||
]);
|
||||
|
||||
$component = Livewire::actingAs($user)->test(Index::class);
|
||||
$progress = $component->viewData('categoryProgress')[$category->id];
|
||||
|
||||
expect($component->viewData('categoryProgress')[$category->id])->toBe(60.0);
|
||||
expect($progress['pct'])->toBe(60.0);
|
||||
expect($progress['remaining'])->toBe(400.0);
|
||||
});
|
||||
|
||||
it('caps the category progress percentage at 100', function (): void {
|
||||
it('caps the category progress percentage at 100 and floors remaining at 0', function (): void {
|
||||
$this->travelTo(now()->setDate(2026, 3, 10));
|
||||
|
||||
$user = User::factory()->create();
|
||||
@@ -216,8 +218,10 @@ it('caps the category progress percentage at 100', function (): void {
|
||||
]);
|
||||
|
||||
$component = Livewire::actingAs($user)->test(Index::class);
|
||||
$progress = $component->viewData('categoryProgress')[$category->id];
|
||||
|
||||
expect($component->viewData('categoryProgress')[$category->id])->toBe(100);
|
||||
expect($progress['pct'])->toBe(100);
|
||||
expect($progress['remaining'])->toBe(0);
|
||||
});
|
||||
|
||||
it('returns no progress for a category without a budget defined', function (): void {
|
||||
|
||||
Reference in New Issue
Block a user