Not quite ready to merge. Two small fixes are needed first, and the rest of the file is in good shape.

The structure is clean. Fetch, write and upload are separate functions, the query is parameterized, the connection is always closed, and the file handles use context managers.

**Fix before merging**

1. **Failures look like successes.** In `run()` (lines 56-57), `except Exception` logs the error and then returns normally, so cron sees exit code 0. If the upload returns a 500 or the database is down, finance gets no file and nothing alerts anyone. Re-raise after logging, or call `sys.exit(1)`. Failures then show up in whatever monitors cron.
2. **Customer emails go into the logs.** Line 52 logs `[row[1] for row in rows]`, which is every customer email for the day. That puts personal data into log storage, where it usually lives longer and is shared more widely than the finance data. The count alone is enough: `log.info("exporting %d invoices for %s", len(rows), day)`.

**Worth doing, but it could follow in a later PR**

3. **Amounts as floats.** `amount_cents / 100` gives a float. In Python, 1999 cents becomes `19.99`, but a value like `0.1 + 0.2` shows how float output can drift. Formatting with `Decimal(amount_cents) / 100` or `f"{amount_cents/100:.2f}"` keeps finance's numbers exact.
4. **Time zones.** `datetime.date.today()` uses the server's local time zone, and the query compares it to `paid_at`. If `paid_at` is stored in UTC and the server isn't, the day window can be off by hours, and invoices could land in the wrong day's file. Please confirm both use the same zone, and make that explicit in the code.
5. **Test coverage.** The docstring says the tests cover the CSV header and one row. Nothing covers the paths that matter most:
   - the empty-day case
   - the upload failing, which would have caught issue 1
   - the day-boundary query
   - a rerun overwriting the same file

   A test that mocks `requests.post` to return a 500 and asserts that `run()` fails would be a good addition alongside fix 1.

Also, `UPLOAD_URL = os.environ["FINANCE_UPLOAD_URL"]` runs at import time, so merely importing the module fails if the variable is unset. That is acceptable for a cron script, but your tests need to set it first.

Fixes 1 and 2 are a few lines each, so tomorrow is realistic.

VERDICT: READY WITH CHANGES
