**Not ready to merge as it stands: a failed export currently looks like a success to cron, and customer emails are written to the logs.** The structure is clean and readable, and the SQL is parameterised with a correct half-open date window. The four blockers are small fixes except the timezone one, which needs a check first, so tomorrow is still realistic.

I read the file only; I did not run it and could not see `test_export_job.py`, the schema, or the cron setup.

## Blockers

1. **Failures are swallowed (lines 56–57).** `run()` catches every exception, logs one line and exits with code 0.
   - Case: the finance endpoint returns 503 at 02:00. Cron records success, no alert fires, and finance is missing that day's invoices. Expected: non-zero exit and a traceback.
   - Fix: use `log.exception(...)` and re-raise, or remove the `except` entirely.

2. **A missed day cannot be re-run (line 47).** The day is hard-coded as "yesterday".
   - Case: the 14 Nov run fails. Running the job on 15 Nov exports 14 Nov's data only if you run it that day; after that, 13 Nov's invoices need a code edit to recover.
   - Fix: accept an optional `--date` argument that defaults to yesterday.

3. **Customer emails are logged (line 52).** Every customer email for the day goes into the log line, which puts personal data in log storage with its own retention and access rules. Log the count only.

4. **The upload has no timeout (line 42).** `requests.post` waits forever by default.
   - Case: the finance endpoint accepts the connection and never responds. The job hangs holding a database connection, and the next night's run starts alongside it.
   - Fix: `timeout=(10, 120)` or similar.

5. **"Yesterday" may not match the database's day (lines 28, 47).** `date.today()` uses the host's timezone, while the `paid_at` comparison uses the database session's timezone.
   - Case: host on UTC, `paid_at` stored in US Eastern time. An invoice paid at 21:00 Eastern on 13 Nov is 02:00 UTC on 14 Nov, so it lands in the wrong day's file.
   - Whether this bites depends on your column type and server settings, which I could not see. Confirm them, then pass explicit timezone-aware bounds.

## Should fix

6. **Logging is never configured.** With no handler set up, the `log.info` lines print nothing when run as a script, and errors reach stderr with no timestamp. Add `logging.basicConfig(...)` under `__main__`.

7. **Tests cover only the CSV header and one row** (per the docstring). Nothing covers the date window, an upload failure, an empty day, or the exit code on failure — the paths the blockers above live in.

8. **Amounts are formatted inconsistently (line 37).** `amount_cents / 100` is float division.
   - Case: 2000 cents is written as `20.0` and 1050 as `10.5`; expected `20.00` and `10.50`.
   - It is also wrong for currencies without two decimals: ¥500 stored as 500 exports as `5.0`.
   - Fix: use `Decimal` with a per-currency exponent, or export the raw minor units.

9. **Re-runs create duplicates.** Nothing tells the finance endpoint that a file is a re-send, so a manual retry after a partial failure may double-count unless their side de-duplicates by filename. Worth confirming with them.

10. **No authentication is visible on the upload (line 42).** If the token is embedded in `FINANCE_UPLOAD_URL`, that works, but the URL then must never be logged. Otherwise an auth header is missing.

11. **Export files accumulate in `/var/exports`.** Each one holds customer emails and is never deleted. Add a retention step or delete after a successful upload.

12. **Spreadsheet formula injection (line 37).** An email whose local part begins with `=`, `+`, `-` or `@` is run as a formula when finance opens the CSV in Excel. Prefix such cells with `'`.

## Minor

13. `UPLOAD_URL` is read at import time (line 16), so importing the module in a test without the variable raises `KeyError`; `DATABASE_URL` is read inside `run()`. Read both in `run()`.
14. `psycopg2.connect` sits outside the `try` (line 49), so a connection failure behaves differently from every other failure (it crashes with a traceback, which is the better behaviour).
15. `open(path, "w")` has no `encoding="utf-8"` (line 33), so the encoding depends on cron's locale.
16. The CSV is written in place; a crash mid-write leaves a partial file under the final name. Write to a temp file and rename.
17. `EXPORT_DIR` is hard-coded and not checked for existence.
18. `fetchall()` loads the whole day into memory; fine at current volume, a server-side cursor if it grows.
19. An empty day uploads a header-only file. Decide whether finance wants that or a skip.
20. `paid_at.isoformat()` has no UTC offset if the column is timezone-naive, so finance cannot tell which zone it is in.
21. An invoice paid yesterday and refunded before 02:00 is no longer `PAID` and is omitted. Confirm that is what finance expects.

VERDICT: NOT READY
