`export_job.py` is not ready to merge as it stands, but it can be tomorrow: four small fixes (about an hour of work plus tests) are needed first, and one timezone question needs your answer. The core logic (parameterised query, CSV writing, upload) is sound.

I reviewed by reading only; I have no shell in this session, so nothing was executed. `test_export_job.py`, which the docstring names, is not in this folder, so I could not check the tests.

## Must fix before merge

1. **A failed export looks like a success (high).** `run()` catches every exception at `export_job.py:56`, logs one line and returns, so the process exits 0. For example, if the finance endpoint returns 503, cron records a clean run, finance gets no file, and nobody is alerted. Re-raise after logging, and use `log.exception` so the traceback is kept.

2. **Customer emails are written to the log (high, privacy).** Line 52 logs `[row[1] for row in rows]`, which is every customer's email address for the day. Log the count and the date only.

3. **The upload can hang forever (high).** `requests.post` at line 42 has no `timeout`. If the finance endpoint accepts the connection and never answers, the job blocks indefinitely and there is no error to alert on. Add something like `timeout=(10, 120)`.

4. **Success logs never appear (medium).** The file never configures logging, so run as a script the two `log.info` lines (52 and 55) are dropped; only the error line reaches stderr. You cannot confirm from the logs that a night's export ran. Add `logging.basicConfig(level=logging.INFO)` under `__main__`.

## Needs your answer

5. **"Yesterday" depends on the server's timezone (medium).** Line 47 uses `datetime.date.today()`, which is the host's local date, and the query compares `paid_at` against bare dates. If `paid_at` is stored in UTC and the host runs in another zone (or the reverse), invoices paid near midnight land in the wrong day's file. If the host and database are both UTC, this is fine; otherwise, set the zone explicitly.

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

6. **A missed day cannot be re-exported (medium).** `run()` hardcodes yesterday. If Tuesday's run fails, running it on Wednesday exports Wednesday's "yesterday", and Tuesday's invoices are never sent without editing code. Let `run()` take an optional date argument.

7. **Test coverage is thin (medium).** By the docstring, tests cover only the CSV header and one row. `fetch_invoices`, `upload` and the failure path of `run()` are untested. At a minimum, add a test that a failed upload makes `run()` raise, to go with fix 1.

8. **Amounts have inconsistent decimals (low).** `amount_cents / 100` at line 37 writes 2000 cents as `20.0` and 1050 as `10.5`, not `20.00` and `10.50`. The values are correct, but a finance import expecting two decimals may reject them. Use `f"{amount_cents / 100:.2f}"` or `Decimal`.

9. **Importing the module requires `FINANCE_UPLOAD_URL` (low).** Line 16 reads it at import time, so any test or tool that imports the file without that variable gets a `KeyError`. Read it inside `upload()`.

10. **A database connection failure behaves differently from every other failure (low).** `psycopg2.connect` at line 49 sits outside the `try`, so it crashes with a traceback while other errors are swallowed. Fix 1 makes this consistent.

11. **Export files with customer emails accumulate (low).** Files in `/var/exports` are never deleted, and a failed run leaves a partial file behind. Add a retention or cleanup step.

## Speculative, depends on things I cannot see

- **Upload authentication:** the upload sends no auth header. That is fine if the URL carries a token or the network is private.
- **Duplicates on re-run:** running twice for the same day uploads the file twice. Whether that matters depends on whether the finance endpoint de-duplicates.
- **Zero-decimal currencies:** dividing by 100 is wrong for currencies like JPY if `amount_cents` holds their minor units.
- **Memory:** `fetchall()` loads the whole day into memory, which only matters at very large daily volumes.
- **Spreadsheet formulas:** an email starting with `=` would be run as a formula if finance opens the CSV in Excel.

VERDICT: READY WITH CHANGES
