Not ready to merge as it stands, but the four blocking problems are small fixes that fit in a day. The most serious one is that a failed export looks like a success, and nothing ever retries that day.

I reviewed by reading `export_job.py` only; nothing was run. The docstring names `test_export_job.py`, but that file is not in the folder next to the job, so I could not check the tests.

## Must fix before merge

1. **A failed run reports success (high).** `export_job.py:56-57` catches every exception, logs one line and lets the process exit with code 0.
   - Example: the finance endpoint returns 503. Expected: the job fails visibly. Actual: one line `export failed: 503 Server Error…` with no stack trace, exit code 0.
   - Fix: use `log.exception` and re-raise, or exit non-zero.

2. **A missed day is never re-exported (high).** `run()` only ever exports "yesterday" (`:47`) and takes no date argument.
   - Example: if the 14 Nov run fails, the 15 Nov run exports only 14 Nov's invoices, and 13 Nov's never reach finance.
   - Fix: accept an optional date argument so a day can be re-run by hand.

3. **The upload can hang forever (high).** `requests.post` at `:42` has no `timeout`. If the endpoint accepts the connection and stalls, the job never ends and never logs a failure.
   - Fix: add `timeout=(10, 120)` or similar.

4. **Customer emails are written to the log (high, privacy).** `:52` logs the full list of `customer_email` values for every run.
   - Today this line is dropped because of item 5, but it will start emitting as soon as logging is configured.
   - Fix: log the count only.

5. **Success messages are never emitted (medium).** Nothing configures logging, so Python prints only warnings and above. Both `log.info` lines (`:52`, `:55`) vanish, leaving no record that a run succeeded or how many invoices it sent.
   - Fix: call `logging.basicConfig(level=logging.INFO)` under `__main__`.

6. **Tests do not cover the risky parts (medium).** By the docstring's own description, tests cover the CSV header and one row. Nothing covers the date window in `fetch_invoices`, an upload failure, or `run()` failing loudly.
   - Fix: at least add tests for items 1 to 3 with their fixes.

## Should fix, can follow the merge

7. **Amounts are formatted inconsistently (medium).** `:37` does `amount_cents / 100`, so 1000 cents is written as `10.0`, 1999 as `19.99` and 10 as `0.1`. Format from integers or `Decimal` with fixed places instead.
8. **A null `amount_cents` aborts the whole export (low to medium).** One such row raises `TypeError` at `:37`, and no file is sent for that day.
9. **`FINANCE_UPLOAD_URL` is read at import time (low).** `:16` means importing the module without the variable set raises `KeyError`, including in tests. `DATABASE_URL` is read inside `run()`; do the same here.
10. **Export files with customer emails pile up (low).** Files in `/var/exports` are never deleted and are created with default permissions. The directory is hard-coded and assumed to exist.
11. **Spreadsheet formula injection (low).** An email starting with `=`, `+`, `-` or `@` is treated as a formula if finance opens the CSV in Excel.

## Speculative, depends on things I cannot see

- **Time zones.** "Yesterday" comes from the server's local date (`:47`), while the query's day boundaries use the database session's time zone. If the two differ, invoices near midnight land in the wrong day's file.
- **Non-two-decimal currencies.** If `amount_cents` holds minor units for all currencies, dividing by 100 is wrong for yen (500 JPY becomes `5.0`) and for three-decimal currencies.
- **Upload authentication.** The POST sends no credentials. That is fine if the URL carries a token or the network is private, and a problem otherwise.
- **Refunds before 02:00.** An invoice paid yesterday and refunded before the run is excluded by `status = 'PAID'`. Whether finance wants that is a requirements question.
- **Memory.** `fetchall()` loads the whole day at once, which only matters at very large daily volumes.

The parameterised query, the context managers and the split into small functions are all sound; the gaps are in failure handling.

VERDICT: READY WITH CHANGES
