**Short answer:** the structure is clean. The functions are small, the query is parameterized, and the connection is closed in a `finally`. But two problems should be fixed before merge: failures are silent, and customer emails go into the logs. Both are small fixes.

## Problems, ranked by severity

**High (fix before merging)**

1. **Failures are swallowed (`export_job.py:56-57`).** `run()` catches every exception, logs it, and exits 0. If the database is down or the upload returns a 500, cron sees success and finance never gets the file.
   - Example: the upload endpoint returns 503. The job logs one line and exits 0, and nobody finds out until finance asks where the file is.
   - Fix: log with `log.exception(...)` and re-raise, or call `sys.exit(1)`.
2. **Customer emails are written to the logs (`export_job.py:52`).** The `info` line logs `[row[1] for row in rows]`, which is every paid customer's email, every night. Log the count and the date only.
3. **Test coverage is too thin for the risks above.** The tests only cover the CSV header and one row. Nothing covers an empty day, a failed upload, a database error, or the day boundary. You'd want a test that asserts the failure path exits non-zero, which would have caught problem 1.

**Medium**

4. **Money is formatted as a float (`export_job.py:37`).** `amount_cents / 100` produces a Python float. Two problems follow:
   - Output like `19.9` instead of `19.90`, and possible float artifacts on large values.
   - Zero-decimal currencies such as JPY would be divided by 100, so ¥500 would export as 5.
   - Fix: use `Decimal(amount_cents) / 100` formatted to the currency's exponent.
5. **"Yesterday" is ambiguous (`export_job.py:47`).** `date.today()` uses the server's local time. The query compares `paid_at` to midnight in the database session's timezone. If those differ, or `paid_at` is `timestamptz`, invoices near midnight can land in the wrong day's file or in two files. Pick one timezone (probably UTC) and apply it in both places.
6. **No timeout on the upload (`export_job.py:42`).** `requests.post` has no timeout and can hang forever. Cron would pile up stuck processes. Add `timeout=30` or similar.
7. **Re-runs are not safe.** A re-run overwrites the local file and uploads again, and there is no retry. If finance's endpoint doesn't dedupe, a manual re-run could double-count. At minimum, document the behavior. Better, send an idempotency key such as the date.

**Low**

8. **`UPLOAD_URL` is read at import time (`export_job.py:16`).** Importing the module without `FINANCE_UPLOAD_URL` set raises `KeyError`, which is awkward for tests. Read it inside `run()`, or pass it in.
9. **Logging is never configured.** Under cron, `info` messages are dropped because the default level is WARNING. Add `logging.basicConfig(level=logging.INFO)` under `__main__`.
10. **The file is written in place with default permissions (`export_job.py:33`).** It contains customer emails.
    - If the job crashes mid-write, a partial file is left behind.
    - Write to a temp file and rename it, and set mode `0o600`.
    - `EXPORT_DIR` is hardcoded and not created if missing.
11. **CSV injection.** An email beginning with `=`, `+`, `-` or `@` could be interpreted as a formula if someone opens the file in Excel. Emails are low risk, but a one-line sanitizer is cheap.
12. **An empty day still uploads a header-only file.** That may be what finance wants, but it should be a deliberate choice, and you may want to log a warning.
13. **Minor style points.**
    - `fetchall()` loads every row into memory, which is fine at this scale.
    - The tuple unpacking in `write_csv` breaks if the query's column order changes. A `DictCursor` or named columns would be sturdier.

## What I'd do before tomorrow

Fix 1 and 2, add the tests for 3, and add the timeout from 6. Those are small changes. The rest can go on a follow-up list, though I'd treat 4 and 5 as the next priority, since they affect finance's numbers.

VERDICT: READY WITH CHANGES
