Skip to main content

Function: resendInvoiceEmail()

resendInvoiceEmail(companyId, actorId, invoiceId): Promise<{ skipReason?: "unconfigured" | "disabled"; status: "sent" | "skipped" | "failed"; } | { error: string; }>

Defined in: src/server/services/invoice/send.ts:266

Re-send an already-issued invoice's email (no state/number/lock change) via the outbound_emails outbox. Used by the "Resend" action on the invoices review tab. Re-renders the email fresh from the invoice's stored fields (so any per-facility template / first-name greeting / {token} fills are current), re-attaches the stored PDF if present, addresses the active billing contacts (falling back to admin contacts), CC's the facility's flagged contacts, records the attempt in outbound_emails, and persists the delivery outcome onto the invoice. Money fields are integer USD cents. Company-scoped: only acts on an invoice belonging to companyId.

Parameters

companyId

string

Tenant scope; the invoice and all lookups are filtered to this company.

actorId

string

User performing the resend; recorded as created_by on the outbound_emails row.

invoiceId

string

Invoice to resend.

Returns

Promise<{ skipReason?: "unconfigured" | "disabled"; status: "sent" | "skipped" | "failed"; } | { error: string; }>

On success, the delivery outcome { status, skipReason? }status is 'sent', 'skipped' (with skipReason 'unconfigured'/'disabled'), or 'failed'; resending is a no-op to issuance regardless of delivery status. On a precondition failure, { error } with a user-facing message: invoice not found, void invoice (cannot be resent), or no active billing contact to address.