whisper-money/app/Enums
Víctor Falcón f3b5929ecc
fix(banking): retry failed sync connections and log every sync attempt (#251)
## Summary

- **Fixes the broken retry mechanism** — after the first failed attempt
set status to `Error`, subsequent retry attempts bailed out because
`isActive()` returns `false` for `Error`. Now both `Active` and `Error`
statuses are syncable.
- **Adds auto-retry across scheduled runs** —
`SyncAllBankingConnectionsJob` and `banking:sync` command now include
`Error` connections where `consecutive_sync_failures < 3` (configurable
via `MAX_SCHEDULED_RETRIES`). After 3 full dispatch cycles, manual
intervention is required.
- **Logs every sync attempt to DB** — new `banking_sync_logs` table
records status (Success/Failed/Skipped), attempt number, error details,
duration, and metadata for each sync.

## Changes

### Core logic (`SyncBankingConnectionJob`)
- `isSyncableStatus()` allows both `Active` and `Error` through the gate
- Temporary errors: status only set to `Error` on the final attempt
(attempt 3); earlier attempts re-throw without changing status
- Permanent auth errors (401/403): `$this->fail()` called immediately,
`consecutive_sync_failures` set beyond the cap
- Rate limit (429): handled silently (existing behavior preserved)
- Every attempt is logged to `banking_sync_logs`

### Query updates
- `SyncAllBankingConnectionsJob`: includes `Error` connections under
retry cap
- `SyncBankingConnections` command: same query update for
`--user`/`--connection` filtered runs

### Controller updates
- `ConnectionController::sync()` and `updateCredentials()` reset
`consecutive_sync_failures` to 0

### New files
- `BankingSyncLogStatus` enum (Success, Failed, Skipped)
- `BankingSyncLog` model
- Two migrations: `add_consecutive_sync_failures` column,
`create_banking_sync_logs` table

### Tests
- Updated 3 existing auth error tests in `SyncBankingConnectionJobTest`
(24 pass)
- Added 17 new tests in `SyncRetryAndLoggingTest` covering retry
behavior, sync logging, scheduled retry inclusion/exclusion, and manual
retry reset
- All 10 `SyncBankingConnectionsCommandTest` tests still pass
2026-03-31 11:34:35 +01:00
..
AccountType.php feat(accounts): add real estate asset tracking (#241) 2026-03-24 10:21:32 +00:00
BankingConnectionStatus.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
BankingSyncLogStatus.php fix(banking): retry failed sync connections and log every sync attempt (#251) 2026-03-31 11:34:35 +01:00
BudgetPeriodType.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
CategoryCashflowDirection.php feat(cashflow): track transfer categories in trends (#236) 2026-03-18 14:02:47 +00:00
CategoryColor.php Add category type field support (#2) 2025-12-01 20:19:47 +01:00
CategoryType.php Add type enum to categories 2025-12-01 10:29:57 +01:00
ChartColorScheme.php Add chart color scheme setting (#101) 2026-02-28 12:58:21 +01:00
DripEmailType.php feat: Send custom emails to users (#52) 2026-01-09 09:33:19 +01:00
LabelColor.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
PropertyType.php feat(accounts): add real estate asset tracking (#241) 2026-03-24 10:21:32 +00:00
RolloverType.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
TransactionSource.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00