The monthly publish-invoices run targets the month that just ended: a run at the start of July targets June. That's correct for usage invoices, which are billed in arrears. But manual bills are selected by date-range overlap with the same target month, which gives them arrears semantics too: a contract term starting July 1 isn't selected until the August run, a month after the customer should have received the invoice.
Contract bills are billed in advance. A run targeting month M should publish any manual bill whose term starts in month M+1 — a term starting on the 1st or mid-month alike goes out with that run. Today the workaround is a second, manually-targeted run (--month <M+1> --tenants ...) for each affected tenant, which only happens if someone notices the bill was missed.
Fix
Widen the manual-invoice selection window in publish-invoices to also include manual_bills rows whose date_start falls in the month after the target month. The send-invoices phase filters manual invoices by the same date overlap client-side and needs the matching change, or publish will create drafts that send never finalizes. Usage (final) invoice selection is unchanged.
The monthly
publish-invoicesrun targets the month that just ended: a run at the start of July targets June. That's correct for usage invoices, which are billed in arrears. But manual bills are selected by date-range overlap with the same target month, which gives them arrears semantics too: a contract term starting July 1 isn't selected until the August run, a month after the customer should have received the invoice.Contract bills are billed in advance. A run targeting month M should publish any manual bill whose term starts in month M+1 — a term starting on the 1st or mid-month alike goes out with that run. Today the workaround is a second, manually-targeted run (
--month <M+1> --tenants ...) for each affected tenant, which only happens if someone notices the bill was missed.Fix
Widen the manual-invoice selection window in
publish-invoicesto also includemanual_billsrows whosedate_startfalls in the month after the target month. Thesend-invoicesphase filters manual invoices by the same date overlap client-side and needs the matching change, or publish will create drafts that send never finalizes. Usage (final) invoice selection is unchanged.