0

Categorize a vendor payment

by
Published Oct 17, 2025

Categorize an uncategorized transaction as Vendor Payment.

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 a vendor payment
7
 * Categorize an uncategorized transaction as Vendor Payment.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  transaction_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    vendor_id?: string;
15
    bills?: {
16
      bill_payment_id?: string;
17
      bill_id?: string;
18
      amount_applied?: number;
19
      tax_amount_withheld?: number;
20
    }[];
21
    payment_mode?: string;
22
    description?: string;
23
    date?: string;
24
    reference_number?: string;
25
    exchange_rate?: number;
26
    paid_through_account_id?: string;
27
    amount?: number;
28
    custom_fields?: { index?: number; value?: string }[];
29
    is_paid_via_print_check?: false | true;
30
    check_details?: { memo?: string; check_number?: string }[];
31
  },
32
) {
33
  const url = new URL(
34
    `https://www.zohoapis.com/books/v3/banktransactions/uncategorized/${transaction_id}/categorize/vendorpayments`,
35
  );
36
  for (const [k, v] of [["organization_id", organization_id]]) {
37
    if (v !== undefined && v !== "" && k !== undefined) {
38
      url.searchParams.append(k, v);
39
    }
40
  }
41
  const response = await fetch(url, {
42
    method: "POST",
43
    headers: {
44
      "Content-Type": "application/json",
45
      Authorization: "Zoho-oauthtoken " + auth.token,
46
    },
47
    body: JSON.stringify(body),
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.json();
54
}
55