0

Create a Quote

by
Published Oct 17, 2025

Create a quote for your customer.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create a Quote
7
 * Create a quote for your customer.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  send: string | undefined,
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
      product_type?: string;
42
      hsn_or_sac?: string;
43
      sat_item_key_code?: string;
44
      unitkey_code?: string;
45
      quantity: number;
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(`https://www.zohoapis.com/billing/v1/estimates`);
75
  for (const [k, v] of [
76
    ["send", send],
77
    ["ignore_auto_number_generation", ignore_auto_number_generation],
78
  ]) {
79
    if (v !== undefined && v !== "" && k !== undefined) {
80
      url.searchParams.append(k, v);
81
    }
82
  }
83
  const response = await fetch(url, {
84
    method: "POST",
85
    headers: {
86
      "X-com-zoho-subscriptions-organizationid":
87
        X_com_zoho_subscriptions_organizationid,
88
      "Content-Type": "application/json",
89
      Authorization: "Zoho-oauthtoken " + auth.token,
90
    },
91
    body: JSON.stringify(body),
92
  });
93
  if (!response.ok) {
94
    const text = await response.text();
95
    throw new Error(`${response.status} ${text}`);
96
  }
97
  return await response.json();
98
}
99