`export_job.py` is not ready to merge as written: four problems can lose or leak finance data without anyone noticing. The fixes are small (roughly half a day including tests), so a merge tomorrow is still realistic if they go in first.

I reviewed by reading the file only; nothing was run. The docstring says it is tested by `test_export_job.py`, but that file is not in this folder, so I could not check the tests.

## Blocking (high severity)

1. **A failed export looks like a success.** `run()` catches every exception, logs one line and exits with code 0 (`export_job.py:56`). For example, if the finance endpoint returns 503 at 02:00, cron sees a clean exit, nothing alerts, and finance has no file for that day. The log line also drops the traceback. Fix: use `log.exception` and re-raise or exit non-zero.
2. **A missed day is never recovered.** The day is hard-coded to "yesterday" (`export_job.py:47`). If the 14 Nov run fails, the 15 Nov run exports only 14 Nov, and 13 Nov's invoices are never sent. Fix: accept the day as an argument so a day can be re-run.
3. **Every customer email is written to the log.** Line 52 logs the full list of `customer_email` values on each run. That puts personal data into log files and whatever aggregator reads them. Fix: log the count only.
4. **The upload can hang forever.** `requests.post` has no timeout (`export_job.py:42`). If the endpoint accepts the connection and stalls, the job never finishes and the next night's run starts alongside it. Fix: add a timeout, ideally with a bounded retry.

## Should fix before merge (medium severity)

5. **The day boundary depends on two unrelated timezones.** `date.today()` uses the server clock, and the query compares `paid_at` against a bare date, which the database reads as midnight in its own session timezone. If both are UTC and finance works in US Eastern, an invoice paid at 8pm Eastern on 13 Nov lands in the 14 Nov file. You need to confirm which timezone finance means by "yesterday" and set it explicitly.
6. **Amounts are formatted inconsistently.** `amount_cents / 100` produces a float (`export_job.py:37`), so 1000 cents is written as `10.0`, 1050 as `10.5` and 1999 as `19.99`. Fix: format from the integer or use `Decimal` with two places. Dividing by 100 is also wrong for currencies with no minor unit, such as JPY, if you carry any.
7. **Logging is never configured.** With no handler set up, Python drops the INFO lines, so "exporting N invoices" and "export finished" never appear. Only the error line reaches stderr, without timestamps.
8. **Test coverage is too thin for a finance job.** By the docstring's own description, tests cover the CSV header and one row. The date window, upload failure, empty day, and failure path of `run()` are uncovered. The fixes for items 1, 2, 4 and 6 each need a test.
9. **The CSV with customer emails stays on disk.** It is written to `/var/exports` with default permissions (usually world-readable) and never deleted. A failed run also leaves a partial file behind.
10. **Re-running a day uploads it twice.** Nothing tells the endpoint the file is a repeat. Whether that double-counts depends on how finance's side handles duplicates, which I cannot see from here.

## Minor (low severity)

11. `FINANCE_UPLOAD_URL` is read at import time (`export_job.py:16`), so importing the module in a test without that variable set raises `KeyError`. `DATABASE_URL` is read inside `run()`; do the same for both.
12. `psycopg2.connect` sits outside the `try`, so a connection failure crashes with a traceback while every other failure is swallowed.
13. A `NULL` `amount_cents` on one invoice raises `TypeError` and fails the whole day's export.
14. The file is opened without `encoding="utf-8"`, so output depends on cron's locale.
15. An email beginning with `=`, `+`, `-` or `@` is written as-is and would be treated as a formula if finance opens the CSV in Excel.
16. `fetchall()` loads the whole day into memory, which is fine at current volumes but worth knowing.
17. No authentication is sent with the upload. This is fine if the URL carries a token or the network is private, but worth confirming.
18. An invoice marked PAID late with a back-dated `paid_at` is never exported, because its day has already run.

## Suggested order for tomorrow

Fix items 1–4 with tests, then 6 and 7, which are a few lines each. Get an answer from finance on item 5. Items 9, 10 and the minor list can follow in a second change if you record them as known debt.

VERDICT: NOT READY
