**Not ready to merge tomorrow.** The biggest problem is that the job can fail without anyone finding out. The test file the docstring mentions (`test_export_job.py`) is also not in this directory, so nothing about this job is tested yet.

## Blockers

**1. Failures are hidden from cron** (`export_job.py:56-57`)
The `except Exception` logs the error and then lets the script exit with code 0, which cron treats as success.
- Example: the finance endpoint returns 500, so `raise_for_status()` throws. The job writes one error line and exits 0. Finance gets no file, no alert goes out, and nobody notices until finance asks.
- Fix: log the error, then re-raise it (or `sys.exit(1)`). Better still, drop the `except` and let `finally` close the connection.

**2. Every customer email goes into the logs** (`export_job.py:52`)
`[row[1] for row in rows]` puts the email address of every paid customer in the info log every night. That is personal data in log storage, which usually has wider access and longer retention than the database. Log only the count.

**3. No tests**
`test_export_job.py` doesn't exist next to this file. Even the docstring's description ("CSV header and one row") covers only the easy case. At minimum, tests should cover:
- the upload fails, so the job exits non-zero
- the database fails, so the job exits non-zero and the connection is still closed
- a day with no invoices (decide what that should do: a header-only file, or skip the upload)
- amount formatting (see item 5)
- the date window passed to the query

To make these tests easy to write, see the small refactor under "Should fix" (pass `day` and the connection in as arguments).

## Should fix before merge

**4. Upload has no timeout** (`export_job.py:42`)
If the endpoint stops responding, `requests.post` waits forever. The next night's run then starts while this one is still hung. Add something like `timeout=60`.

**5. Amounts are converted with float division** (`export_job.py:37`)
- `1000 / 100` comes out as `10.0`, not `10.00`. Finance spreadsheets and importers often expect two decimal places.
- It also assumes every currency has 2 decimal places. A JPY invoice of ¥500, stored as `500`, would be exported as `5.0`.

Use `Decimal` and per-currency decimal places, or export `amount_cents` unchanged and let finance divide.

**6. Timezone of "yesterday" is unclear** (`export_job.py:47`, `:28`)
`date.today()` uses the server's local timezone. Comparing `paid_at` to a plain date uses the database session's timezone. If those two differ, invoices paid near midnight end up in the wrong day's file or are missing from both. Pick one timezone (probably UTC, or whatever finance means by "a day") and say so explicitly in the code.

**7. A missed day can't be re-run**
The day is always computed from "today". If Tuesday's run fails, you can't export Monday on Wednesday without editing the code. Make `day` an argument of `run(day=None)` and add a CLI flag. This also makes the date logic testable.

## Minor

- `UPLOAD_URL = os.environ[...]` runs at import time (`:16`). Importing the module in a test without that environment variable set fails with `KeyError`. Read it inside `upload()` or `run()`.
- Nothing sets up logging. When run from cron, `log.info` output goes nowhere and only warnings and errors reach stderr. Add `logging.basicConfig(...)` under `__main__`.
- The CSV files in `/var/exports` contain customer emails and are never deleted. They get default file permissions. Decide on a retention period and restrict the permissions.

## What's fine

The query uses parameters (no SQL injection risk). The half-open date range `>= day AND < day+1` is correct. The connection is closed in `finally`. The functions are small and each does one job.

Fixing items 1 to 4 is about an hour's work plus the tests. Items 5 and 6 need a quick answer from finance about what amount format and which timezone they expect.

VERDICT: NOT READY
