0

Categorize as Customer Payment refund

by
Published Oct 17, 2025

Categorizing bank transactions as Payment Refund.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Categorize as Customer Payment refund
7
 * Categorizing bank transactions as Payment Refund.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  statement_line_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    date: string;
15
    refund_mode?: string;
16
    reference_number?: string;
17
    amount: number;
18
    exchange_rate?: number;
19
    from_account_id: string;
20
    description?: string;
21
  },
22
) {
23
  const url = new URL(
24
    `https://www.zohoapis.com/books/v3/banktransactions/uncategorized/${statement_line_id}/categorize/paymentrefunds`,
25
  );
26
  for (const [k, v] of [["organization_id", organization_id]]) {
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