Skip to content

billing: publish manual (contract) invoices in advance rather than in arrears #3103

Description

@jshearer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions