whisper-money/tests/Browser
Víctor Falcón 094fb1b744
feat(real-estate): auto-calculate revaluation % and generate historical balances (#253)
## Summary

- **Auto-calculates Annual Revaluation %** (CAGR) on the frontend when
purchase price, purchase date, and current market value are all provided
— pre-fills the revaluation field while still allowing manual override
- **Generates historical monthly balance records** via linear
interpolation from purchase date to today when creating a real estate
account with complete purchase data
- New `RealEstateBalanceGeneratorService` handles balance generation
with dates on the 1st of each month (matching the existing
`ApplyRealEstateRevaluationCommand` convention)

## Changes

### Backend
- **`app/Services/RealEstateBalanceGeneratorService.php`** (new) —
Linear interpolation service that builds balance dates (purchase date,
1st of each intermediate month, today) and creates `AccountBalance`
records using `updateOrCreate`
- **`app/Http/Controllers/Settings/AccountController.php`** — Calls the
service after real estate detail creation when all three inputs are
present

### Frontend
- **`resources/js/components/accounts/account-form.tsx`** — Added CAGR
auto-calculation via `useEffect` with a `useRef` flag
(`isRevaluationManuallySet`) to avoid overwriting manual user input

### Tests
- **`tests/Feature/Services/RealEstateBalanceGeneratorServiceTest.php`**
(new) — 7 unit tests covering interpolation, edge cases (same-day
purchase, flat values, single month spans)
- **`tests/Feature/RealEstateTest.php`** — 6 new feature tests covering
historical balance generation through the controller (with/without
purchase data, same-day, flat values)

All 38 tests in `RealEstateTest.php` and all 7 service tests pass.
2026-04-15 12:18:33 +00:00
..
assets Improve automation rules and sync error handling 2025-12-01 10:30:22 +01:00
.gitignore Add category type field support (#2) 2025-12-01 20:19:47 +01:00
AccountsPageTest.php test: expand browser coverage for accounts and linked loans (#277) 2026-04-13 09:33:18 +01:00
AmountInputTest.php fix(transactions): fix toolbar overflow on mobile and shorten button label (#175) 2026-03-01 17:57:59 +00:00
AuthenticationTest.php feat: Enable email verification on sign up (#97) 2026-02-03 10:15:07 +01:00
AutomationRuleBuilderTest.php feat(automation-rules): simplify smart rules UI, fix re-evaluation, and localize amounts (#161) 2026-02-28 13:24:57 +00:00
BankAccountsTest.php feat(real-estate): auto-calculate revaluation % and generate historical balances (#253) 2026-04-15 12:18:33 +00:00
BudgetCrudTest.php test(budgets): stabilize budget rename browser test (#255) 2026-04-01 10:30:49 +01:00
BudgetsFeatureNavigationTest.php feat(subscription): allow free plan for open banking users without connected banks (#188) 2026-03-03 22:28:50 +00:00
CashflowCategoryNavigationTest.php feat(cashflow): make income/expense category rows clickable to transactions (#234) 2026-03-17 10:57:40 +00:00
CategoriesTest.php feat(cashflow): track transfer categories in trends (#236) 2026-03-18 14:02:47 +00:00
ImportTransactionsTest.php Remove encryption from browser tests and demo user (#129) 2026-02-17 11:45:27 +01:00
OnboardingFlowTest.php fix: default to standard onboarding option (#276) 2026-04-13 08:54:12 +01:00
RealEstateAccountTest.php feat(real-estate): auto-calculate revaluation % and generate historical balances (#253) 2026-04-15 12:18:33 +00:00
TransactionsTest.php test: expand browser coverage for account types and transactions (#279) 2026-04-13 14:02:21 +02:00