0

Update a Quote

by
Published Oct 17, 2025

Update an existing quote. To delete a line item just remove it from the line_items list.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Update a Quote
7
 * Update an existing quote. To delete a line item just remove it from the line_items list.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  estimate_id: string,
12
  ignore_auto_number_generation: string | undefined,
13
  X_com_zoho_subscriptions_organizationid: string,
14
  body: {
15
    customer_id: string;
16
    contact_persons?: string[];
17
    template_id?: string;
18
    place_of_supply?: string;
19
    gst_treatment?: string;
20
    tax_treatment?: string;
21
    gst_no?: string;
22
    estimate_number?: string;
23
    reference_number?: string;
24
    date?: string;
25
    expiry_date?: string;
26
    exchange_rate?: number;
27
    discount?: number;
28
    is_discount_before_tax?: false | true;
29
    discount_type?: string;
30
    is_inclusive_tax?: false | true;
31
    custom_body?: string;
32
    custom_subject?: string;
33
    salesperson_name?: string;
34
    custom_fields: { label?: string; value?: string }[];
35
    line_items?: {
36
      item_id: string;
37
      name?: string;
38
      description?: string;
39
      item_order?: number;
40
      rate: number;
41
      quantity: number;
42
      product_type?: string;
43
      hsn_or_sac?: string;
44
      sat_item_key_code?: string;
45
      unitkey_code?: string;
46
      unit?: string;
47
      discount_amount?: number;
48
      discount?: number;
49
      tax_id?: string;
50
      tds_tax_id?: string;
51
      tax_exemption_id?: string;
52
      avatax_tax_code?: string;
53
      avatax_use_code?: string;
54
      tax_name?: string;
55
      tax_type?: string;
56
      tax_percentage?: number;
57
      item_total?: number;
58
    }[];
59
    notes?: string;
60
    terms?: string;
61
    shipping_charge?: string;
62
    adjustment?: number;
63
    adjustment_description?: string;
64
    tax_id?: string;
65
    tax_exemption_id?: string;
66
    tax_authority_id?: string;
67
    avatax_use_code?: string;
68
    avatax_tax_code?: string;
69
    avatax_exempt_no?: string;
70
    vat_treatment?: string;
71
    project_id?: string;
72
  },
73
) {
74
  const url = new URL(
75
    `https://www.zohoapis.com/billing/v1/estimates/${estimate_id}`,
76
  );
77
  for (const [k, v] of [
78
    ["ignore_auto_number_generation", ignore_auto_number_generation],
79
  ]) {
80
    if (v !== undefined && v !== "" && k !== undefined) {
81
      url.searchParams.append(k, v);
82
    }
83
  }
84
  const response = await fetch(url, {
85
    method: "PUT",
86
    headers: {
87
      "X-com-zoho-subscriptions-organizationid":
88
        X_com_zoho_subscriptions_organizationid,
89
      "Content-Type": "application/json",
90
      Authorization: "Zoho-oauthtoken " + auth.token,
91
    },
92
    body: JSON.stringify(body),
93
  });
94
  if (!response.ok) {
95
    const text = await response.text();
96
    throw new Error(`${response.status} ${text}`);
97
  }
98
  return await response.json();
99
}
100