**Not mergeable as it stands, but it's close.** The structure is good: small functions, parameterized SQL, a `finally` that closes the connection, and the `with` blocks for the cursor and file. Two problems need fixing before merge. The rest can follow.

## Must fix before merge

1. **Failures are swallowed, so cron never learns the export failed** (`export_job.py:56-57`). `run()` catches every exception, logs one line, and exits 0.
   - Case: the finance endpoint returns a 500 at 02:00. The job exits successfully, no alert fires, and finance has no file for that day until someone notices.
   - Fix: use `log.exception(...)` and re-raise, or call `sys.exit(1)`, so cron and monitoring see the failure.

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 customer's email address, every night. That is personal data in log storage, and it makes a long line on busy days. Log the count and the date only.

## Should fix (soon, ideally in this PR)

3. **No timeout on `requests.post`** (`export_job.py:42`). If the endpoint hangs, the job hangs forever and the next night's run may overlap it. Add `timeout=30` or similar.

4. **Money is exported as a float** (`export_job.py:37`). `amount_cents / 100` turns integers into floats, which is risky for a finance file. It also assumes every currency has two decimals, so JPY (0 decimals) or KWD (3 decimals) would be wrong by a factor of 100 or 10. Use `Decimal` with the currency's exponent, or export `amount_cents` as-is and let finance divide.

5. **Time zones are undefined** (`export_job.py:47, 28`). `date.today()` uses the server's time zone, and the query compares `paid_at` to a bare date, which uses the database session's time zone.
   - Case: the server is in UTC, the DB session is in US Eastern, and "yesterday" is cut at a different midnight than finance expects.
   - Fix: pick one zone (probably UTC), make the boundaries explicit timestamps, and document the choice.

6. **Tests cover very little.** `test_export_job.py` checks the CSV header and one row. Still untested:
   - an empty day
   - `fetch_invoices` boundaries (an invoice at exactly midnight, and one just outside)
   - `upload` on a non-2xx response
   - `run()` failure behavior, which would have caught #1
   - amounts like 1999 and 5

   Under your TDD standard, #1, #4 and #5 each need a failing test first.

## Minor

7. **`UPLOAD_URL = os.environ[...]` is read at import time** (`export_job.py:16`). Importing the module without the variable set raises `KeyError`, which makes tests and tooling awkward. Read it inside `run()` or pass it in.
8. **Re-runs are not idempotent.** Running the job twice overwrites the local file and uploads a duplicate. This is fine if the endpoint dedupes by filename. Confirm that, or note it.
9. **The CSV file is written non-atomically, with default permissions, and never cleaned up.** It contains customer emails and stays in `/var/exports` indefinitely. Write to a temp name and rename, set mode `0600`, and decide on a retention policy.
10. **`EXPORT_DIR` is hard-coded and not checked.** A missing directory fails with a plain `FileNotFoundError`. Make it configurable.
11. **Logging is never configured.** Nothing calls `logging.basicConfig` under `__main__`, so the `info` lines may not appear under cron. Only warnings and errors reach stderr by default.
12. **`fetchall()` loads everything into memory.** This is fine now. Switch to a streaming cursor if volume grows.
13. **CSV formula injection.** An email starting with `=`, `+` or `-` could execute as a formula if finance opens the file in Excel. Low risk, but worth a sanitizing step if the file is opened by hand.
14. **Empty days upload a header-only file.** This is probably correct (it proves the job ran), but make it a deliberate choice and add a test.

## Path to merge

Fix #1 and #2 (about ten minutes), add #3 and a failure-path test, and write down the decisions on #4 and #5. Everything below that can be tracked as follow-ups. I couldn't run the tests, so none of this has been checked against `test_export_job.py` or a live database.

VERDICT: READY WITH CHANGES
