0

Create a base currency adjustment

by
Published Oct 17, 2025

Creates a base currency adjustment for the given information.

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