import type { PaymentMethod } from "./types"; /** * Whether an invoice delivery action (render a PDF, send the email) must be * refused because no payment method is configured — the recipient would * receive a bill with no way to pay it. `allowNoPayment` is the escape hatch * for users who deliberately bill without on-invoice payment instructions * (e.g. they arrange payment out of band). * * Shared by the CLI (`invoice pdf` / `invoice send`) and the web hub API * routes (`GET /api/invoices/[id]/pdf`, `POST /api/invoices/[id]/send`) so the * gate is defined exactly once and can never drift between surfaces. */ export function shouldRefuseNoPayment( paymentMethods: PaymentMethod[] | undefined, allowNoPayment: boolean, ): boolean { return (paymentMethods?.length ?? 0) === 0 && !allowNoPayment; }