I wouldn't merge this tomorrow. The structure is good, but three problems would hurt finance in production. A failed export looks like a success to cron. Every customer email address goes into the logs each night. Money amounts are written as floating-point numbers. Each fix is small, so this is probably a few hours of work, not a redesign.

One more thing first: the docstring points to `test_export_job.py`, but that file isn't in this directory, so I couldn't check the tests.

The structure is clean. It's split into small functions with a single query, it uses a parameterised SQL query, and the connection is always closed. Here is everything I found, most serious first.

## High: fix before merging

**1. Failures are hidden from cron** (`export_job.py:56-57`)
`except Exception` logs the error, then `run()` returns normally and the process exits with code 0. If the finance endpoint returns a 500 at 02:00, cron records a success and nobody gets alerted. Finance just finds no file. The log line also uses `%s`, which drops the traceback.
*Fix:* remove the `try/except`, or use `log.exception(...)` and then `raise`, so the job exits non-zero.

**2. Customer emails are written to the logs** (`export_job.py:52`)
`[row[1] for row in rows]` logs every customer's email address on every run. That copies personal data into log storage, which usually has wider access and longer retention than the database.
*Fix:* log only the count, e.g. `log.info("exporting %d invoices for %s", len(rows), day)`.

**3. Money is written as a float and assumes two decimal places** (`export_job.py:37`)
`amount_cents / 100` returns a float. Two concrete cases:
- 1000 cents is written as `10.0`, not `10.00`. Float rounding can also produce values that don't reconcile exactly.
- A JPY invoice stored as 500 is written as `5.0` (JPY has no minor unit). A currency with three decimal places, like KWD, is also wrong.

*Fix:* use `Decimal(amount_cents) / 100` formatted to two places, or a currency-to-decimal-places lookup if you have non-two-decimal currencies. You could also export cents and let finance divide.

## Medium: fix now or open a ticket

**4. "Yesterday" depends on the server's timezone** (`export_job.py:47`, `:28`)
`date.today()` uses the host's local clock. The `paid_at >= date` comparison uses the database session's timezone. If those two differ (for example, server in UTC and finance expecting their local day), invoices paid near midnight end up in the wrong day's file or are missed.
*Fix:* choose the timezone explicitly and pass timezone-aware datetimes as the boundaries.

**5. The upload has no timeout** (`export_job.py:42`)
`requests.post` without `timeout=` can hang forever if the endpoint stops responding. The next night's run would then overlap with it.
*Fix:* add `timeout=(10, 120)` or similar.

**6. Tests are thin, and the test file is missing**
By the docstring's own description, the tests cover only the CSV header and one row. Nothing covers:
- the upload failing
- a day with zero invoices
- the day boundaries
- the amount formatting

*Fix:* add tests for those cases. Finding 3 is the one most likely to cause a real complaint.

**7. A missing env var crashes on import** (`export_job.py:16`)
`os.environ["FINANCE_UPLOAD_URL"]` runs when the module is imported. Any test that imports `write_csv` must set that variable first, or the import fails with `KeyError`.
*Fix:* read it inside `upload()` or `run()`.

## Low: worth tidying

**8. You can't re-run a past day.** The day is always yesterday. If the job fails on Tuesday, there's no way to re-export Monday without editing code. A `day` parameter or CLI argument fixes this.

**9. Info logs never appear.** Logging is never configured in `__main__`, so the default WARNING level drops the `log.info` lines. Only errors show up. Add `logging.basicConfig(level=logging.INFO)`.

**10. A failed write can leave a partial CSV.** If the job dies mid-write, a partial file stays in `/var/exports`. Writing to a temporary file and renaming it at the end avoids that.

**11. Old CSVs with customer emails pile up on disk.** Nothing deletes old files or restricts their permissions in `/var/exports`. Worth one cleanup rule.

**12. The connection is opened outside the `try`.** That's fine in practice, because a failed connect already exits non-zero. Once finding 1 is fixed, a `with` block, or closing the connection with `contextlib.closing`, would read more cleanly.

Findings 1–3 are each a one- or two-line change plus a test. With those done and the test file in place, I'd call it ready with changes.

VERDICT: NOT READY
