**Not ready to merge as it stands: four problems can lose or leak finance data without anyone noticing.** All four are small fixes, so tomorrow is still realistic. The structure is good: small single-purpose functions, a parameterised query, and a correct half-open date window.

I read the file but did not run it, and I could not see `test_export_job.py`, so the test comments rely on the docstring's description.

## Blockers

1. **Failures are silent (`export_job.py:56-57`).** `run()` catches every exception, logs one line and exits with code 0. If the finance endpoint returns a 500 at 02:00, cron records success and nobody finds out until finance asks where the file is. Re-raise or `sys.exit(1)` after logging, and use `log.exception` so the traceback is kept.

2. **No way to re-export a missed day (`:47`).** The day is hardcoded to "yesterday" inside `run()`. If Tuesday's run fails, Wednesday's run exports only Tuesday's invoices and Monday's are never sent. Accept the day as an optional argument; that also makes `run()` testable.

3. **Customer emails are written to the log (`:52`).** Every customer email for the day goes into one log line. That is personal data in log storage, which usually has wider access and longer retention than the database. Log the count only.

4. **The upload has no timeout (`:42`).** `requests.post` waits forever by default. If the endpoint accepts the connection and stalls, the job hangs and the next night's run starts alongside it. Add `timeout=(10, 120)` or similar.

## Should fix before merge

5. **The day boundary depends on two unstated timezones (`:28`, `:47`).** `date.today()` uses the server's local zone, and the date is compared to `paid_at` in the database session's zone. If the server is UTC and the session is US Eastern, an invoice paid at 23:30 Eastern lands in a different day's file than finance expects. Pick the zone explicitly and build timezone-aware bounds.

6. **Amounts are formatted inconsistently and assume two decimal places (`:37`).** `amount_cents / 100` writes 1990 as `19.9` and 10000 as `100.0`. For JPY, which has no minor unit, 500 yen is exported as `5.0`. Format with `Decimal` and a per-currency exponent, or export `amount_cents` unchanged.

7. **No logging configuration.** Nothing calls `logging.basicConfig`, so when run from cron both `log.info` lines are dropped. Only the bare error message reaches stderr, without a timestamp.

8. **Tests cover only the CSV header and one row.** There are no tests for the date window, the upload, the failure path, or amount formatting. By your own standards, items 1, 2, 5 and 6 each need a test.

9. **A re-run uploads the same file again.** Nothing marks a day as exported. Confirm whether the finance endpoint deduplicates by filename; if it does not, a manual re-run double-counts revenue.

## Minor

10. **Exported files accumulate in `/var/exports` forever (`:15`, `:48`).** They contain customer emails, are created with default permissions, and are never cleaned up. The directory is hardcoded and never created.
11. **Spreadsheet formula injection (`:37`).** An email such as `=cmd@example.com` is treated as a formula if finance opens the CSV in Excel. Prefix cells that start with `=`, `+`, `-` or `@` with a single quote.
12. **`FINANCE_UPLOAD_URL` is read at import time (`:16`).** Importing the module in a test without the variable raises `KeyError`. `DATABASE_URL` is read inside `run()`, so the two are inconsistent.
13. **`psycopg2.connect` sits outside the `try` (`:49`).** A database connection failure is the only failure that does crash loudly. Fixing item 1 makes this consistent.
14. **Late-recorded payments are missed.** An invoice marked paid after 02:00 with a `paid_at` of the previous day is never exported. Check whether payment webhooks can arrive that late.
15. **A partially written file is left on disk (`:33`).** If the write crashes midway, the truncated file stays under the final name. Write to a temporary file and rename.
16. **The upload sends no credentials (`:42`).** This is fine if the URL carries a token or the network is private; worth confirming.
17. **A day with no invoices uploads a header-only file.** Confirm finance wants that rather than no file.
18. **`fetchall()` loads the whole day into memory (`:29`).** Fine at current volume.

VERDICT: NOT READY
