# S19-04 Assumptions — Daily Auto-Export Backup

**Task:** Daily auto-export job: all transactions to Excel as backup
**Date:** 2026-05-09

## Assumptions

1. **Domain placement.** Using `app/Domain/Backup/` (greenfield) for the `DailyExportBackup` action class. The Artisan command lives in `app/Console/Commands/Backup/DailyExportBackupCommand.php`.

2. **"All transactions" scope.** Exporting `transactions` table + `journal_entry_lines` + `members` + `coa_accounts` as separate sheets. These cover the core financial records. Inventory movements and AR/AP are excluded (not yet built at time of this task; follow DSAR deferred-sources pattern from S38-004).

3. **Per-tenant execution.** The command iterates over all active tenants and exports one file per tenant. Not dispatched as a queued job per tenant — runs synchronously in the scheduler since it's a low-frequency nightly task.

4. **S3 / filesystem.** Uses `Storage::disk(config('backup.disk'))` — `s3` in production, `local` in tests. The `.env.example` should document `BACKUP_DISK=s3`.

5. **Naming.** `{tenant_id}/{YYYY-MM-DD}/transactions.xlsx` as specified. In local dev the path is relative to `storage/app/`.

6. **Retention.** 90-day purge checks `Storage::disk(...)->lastModified()` and deletes files older than 90 days. Runs at the end of each export run.

7. **Failure handling.** Uses Laravel `Schedule::command(...)->emailOutputOnFailure(config('mail.from.address'))` + catches exceptions inside the action and reports to Sentry. Retry logic: command retries once before failing.

8. **PhpSpreadsheet.** `phpoffice/phpspreadsheet` was installed as part of sprint setup (via S19 pre-work).

9. **Audit log.** Records one activity entry per tenant per successful export: `backup.daily_export`.

10. **No tenant context injection.** The command runs as a platform-level (PO) process, not within a tenant request. Uses `withoutGlobalScopes()` + explicit `where('tenant_id', $tenant->id)` per PRINCIPLES P-42.

## Out of Scope
- Per-table incremental exports (full 24h window only)
- Compression (zip) — deferred
- Multiple file formats (CSV, PDF) — Excel only per tender requirement
- Cloud storage provider abstraction beyond `Storage::disk()`
