I don't think it should merge tomorrow. The happy path looks right, but if the export fails, nobody finds out, and the tests the file says exist aren't in the folder.

## Must fix before merging

**1. Failures are silent (lines 56–57).** `run()` catches every exception, logs one line and returns normally, so cron sees exit code 0. For example, if the finance endpoint returns a 500 at 02:00, `raise_for_status()` raises, the error is caught, and the job reports success. Finance gets no file and no alert goes out. The same happens if the database query fails. Fix: after logging, re-raise (or `sys.exit(1)`) so cron and your monitoring see the failure. Use `log.exception(...)` so the stack trace is kept.

**2. Every customer email gets logged (line 52).** `[row[1] for row in rows]` puts the email address of every paid customer into the logs each night. That's personal data going to wherever your logs end up. Log only the count.

**3. The tests don't exist.** The docstring says it's "Tested by test_export_job.py (CSV header and one row)", but there's no such file in this directory. Even that described test would only cover one success case. At minimum it should cover:
- no invoices that day (header-only file, and does finance want a file at all?)
- amount formatting (see item 5)
- upload fails, so `run()` should fail (this would have caught item 1)
- DB error, so `run()` should fail
- a test that the date range is yesterday 00:00 up to today 00:00

To make this testable, stop reading `FINANCE_UPLOAD_URL` when the module is imported (line 16). Right now, importing the module in a test with that variable unset crashes with `KeyError`. Read it inside `run()` or pass it in.

**4. The upload has no timeout (line 42).** `requests.post` without `timeout=` can hang forever if the endpoint stalls, and the next night's run would pile up behind it. Add a timeout, and probably a couple of retries.

## Should fix or decide

**5. Amounts are floats and are formatted inconsistently (line 37).** `amount_cents / 100` turns 1050 into `10.5` and 1000 into `10.0`, not `10.50` / `10.00`. It also assumes every currency has two decimal places. If you store JPY in its smallest unit, 500 yen exports as `5.0`. Use `Decimal`, format to the currency's number of decimal places, or just export `amount_cents` and let finance divide.

**6. Which "yesterday"?** `date.today()` uses the server's local timezone. Postgres then turns the date into midnight in the database session's timezone. If those two differ from the timezone finance means by "yesterday" (e.g. UTC on the server, local time for finance), invoices near midnight end up in the wrong day's file. Use one explicit timezone throughout.

**7. A missed day can't be re-run.** The date is always yesterday. If the job fails on Tuesday, there's no way to export Monday's invoices on Wednesday. Add an optional `--date` argument.

**8. Smaller items:**
- Nothing calls `logging.basicConfig` under `__main__`, so the two `log.info` lines never print. Only the error line shows up.
- The CSV files in `/var/exports` contain customer emails, are created with the default permissions, and are never cleaned up.

## Fine as is
The query is parameterised (no SQL injection risk). The connection is always closed in `finally`. The date range correctly includes midnight at the start and excludes it at the end. `raise_for_status()` is in the right place, though item 1 cancels it out.

Items 1–4 are each small changes. Once they're done and the tests exist and pass, this is close to ready.

VERDICT: NOT READY
