I wouldn't merge `export_job.py` tomorrow. When the job fails, nobody finds out. It also writes every customer's email address to the logs each night. And the test file it mentions doesn't exist.

## Must fix before merge

**1. Failures are hidden** (`export_job.py:56-57`)
`run()` catches every exception, logs one line and exits normally. Cron sees a successful run, so no alert fires.
- *Example:* the finance endpoint returns a 503. `raise_for_status()` raises, the job logs `export failed: 503 ...` and exits with code 0. Finance gets no file and nobody is told.
- *Expected:* log it with `log.exception(...)`, then re-raise or `sys.exit(1)` so cron or monitoring reports the failure.

**2. Customer emails go into the logs** (`export_job.py:52`)
`[row[1] for row in rows]` puts every paying customer's email into an INFO log line every night. That is personal data in the logs, which you probably have to delete later for privacy or compliance reasons.
- *Fix:* log only the count and the date.

**3. The upload can hang forever** (`export_job.py:42`)
`requests.post` has no `timeout`. If the endpoint stops responding, the job never finishes and never errors. Fixing #1 won't catch this.
- *Fix:* add `timeout=(5, 60)` or similar.

**4. There are no tests**
The docstring says `test_export_job.py` covers the CSV header and one row, but that file isn't in this directory. Even if it exists somewhere else, its described scope misses the risky paths. Tests needed:
- an upload failure makes the job fail, not exit 0
- a fetch failure makes the job fail
- an empty day: should finance get a header-only file, or nothing?
- amount formatting (see #5)
- the date window is `[yesterday 00:00, today 00:00)`, and `run()` passes the right day

## Should fix

**5. Amounts are calculated as floats** (`export_job.py:37`)
`amount_cents / 100` gives `1.0` for 100 cents and `19.99` for 1999. So the decimal places vary from row to row. It's also wrong for currencies with no minor unit: a JPY invoice of ¥500 stored as `500` exports as `5.0`.
- *Fix:* use `Decimal(amount_cents) / 100` formatted to 2 places, or ideally a per-currency exponent. Also confirm the format finance actually expects.

**6. Timezone of "yesterday" is unclear** (`export_job.py:47`)
`date.today()` uses the server's local time. The query compares `paid_at` against plain dates, which Postgres interprets in the session timezone. If the server, the database and finance don't all mean the same timezone, invoices near midnight land on the wrong day or drop out. Please state which timezone is intended and make it explicit in the code.

**7. Config is read at import time** (`export_job.py:16`)
`UPLOAD_URL` is read from the environment when the module loads. Importing the module without `FINANCE_UPLOAD_URL` set raises `KeyError`, which makes the tests above awkward to write. Read it inside `run()` or `upload()` and pass it in.

## Nice to have
- Accept an optional date argument so a failed night can be re-run without editing code.
- The CSV files with customer emails stay in `/var/exports` forever. Decide whether they should be retained or deleted.

What's already fine: the query is parameterised (no SQL injection), the connection is closed in `finally`, and the functions are small and separate.

Items 1–4 are small changes, maybe an hour of work. If they're done tonight with the tests passing, a merge tomorrow is realistic. Item 6 needs an answer from you or finance first.

VERDICT: NOT READY
