The structure is solid. Fetch, write, upload and run are separate small functions, the query is parameterized, and the connection is closed in a `finally`. Two problems should be fixed before merging, and both are small.

## Must fix before merge

1. **Failures are swallowed, so cron never learns the job failed** (`export_job.py:56-57`).
   - `except Exception` logs the error, and the process then exits 0.
   - Example: the finance endpoint returns a 500 at 02:00. The job logs one line, cron reports success, and finance has no file for that day. Nobody finds out until someone asks.
   - Fix: re-raise, or call `sys.exit(1)` after logging. Use `log.exception` so the traceback is kept.

2. **Customer emails are written to the logs** (`export_job.py:52`).
   - The log line includes `[row[1] for row in rows]`, which is every customer email for the day.
   - That puts personal data into log storage, probably with different retention and access than the invoice database.
   - Fix: log the count and the day only.

## Should fix

3. **Day boundaries depend on timezone** (`export_job.py:47`, `export_job.py:28`).
   - `date.today()` uses the server's timezone. The query compares `paid_at` to a plain date, so it uses the database session's timezone.
   - If the two differ, an invoice paid at 23:30 can land in the wrong day's file, or in none.
   - Fix: pick one explicit timezone (probably UTC) and use it for both.

4. **Amounts are computed as floats** (`export_job.py:37`).
   - `amount_cents / 100` gives a float. Most values print fine, but floats can produce things like `0.30000000000000004` in finance data.
   - It also assumes every currency has two decimal places. JPY has none and KWD has three.
   - Fix: use `Decimal` with a per-currency exponent, or export the cents as an integer column.

5. **The upload has no timeout** (`export_job.py:42`).
   - `requests.post` waits forever by default, so a hung endpoint leaves the cron job hanging.
   - Fix: pass `timeout=...`. A small retry on 5xx would also help.

6. **Tests cover very little** (the docstring says header plus one row).
   - Missing cases:
     - an empty day
     - a failed upload, which would have caught #1
     - the day-boundary query, at 23:59:59 and exactly 00:00:00
     - `run()` end to end with a fake connection and a stubbed `requests.post`
   - Adding these comes first for me: #1, #3 and #4 each need a failing test before the fix.

7. **`UPLOAD_URL` is read at import time** (`export_job.py:16`).
   - If `FINANCE_UPLOAD_URL` is unset, importing the module raises `KeyError`. That also affects the test module.
   - Fix: read it inside `run()` or `upload()`.

## Minor

8. **Re-runs can double-upload.** The local file is overwritten, which is fine, but finance receives the file twice. Confirm the endpoint dedupes by filename, or document that it doesn't.
9. **The CSV is written straight to its final path** (`export_job.py:33`). A crash mid-write leaves a partial file. Write to a temp file and rename it.
10. **The CSV contains personal data and sits on disk indefinitely** in `/var/exports`. Check the directory permissions, and consider deleting old files or the one just uploaded.
11. **No logging setup.** There is no `basicConfig`, so `log.info` lines are dropped when run from cron. Only the error would appear, on stderr.
12. **Empty days still upload a header-only file.** This may be what finance wants, but it should be a deliberate choice.
13. **Emails starting with `=`, `+`, `-` or `@` can act as formulas** if finance opens the CSV in Excel. This is low risk but cheap to guard against.
14. **`fetchall()` loads everything into memory.** It's fine at today's volume. A server-side cursor would scale better.
15. **`EXPORT_DIR` is hardcoded.** Make it configurable through an environment variable, like the other settings.

After #1 and #2 are fixed, with tests for #1, the job is safe to run. I'd also make #3 and #5 part of the same change. The rest can follow as tracked tickets.

VERDICT: READY WITH CHANGES
