I wouldn't merge this tomorrow as it stands. The file is small and its functions are cleanly separated, so most fixes are a few lines each. But three problems mean finance could get a wrong file, or no file at all, without anyone finding out.

## Must fix before merge

**1. Failures are hidden, so cron thinks every run succeeded** (`export_job.py:56-57`)
`run()` catches every exception, logs one line and exits with status 0.
- Example: the finance endpoint returns a 500. `raise_for_status()` raises, the `except` catches it, and the process still exits 0. Cron and any monitoring see a success, and finance gets no file.
- Expected: the job exits non-zero so the failure is noticed.
- `log.error("%s", error)` also drops the traceback.
- Fix: use `log.exception(...)` and then `raise`, or remove the `try/except` and keep only the `finally`.

**2. Every customer email address is written to the logs** (`export_job.py:52`)
`[row[1] for row in rows]` puts each customer's email into the INFO log line. That leaks personal data into log storage, which usually has wider access and longer retention than the database. Log only the count.

**3. Amounts are converted with floating-point division and a fixed /100** (`export_job.py:37`)
- `2000 / 100` writes `20.0`, not `20.00`. Floats are the wrong type for money in a finance file.
- Dividing by 100 is only correct for currencies with 2 decimal places. If a JPY invoice is stored as `amount_cents=500`, it exports as `5.0` instead of `500`. Currencies with 3 decimals, such as KWD, are wrong the other way.
- Fix: use `Decimal` and format using each currency's number of decimal places. Or export the raw integer minor units (cents) and agree the format with finance.
- I can't tell how non-2-decimal currencies are stored, so please confirm. The `20.0` formatting problem applies either way.

## Should fix before merge

**4. The upload request has no timeout** (`export_job.py:42`)
If the endpoint stops responding, the job waits forever. Tomorrow's 02:00 run would then start while this one is still running. Add something like `timeout=(5, 60)`.

**5. Invoices near midnight can land in the wrong day** (`export_job.py:28, 47`)
`date.today()` uses the server's local time zone. The query compares `paid_at` against a plain date, which Postgres reads as midnight in the database session's time zone. If those two time zones differ from each other, or from what finance means by "yesterday", invoices paid near midnight are left out or exported twice. Choose one time zone (probably UTC), use it explicitly in both places, and pass timezone-aware datetimes to the query.

**6. The INFO log lines are never written** (`export_job.py:13`)
Nothing configures logging, so Python's default only shows WARNING and above. The "exporting…" and "export finished" lines go nowhere. This is also the only reason item 2 hasn't leaked anything yet. Add `logging.basicConfig(...)` in the `__main__` block.

**7. Tests cover only the CSV writer**
The docstring says the tests check the CSV header and one row. Nothing tests:
- the date window in the query
- the upload failure path
- the behaviour in item 1
- amount formatting, including the cases in item 3

Your engineering standards require the failure paths to be tested. I'd add at least:
- a test that `run()` raises when `upload` fails
- an amount-formatting test with a few edge values

## Nice to have

**8. Missed days can't be re-run.** The date is always "yesterday". If Tuesday's run fails, you can't re-export Tuesday on Wednesday without editing code. Accept an optional `--date` argument.

**9. Settings are read from the environment at import time** (`export_job.py:16`). Importing the module raises `KeyError` unless `FINANCE_UPLOAD_URL` is set, which makes tests awkward. Read it inside `upload()`/`run()`, or pass it in.

**10. A half-written CSV can be left on disk.** If `write_csv` fails partway through, a truncated file stays in `/var/exports`. Write to a temporary file and rename it when complete.

**11. The CSV holds personal data with default file permissions.** Customer emails sit in `/var/exports` with whatever permissions the process umask gives. Check that this is acceptable, and set mode `0o600` if not.

**12. No encoding is set when opening the CSV** (`export_job.py:33`). Add `encoding="utf-8"` so emails with non-ASCII characters don't depend on cron's locale.

**13. Days with no invoices upload a header-only file.** That may be what you want. Confirm finance expects a file every day.

**14. Small cleanup.** The functions have no type hints or docstrings, and `fetchall()` loads every row into memory. Both are fine at nightly volumes and need no action now.

The overall shape is good: fetch, write and upload are separate, small, testable functions. That's why items 1–7 should be quick. Items 1–3 block the merge because each one can produce a wrong or missing finance export without anyone noticing.

VERDICT: NOT READY
