whisper-money/tests/Feature
Víctor Falcón cc666a3111 test: Fix Carbon month overflow in date calculations (#87)
## Summary
- Replace `subMonths()` with `subMonthsNoOverflow()` across controllers,
commands, and tests to prevent date overflow on months with 31 days
- On Jan 31, `subMonths(2)` overflows: Nov 31 doesn't exist → Carbon
rolls forward to Dec 1, producing wrong date ranges and off-by-one month
counts

## Root cause
Carbon's `subMonths()` allows day overflow. When the target month has
fewer days than the source date, it rolls into the next month. For
example:
- `2026-01-31 subMonths(2)` → Nov 31 → **2025-12-01** (expected Nov 30)
- `2026-01-31 subMonths(11)` → Feb 31 → **2025-03-03** (expected Feb 28)

`subMonthsNoOverflow()` clamps to the last valid day of the target month
instead.

## Files changed
- `app/Http/Controllers/Api/CashflowAnalyticsController.php` — cashflow
trend start date calculation
- `app/Console/Commands/ResetDemoAccountCommand.php` — balance history
date generation (was causing duplicate `balance_date` entries)
- `tests/Feature/AccountControllerTest.php` — balance evolution `from`
param
- `tests/Feature/CashflowAnalyticsTest.php` — transaction date
generation in loop
- `tests/Feature/DashboardAnalyticsTest.php` — net worth evolution
`from` param

## Test plan
- [x] `account balance evolution returns data` — expects 3 months, was
getting 2
- [x] `cashflow trend returns monthly data` — expects 3 months, was
getting 2
- [x] `cashflow trend defaults to 12 months` — expects 12 months, was
getting 11
- [x] `net worth evolution returns monthly data points` — expects 3
months, was getting 2
- [x] `demo:reset creates demo user` — was throwing
UniqueConstraintViolation on duplicate balance dates
2026-02-01 11:33:09 +01:00
..
Auth feat(queue): Implement queueable email jobs with rate limiting 2025-12-30 07:22:18 +01:00
Console test: Improve demo reset tests performance 2026-01-22 10:24:07 +01:00
Jobs/Drip Add subscription cancellation email with manual trigger command (#47) 2025-12-30 20:32:44 +01:00
Listeners feat: Sync new users to Resend contacts (#85) 2026-01-28 21:25:58 +01:00
Onboarding User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
Settings Add currency selection to user profile settings (#41) 2025-12-30 07:22:19 +01:00
Sync refactor: Simplify transaction endpoints architecture (#76) 2026-01-25 16:15:17 +01:00
AccountBalanceControllerTest.php Accounts: new pages to list, and see account details (#13) 2025-12-05 14:33:18 +01:00
AccountControllerTest.php test: Fix Carbon month overflow in date calculations (#87) 2026-02-01 11:33:09 +01:00
AutomationRuleTest.php chore: Simplify IndexedDB sync by moving to Inertia shared props (#63) 2026-01-19 19:15:26 +01:00
BudgetFeatureFlagTest.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
BudgetHistoricalAssignmentTest.php feat: Load transactions history on budget created (#72) 2026-01-22 11:10:15 +01:00
BudgetTest.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
BudgetTransactionServiceTest.php feat: Load transactions history on budget created (#72) 2026-01-22 11:10:15 +01:00
BulkUpdateTransactionsTest.php refactor: Simplify transaction endpoints architecture (#76) 2026-01-25 16:15:17 +01:00
CashflowAnalyticsTest.php test: Fix Carbon month overflow in date calculations (#87) 2026-02-01 11:33:09 +01:00
DashboardAnalyticsTest.php test: Fix Carbon month overflow in date calculations (#87) 2026-02-01 11:33:09 +01:00
DashboardTest.php User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
DeleteUserCommandTest.php test: Optimize tests performance 2026-01-17 19:20:23 +01:00
DemoAccountRestrictionsTest.php test: Optimize DemoAccountRestrictionsTest to run under 10s 2026-01-28 21:27:27 +01:00
EncryptionTest.php User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
ExampleTest.php Install Pest 2025-11-07 12:01:58 +00:00
IdorVulnerabilityTest.php refactor: Simplify transaction endpoints architecture (#76) 2026-01-25 16:15:17 +01:00
ImportDataTest.php fix: Apply automation rule labels on transaction creation and import (#79) 2026-01-27 11:11:29 +01:00
InertiaSharedDataTest.php SEO landing page 2025-11-25 11:33:11 +01:00
LabelTest.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
ResendSyncCommandTest.php feat: Sync new users to Resend contacts (#85) 2026-01-28 21:25:58 +01:00
SitemapTest.php User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
SubscriptionTest.php User Onboarding Flow (#23) 2025-12-12 13:06:08 +01:00
TransactionTest.php fix: Apply automation rule labels on transaction creation and import (#79) 2026-01-27 11:11:29 +01:00
UserLeadTest.php Add User Lead functionality and tests 2025-11-25 10:31:25 +01:00