**`export_job.py` is not ready to merge as it stands: two problems are blockers, and three more should be fixed before you rely on it for finance data.** The blockers are small fixes (roughly half a day with tests), so tomorrow is still reachable. I reviewed by reading the file only; I did not run it or open `test_export_job.py`.

## Blockers

| # | Problem | Concrete case | Fix |
|---|---------|---------------|-----|
| 1 | **Failures are hidden from cron.** `run()` catches every exception, logs one line and exits with status 0 (`export_job.py:56-57`). | Finance endpoint returns 503 at 02:00. The job exits "successfully", no alert fires, and finance has no file. Expected: non-zero exit and a stack trace. | Log with `log.exception` and re-raise (or `sys.exit(1)`). |
| 2 | **A missed day can never be exported.** The date is always "yesterday" (`:47`), with no way to pass one in. | The 503 above happens on 14 Nov. On 15 Nov the job exports only the 14th's successor day; the missed day's invoices never reach finance. | Accept an optional `--date` argument, defaulting to yesterday. |

## High severity

| # | Problem | Concrete case | Fix |
|---|---------|---------------|-----|
| 3 | **Every customer email is written to the log** (`:52`). | A day with 4,000 paid invoices puts 4,000 email addresses in one log line, in whatever log store keeps them. | Log the count and day only. |
| 4 | **The upload has no timeout** (`:42`). | The finance endpoint accepts the connection and never answers. The job hangs indefinitely, holding the database connection open. | Add `timeout=(10, 120)` or similar. |
| 5 | **Test coverage is the CSV header and one row** (per the docstring). | Nothing tests the date window, an upload failure, or `run()`'s failure path, which is where blockers 1 and 2 sit. | Add tests for those three alongside the fixes. |

## Medium severity

- **Amounts are wrong for currencies that don't have two decimals** (`:37`). A JPY invoice stored as 5000 is exported as `50.0`; expected `5000`. If you only bill in two-decimal currencies this doesn't bite today, but the `currency` column suggests otherwise.
- **Amount formatting is inconsistent.** 1000 cents is exported as `10.0` and 1050 as `10.5`; expected `10.00` and `10.50`. Use `Decimal` and a fixed format.
- **"Yesterday" depends on two clocks.** `date.today()` uses the server's time zone, while the query compares against `paid_at` in the database session's time zone. If they differ, an invoice paid at 23:30 lands in the wrong day's file. Decide the business time zone and build the window explicitly.
- **Invoices recorded late are skipped.** If an invoice is marked PAID at 02:30 with `paid_at` set to 23:50 the previous day, no run ever picks it up. Whether this can happen depends on how `paid_at` is set; worth confirming.
- **Reruns upload duplicates.** There is no idempotency key or "already uploaded" check, so a manual rerun sends finance the same file twice.
- **Info logs probably go nowhere.** The script never configures logging, so run directly from cron, the "exporting" and "export finished" lines are dropped and only errors reach stderr.

## Low severity

- `FINANCE_UPLOAD_URL` is read at import time (`:16`), so importing the module in tests fails without it; `DATABASE_URL` is read inside `run()`. Read both in `run()`.
- The CSV holding customer emails stays in `/var/exports` forever with default permissions, and a half-written file is left behind if the job fails mid-write.
- `EXPORT_DIR` is hardcoded and not created if missing.
- `open()` has no `encoding="utf-8"` (`:33`), so a non-ASCII email can fail under some cron locales.
- An email starting with `=`, `+`, `-` or `@` is treated as a formula if finance opens the CSV in Excel.
- `fetchall()` loads the whole day into memory; fine at current volumes, not at very large ones.
- A day with no paid invoices uploads a header-only file; confirm finance wants that.
- No retry on a transient upload failure.

## What I'd do for tomorrow

Fix 1 to 5 with tests, plus the amount formatting, and merge. The time zone, late-recorded invoice and duplicate-upload questions need an answer from finance or whoever owns `paid_at`, and can follow as tracked debt if you name them in the PR.

VERDICT: NOT READY
