export type DeleteApiInvoicesIdArgs = {id: string}; export type DeleteApiInvoicesIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Hard-delete an invoice. Allowed only when the invoice is provably inert — a * InvoiceStatus.Draft (never sent) with no payment, no dispensed line, * and not the product of a merge. Anything with committed side effects is refused * with 409. An invoice that came from an estimate is refused too: use * "revert to estimate" so the source estimate is returned to a clean state rather * than left accepted-but-unbilled. Deleting a paid/dispensed bill would strand * payments and inventory — those must be reversed through their own paths first. * * DELETE /Invoices/{id} */ export const deleteApiInvoicesId = async (args: DeleteApiInvoicesIdArgs, options?: DeleteApiInvoicesIdOptions) => { const {baseUrl = "https://api.clinicos.vet/backend/business", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/Invoices/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };