export type DeleteApiEstimatesIdArgs = {id: string}; export type DeleteApiEstimatesIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Hard-delete an estimate. Allowed only when the estimate is provably inert — a * EstimateStatus.Draft that has never been converted and has no line * that has performed/dispensed anything. Anything with committed side effects * (dispensed stock, DEA entries, a cut Rx) is refused with 409: the raw cascade * delete reverses none of that, so those lines must be voided first (which restores * stock, files the DEA correction, cancels the Rx). Mirrors the per-line delete guard * at Task<ActionResult> EstimatesController.DeleteItemAsync(string id, string lineId). * * DELETE /Estimates/{id} */ export const deleteApiEstimatesId = async (args: DeleteApiEstimatesIdArgs, options?: DeleteApiEstimatesIdOptions) => { 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(/\/+$/, '')}/Estimates/${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 };