It isn't ready to merge yet. Two problems block it: a failed export looks like a success, and the job writes every customer's email address into the logs. A third: the test file the docstring cites (`test_export_job.py`) doesn't exist in this folder, so nothing is tested. All three are small fixes, so tomorrow is still realistic.

## Blockers

**1. Failures are hidden (High)** — `export_job.py:56-57`
`run()` catches every exception, logs one line and returns normally. The process exits with code 0, so cron and any monitoring see a success.
- **Case:** the finance endpoint returns 503. Expected: the job fails and someone is alerted. Actual: one log line saying `export failed: 503 Server Error...` with no stack trace, exit code 0, and finance silently gets no file that night.
- **Fix:** use `log.exception(...)` and then `raise`, or drop the `except` and keep only the `finally`.

**2. Customer emails written to logs (High, privacy)** — `export_job.py:52`
`[row[1] for row in rows]` logs every customer's email address every night. Logs usually have wider access and longer retention than the invoices table.
- **Fix:** log only the count, plus the invoice IDs if you need them.

**3. No tests (High under your TDD standard)**
The docstring says tests exist, but the file isn't in this folder. Even the tests it describes ("CSV header and one row") wouldn't cover issues 1, 4 or 5. Minimum set:
- the CSV header and an amount formatted correctly
- a failed upload is re-raised, not swallowed
- an invoice paid at 23:59:59 and one at 00:00:00 land on the correct days
- the log output contains no email addresses

There's also a testability problem: `UPLOAD_URL = os.environ[...]` at line 16 runs on import, so any test that imports the module crashes unless that variable is set. Read it inside `upload()` or pass it in.

## Should fix (Medium)

**4. Amounts are wrong for some currencies and badly formatted** — `export_job.py:37`
`amount_cents / 100` assumes every currency has 2 decimal places and produces floats.
- **Case:** a ¥500 invoice is stored as `500`. Expected `500`, actual `5.0`. For dollars, $10.00 is exported as `10.0` instead of `10.00`.
- **Fix:** if you only bill in currencies with 2 decimals, use `Decimal(amount_cents) / 100` with fixed 2-place output. Otherwise, look up each currency's number of decimal places.

**5. The day boundary depends on the server's timezone** — `export_job.py:28, 47`
`date.today()` uses the server's local time. A plain date compared against `paid_at` is converted using the database session's timezone. If the cron host, the database and finance's notion of "a day" don't all agree, invoices near midnight end up in the wrong file or in none. I can't verify which timezone `paid_at` is stored in from this file alone. Please confirm it, then set the timezone explicitly (for example, compute UTC start and end times and pass those).

**6. The upload has no timeout** — `export_job.py:42`
`requests.post` without `timeout=` can hang forever on a stalled connection, and the next night's run then overlaps it. Add something like `timeout=60`.

**7. A failed night can't be re-run** — `export_job.py:47`
The day is always "yesterday". If Tuesday's export fails and you re-run it on Thursday, you get Wednesday's file and Tuesday is never sent. Let `run()` take an optional date from the command line.

## Low

- **Info logs never appear:** nothing configures logging in `__main__`, so Python's default level hides both `log.info` lines. Add `logging.basicConfig(level=logging.INFO)`.
- **A partial file can be left behind:** if `write_csv` fails halfway, a truncated CSV stays in `/var/exports`. Write to a temporary file and rename it when complete.
- **Export folder is hardcoded and assumed to exist:** `EXPORT_DIR` is fixed in the code. Read it from config and create it if missing.
- **Question for the product owner:** does finance actually need `customer_email` in the export? If not, removing it also shrinks the privacy exposure.

## What's fine

The SQL is parameterized (no injection risk), the date range is half-open (each invoice lands in exactly one day), the connection is always closed, and upload errors are raised (just swallowed later by issue 1). The small functions are a good basis for tests.

If you fix 1–3 and add timeouts (6) tonight, I'd treat 4, 5 and 7 as must-fix-soon follow-ups. That's only safe if you confirm you bill in 2-decimal currencies and that the servers' timezones match finance's day.

VERDICT: NOT READY
