I wouldn't merge this tomorrow as it stands. The job is short and easy to follow, but two of its problems would hurt in production. When an export fails, nobody finds out. And it writes every customer's email address into the logs. On top of that, the test file the docstring points to doesn't exist. All three are small fixes, about half a day of work including tests.

## Blocking issues

**1. Failures are hidden from cron (High).** `export_job.py:56-57` catches every exception, logs one line and returns normally, so the process exits with code 0.
- **Example:** the finance endpoint returns 503 at 02:00. `raise_for_status()` raises, the error is logged, and the job exits 0. Cron and any monitoring record a successful run, and finance gets no file for that day.
- **Expected:** the job exits non-zero so the failure is noticed.
- **Fix:** keep the log line but change it to `log.exception(...)` so the traceback is kept, then re-raise (or `sys.exit(1)`).

**2. Customer emails go into the logs (High).** `export_job.py:52` logs `[row[1] for row in rows]`, which is every customer email, at INFO level on every run. That is personal data spreading into log storage, which usually has wider access and longer retention than the database. Log only the count.

**3. The tests the docstring cites don't exist (High).** Line 3 says the job is "Tested by test_export_job.py", but there is no such file in the directory. Even that description would only cover the CSV header and one row. Here is what needs tests before merge:
- `write_csv`: amount formatting (see issue 4), and that the header matches the column order.
- `fetch_invoices`: the date bounds passed to the query.
- `run`: a failed upload makes the job exit non-zero (issue 1).
- `run`: no emails appear in the logs (issue 2).
- `upload`: an HTTP error status raises.

## Should fix (not blocking alone)

**4. Amounts use floating-point division and assume 2 decimal places (Medium).** Line 37 computes `amount_cents / 100`.
- **Example:** 1000 cents comes out as `10.0` rather than `10.00`.
- **Example:** a JPY invoice of ¥500 stored as 500 comes out as `5.0`, which is wrong because yen has no minor unit.
- **Fix:** format with `Decimal`. If you have non-2-decimal currencies, look up decimal places per currency, or ask finance whether they'd rather receive cents.

**5. No timeout on the upload (Medium).** `requests.post` on line 42 has no `timeout`, so a stalled endpoint can hang the job indefinitely. The next night's run could then overlap it. Add `timeout=(5, 60)` or similar.

**6. The required config is read at import time (Low).** Line 16 reads `os.environ["FINANCE_UPLOAD_URL"]` when the module loads. Importing the module without that variable set raises `KeyError`, which makes tests awkward. Read it inside `upload()` or `run()` instead.

**7. `run()` is hard to test (Low).** It hardcodes `date.today()` and creates its own DB connection. Accepting `day` and `conn` as optional parameters would make issues 1–3 straightforward to test, and would let you re-run a missed day by hand.

## Worth checking (speculative, depends on your setup)

- **Timezone of "yesterday".** `date.today()` uses the server's local timezone. If `paid_at` is a `timestamptz`, Postgres turns the date bounds into timestamps using the DB session's timezone. If the server and DB timezones differ, invoices near midnight can be skipped or exported twice. Pin both to UTC, or whatever finance defines as "a day".
- **Customer data on disk.** Each CSV with customer emails stays in `/var/exports` forever. Check whether there's a retention or cleanup policy.
- **Re-runs.** If you re-run a day by hand, does finance's endpoint dedupe the file, or would they get duplicates?

The fix order is 1 → 2 → 3 (with 7 to make testing easy) → 4 → 5. Issues 1 and 2 are each a few lines of code.

VERDICT: NOT READY
