**Not ready to merge as-is, but you can probably get it ready by tomorrow.** Two problems block the merge. First, if the export fails, nobody finds out. Second, it writes every customer's email address to the logs. The tests the docstring mentions also don't exist. Each fix is small.

### Must fix before merge

**1. A failed export looks like a success (High), `export_job.py:56-57`**
`except Exception` logs the error and returns normally, so the process exits with code 0. Cron and any monitoring will see a successful run.
- Example: the finance endpoint returns 503 at 02:00. `raise_for_status()` raises, the error goes to the log, and the exit code is still 0. Finance gets no file and no alert fires.
- Expected: log the error, then re-raise it (or `sys.exit(1)`) so the job fails visibly.

**2. Customer emails are written to the logs (High), `export_job.py:52`**
`[row[1] for row in rows]` puts every customer's email into an INFO log line, every night. That's personal data leaking into log storage, which usually has wider access and longer retention than the database. Log only the count.

**3. The tests don't exist (High), `export_job.py:3`**
The docstring says the job is tested by `test_export_job.py`, but that file isn't in the directory. Even as described (a CSV header and one row), it would miss the riskiest paths. Minimum test set:
- `write_csv`: header, amount formatting, and a day with no invoices.
- `run`: an upload failure must make the job fail (this test would catch issue 1).
- `run`: the log output must not contain an email address (this would catch issue 2).
- `fetch_invoices`: the date range starts at midnight yesterday and stops before midnight today.

**4. Importing the module crashes without an env var (Medium), `export_job.py:16`**
`os.environ["FINANCE_UPLOAD_URL"]` runs when the module is imported, so any test that imports it raises `KeyError` unless the variable is set. Read it inside `upload()` or `run()` instead. That also makes the tests above easy to write.

**5. The upload can hang forever (Medium), `export_job.py:42`**
`requests.post` has no `timeout`. If the endpoint stalls, the job never finishes and the next night's run can overlap with it. Add something like `timeout=60`.

### Should fix, or confirm with finance

**6. Amounts are wrong for currencies without 2 decimal places (Medium), `export_job.py:37`**
`amount_cents / 100` assumes every currency has cents. A ¥500 invoice is stored as `500` and exported as `5.0`, but it should be `500`. Even for USD, you're exporting floats (`1999` becomes `19.99`, and a whole-dollar `2000` becomes `20.0`). Either look up each currency's number of decimal places and format with `Decimal`, or export the raw integer `amount_cents` and let finance convert it. Check which format finance expects.

**7. Which "yesterday" does finance mean? (Medium, can't verify from here), `export_job.py:28, 47`**
`date.today()` uses the server's timezone. If `paid_at` is a `timestamptz`, Postgres compares it against midnight in the database session's timezone. If those two timezones differ from each other, or from the business day finance uses, invoices near midnight end up in the wrong day's file. I can't see the schema or server config, so this needs checking. Passing explicit UTC (or business-timezone) datetimes would remove the ambiguity.

### Worth a ticket, not blocking

- **No way to re-run a past day.** The date is always "yesterday". After a failed night, someone would have to edit code to backfill. Accepting an optional date argument fixes that.
- **Files with customer data pile up.** CSVs containing emails stay in `/var/exports` indefinitely, including partial files from failed runs. Decide on a retention or cleanup policy.
- **No-invoice days upload a header-only file.** That's probably fine, but check with finance that they expect it.

The job's overall structure is sound: fetch, write and upload are separate functions with a clean `run()` around them. That makes the tests straightforward to add. Fixing 1–5 is maybe an hour or two of work, and then I'd be comfortable with it merging tomorrow.

VERDICT: NOT READY
