Add recurring transactions with monthly confirmation flow
New "Récurrences" section lets users define recurring depense/epargne models (name, category, default amount, day of month). Nothing is created automatically: from the day a recurrence is due, it appears as a pending proposal in Suivi (desktop + mobile) with an editable amount, so variable bills (electricity, etc.) can be adjusted before confirming. Dismissing a proposal skips it for the current month without creating a transaction, and it reappears the following month. - recurring_transactions table (household/category scoped, active flag, last_generated_year/month to prevent duplicate generation) - transactions.recurring_transaction_id nullable FK to trace origin - RecurringTransactionPolicy mirrors CategoryPolicy tenant scoping - 10 new Pest tests covering CRUD, tenant isolation, and the pending/confirm/dismiss lifecycle across month boundaries (travelTo) 58/58 tests pass, Pint clean, verified end-to-end against production data (test recurrence created and cleaned up). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
674c43afea
commit
b78c314569
@@ -44,4 +44,9 @@ class Household extends Model
|
||||
{
|
||||
return $this->hasMany(HouseholdInvite::class);
|
||||
}
|
||||
|
||||
public function recurringTransactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurringTransaction::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class RecurringTransaction extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'household_id', 'category_id', 'name', 'amount', 'day_of_month',
|
||||
'active', 'last_generated_year', 'last_generated_month',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'amount' => 'decimal:2',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function household(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Household::class);
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
public function wasGeneratedFor(int $year, int $month): bool
|
||||
{
|
||||
return $this->last_generated_year === $year && $this->last_generated_month === $month;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
protected $fillable = ['household_id', 'category_id', 'user_id', 'date', 'date_effective', 'amount', 'details'];
|
||||
protected $fillable = ['household_id', 'category_id', 'recurring_transaction_id', 'user_id', 'date', 'date_effective', 'amount', 'details'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user