0

Create a fixed asset type

by
Published Oct 17, 2025

Create a fixed asset type.

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 fixed asset type
7
 * Create a fixed asset type.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    fixed_asset_type_name: string;
14
    expense_account_id: string;
15
    depreciation_account_id: string;
16
    depreciation_method: string;
17
    depreciation_frequency: string;
18
    depreciation_percentage: number;
19
    total_life: number;
20
    salvage_value: string;
21
    computation_type: string;
22
  },
23
) {
24
  const url = new URL(`https://www.zohoapis.com/books/v3/fixedassettypes`);
25
  for (const [k, v] of [["organization_id", organization_id]]) {
26
    if (v !== undefined && v !== "" && k !== undefined) {
27
      url.searchParams.append(k, v);
28
    }
29
  }
30
  const response = await fetch(url, {
31
    method: "POST",
32
    headers: {
33
      "Content-Type": "application/json",
34
      Authorization: "Zoho-oauthtoken " + auth.token,
35
    },
36
    body: JSON.stringify(body),
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44