fix(invoices): badge held (unsent, no send date) invoices as "Draft"
The earlier change only relabeled is_monthly_draft rows. But a per-event invoice created from hours is status 'scheduled' with scheduled_send_at = NULL and is_monthly_draft = false — it never auto-ships (the scheduler only picks rows with scheduled_send_at <= now), yet it still read "Scheduled" on the customer panel + lists. Add a shared isDraftInvoice() helper (scheduled && no send date, or a monthly/manual accumulator) and use it for the badge in the Bills list, the invoice detail header, and the customer profile's invoice panel. A scheduled invoice WITH a future send date keeps "Scheduled".
This commit is contained in:
@@ -98,6 +98,20 @@ export interface InvoiceSummary {
|
||||
isMonthlyDraft?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A "scheduled" invoice with no send date is HELD — the scheduler only
|
||||
* picks up rows whose `scheduled_send_at <= now`, so a null send date
|
||||
* means it never auto-ships and is waiting on the admin (Send now /
|
||||
* Trigger invoice now). Those, plus monthly/manual accumulators, read as
|
||||
* "Draft" everywhere instead of the misleading "Scheduled". A scheduled
|
||||
* invoice WITH a future send date is genuinely scheduled and keeps that
|
||||
* label.
|
||||
*/
|
||||
export function isDraftInvoice(inv: Pick<InvoiceSummary, 'status' | 'scheduledSendAt' | 'isMonthlyDraft'>): boolean {
|
||||
if (inv.isMonthlyDraft) return true;
|
||||
return inv.status === 'scheduled' && !inv.scheduledSendAt;
|
||||
}
|
||||
|
||||
export interface InvoiceDetail extends InvoiceSummary {
|
||||
netAmountMinor: number;
|
||||
vatRate: number | null;
|
||||
|
||||
Reference in New Issue
Block a user