0

Update a tax

by
Published Oct 17, 2025

Update the details of a simple or compound tax.

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 tax
7
 * Update the details of a simple or compound tax.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  tax_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    tax_name?: string;
15
    tax_percentage?: number;
16
    tax_type?: string;
17
    tax_factor?: string;
18
    tax_specific_type?: string;
19
    tax_authority_name?: string;
20
    tax_authority_id?: string;
21
    country_code?: string;
22
    purchase_tax_expense_account_id?: number;
23
    is_value_added?: false | true;
24
    update_draft_invoice?: false | true;
25
    update_draft_so?: false | true;
26
    is_editable?: false | true;
27
    tds_payable_account_id?: string;
28
  },
29
) {
30
  const url = new URL(
31
    `https://www.zohoapis.com/inventory/v1/settings/taxes/${tax_id}`,
32
  );
33
  for (const [k, v] of [["organization_id", organization_id]]) {
34
    if (v !== undefined && v !== "" && k !== undefined) {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "PUT",
40
    headers: {
41
      "Content-Type": "application/json",
42
      Authorization: "Zoho-oauthtoken " + auth.token,
43
    },
44
    body: JSON.stringify(body),
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52