`export_job.py` is not ready to merge as it stands, but it can be by tomorrow: four fixes of a few lines each plus a handful of tests. The core logic (query, CSV, upload) is sound and nicely split into small functions. I reviewed by reading only; nothing was run. `test_export_job.py` is not in this folder, so my view of test coverage comes from the docstring alone.

## Must fix before merge

1. **Failures are silent (high).** `export_job.py:56-57` catches every exception, logs one line and exits with code 0.
   - Example: the finance endpoint returns a 500 at 02:00. Cron records success, finance gets no file and nobody is alerted. Expected: a non-zero exit so cron or monitoring flags it.
   - Fix: use `log.exception(...)` to keep the traceback, then re-raise, or drop the `except` entirely.

2. **The upload can hang forever (high).** `requests.post` at `export_job.py:42` has no `timeout`. If the finance endpoint accepts the connection and stalls, the job never finishes and never fails.
   - Fix: add `timeout=(10, 120)` or similar.

3. **Customer emails are written to the logs (high, privacy).** `export_job.py:52` logs every customer's email address on every run.
   - Fix: log the count and the day only.

4. **Logging is never configured (medium).** Nothing sets up a handler, so under cron both `log.info` lines are discarded and only the error line reaches stderr. A successful run leaves no trace.
   - Fix: call `logging.basicConfig(level=logging.INFO)` under `if __name__ == "__main__":`.

5. **Tests cover only the CSV header and one row (medium).** That is what the docstring states. Missing tests:
   - `fetch_invoices` passes the right day window.
   - `upload` raises on an HTTP error.
   - `run` exits non-zero when any step fails.
   - `write_csv` with zero rows.

## Should fix, can follow the merge if you name the debt

6. **A missed day cannot be re-run (medium).** `run()` hard-codes "yesterday" at `export_job.py:47`. If Tuesday's run fails, running the job on Thursday exports Wednesday, and Tuesday is lost. An optional `--date` argument fixes this.

7. **Amount formatting is inconsistent (low to medium).** `amount_cents / 100` at `export_job.py:37` writes 1050 cents as `10.5` and 100000 cents as `1000.0`. Finance will likely expect `10.50` and `1000.00`; use `f"{amount_cents / 100:.2f}"` or `Decimal`.

8. **`FINANCE_UPLOAD_URL` is read at import time (low).** `export_job.py:16` raises `KeyError` on import when the variable is unset, which includes importing the module in tests. `DATABASE_URL` is read inside `run()`; do the same for both.

9. **Export files pile up (low).** CSVs containing customer emails are written to `/var/exports` and never deleted, with whatever permissions the default umask gives.

## Questions I could not settle from the file

- **Timezone of "yesterday".** `date.today()` uses the server's local time, and the query compares a date against `paid_at`. If `paid_at` is stored in UTC and the server or finance works in another timezone, invoices paid near midnight land in the wrong day's file. I cannot tell without the column type and server timezone; please confirm before merge, because a wrong answer here means wrong finance figures.
- **Non-two-decimal currencies.** The query selects `currency`, so multiple currencies seem to be in play. Dividing by 100 is wrong for yen (no minor unit) or Kuwaiti dinar (three decimals), if you bill in those.
- **Upload authentication.** The POST sends no credentials. That is fine if the URL carries a token or the network is private.
- **Empty days.** A day with no paid invoices uploads a header-only file. Confirm finance wants that rather than no file.
- **Spreadsheet formulas.** A customer email beginning with `=` would be read as a formula if finance opens the CSV in Excel. This is unlikely, but cheap to guard against.

VERDICT: READY WITH CHANGES
