Not ready to merge. Two problems would hurt in production: when the job fails it still exits as if it succeeded, so nobody finds out the finance export is missing, and it writes every customer's email address to the logs on every run. Both are quick fixes. The bigger gap is tests: the docstring says `test_export_job.py` covers the job, but that file isn't in this folder.

## Problems, by severity

**High: fix before merge**

1. **Failures are logged and then ignored** (`export_job.py:56-57`). `except Exception` logs the error and `run()` returns normally, so cron sees exit code 0. For example, if the finance endpoint returns HTTP 500, the log says "export failed", nothing alerts, and finance has no file for that day. Expected: log it, then re-raise (or `sys.exit(1)`) so cron or monitoring flags the failure.
2. **Customer emails go into the logs** (`export_job.py:52`). `[row[1] for row in rows]` writes every customer email at INFO level, so personal data ends up in log storage, which usually has wider access and longer retention than the database. Log the count only, or the invoice IDs if you need traceability.
3. **The tests don't exist here, and wouldn't be enough if they did.** `test_export_job.py` is missing from this directory. The docstring says it only checks "CSV header and one row". Nothing tests what happens when the upload fails, when a day has no invoices, or that the job reports failure correctly (problem 1 would have been caught by that last one). There's a second barrier: line 16 reads `os.environ["FINANCE_UPLOAD_URL"]` at import time, so any test that imports the module crashes unless that variable is set.

**Medium: fix before merge if you can, otherwise open a ticket**

4. **Amounts are converted with float division** (`export_job.py:37`). `amount_cents / 100` turns 1000 into `10.0`, not `10.00`, and 5 into `0.05`, which float precision can occasionally render oddly. It also assumes every currency has 100 minor units, which is wrong for JPY (0 decimals) and KWD (3 decimals). Use `Decimal(amount_cents) / 100` formatted to the currency's number of decimals, or export the integer cents and let finance convert.
5. **No timeout on the upload** (`export_job.py:42`). `requests.post` with no `timeout` can hang forever if the endpoint stops responding, and the next night's run will stack on top of it. Add something like `timeout=60`, and consider retrying a couple of times.
6. **"Yesterday" depends on the server's timezone** (`export_job.py:47`). `date.today()` uses the host's local timezone. If `paid_at` is a `timestamptz`, the database session's timezone decides where the day boundary falls. If the two disagree, invoices paid near midnight end up in the wrong day's file or in no file. Pin both to one timezone, probably UTC or whatever finance treats as "the business day".
7. **Can't re-run for a specific day.** The day is always "yesterday", so after a failure (or a fix to problem 6) you can't regenerate an earlier day's export without editing the code. Make `day` an optional argument or command-line flag.

**Low: follow-up ticket is fine**

8. Export files containing customer emails pile up in `/var/exports` forever, with default file permissions. Add a retention or cleanup policy.
9. The CSV is written straight to its final path. If the job crashes mid-write, a partial file sits there. Write to a temp file and rename it.
10. Emails go into the CSV unescaped. A value starting with `=` could run as a formula if finance opens the file in Excel (CSV injection). This risk is minor for email addresses.
11. `fetchall()` loads the whole day into memory. That's fine at today's volumes and only matters if they grow a lot.

## What I'd do before tomorrow

Fixing 1, 2 and 5, plus moving the environment-variable read into `run()`, is about an hour of work. Then write tests for: upload fails → job exits non-zero, empty day → header-only CSV, and amount formatting (including 1000 cents → `10.00`). Problems 4 and 6 depend on what finance expects for currency format and day boundaries, so it's worth asking them today. I haven't run anything, because the test file isn't present.

VERDICT: NOT READY
