Skip to main content

Function: invoiceLabelFor()

invoiceLabelFor(invoiceIds, numberById): string | undefined

Defined in: src/lib/invoice/index.ts:284

Display label for the sent invoice(s) a set of hours is already billed on — the subject of the ADR-0050 §3 reissue warning shown on every owner hours-entry surface. Only send_invoices stamps time_entries.invoice_id (a void detaches it), so any id here belongs to an issued invoice.

Fails safe: the presence of an id — not the success of the number lookup — decides whether the warning shows. Ids that resolve are named; if none resolve (missing invoice row, or a failed lookup returning an empty map) the hours are still invoiced, so it falls back to UNNUMBERED_INVOICE_LABEL rather than reading as not-invoiced.

Parameters

invoiceIds

Iterable<string>

The invoice_ids covering those hours; duplicates are collapsed.

numberById

ReadonlyMap<string, string>

Resolved invoice numbers; ids missing from it are dropped from the list (never rendered as "undefined").

Returns

string | undefined

The numbers sorted and comma-joined (e.g. "INV-0002, INV-0007"), the unnumbered fallback when ids exist but none resolve, or undefined only when there are no ids at all — the falsy value the callers branch on to hide the warning.