0

List recurring bills

by
Published Oct 17, 2025

List all recurring bills with pagination.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * List recurring bills
7
 * List all recurring bills with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  recurring_bill_id: string | undefined,
13
  vendor_id: string | undefined,
14
  vendor_name: string | undefined,
15
  status: string | undefined,
16
  recurrence_name: string | undefined,
17
  currency_id: string | undefined,
18
  currency_code: string | undefined,
19
  currency_symbol: string | undefined,
20
  start_date: string | undefined,
21
  end_date: string | undefined,
22
  source_of_supply: string | undefined,
23
  place_of_supply: string | undefined,
24
  destination_of_supply: string | undefined,
25
  gst_treatment: string | undefined,
26
  gst_no: string | undefined,
27
  tax_treatment: string | undefined,
28
  vat_treatment: string | undefined,
29
  vat_reg_no: string | undefined,
30
  is_abn_quoted: string | undefined,
31
  abn: string | undefined,
32
  is_reverse_charge_applied: string | undefined,
33
  pricebook_id: string | undefined,
34
  pricebook_name: string | undefined,
35
  is_inclusive_tax: string | undefined,
36
  line_items: string | undefined,
37
  is_tds_applied: string | undefined,
38
  notes: string | undefined,
39
  terms: string | undefined,
40
  payment_terms: string | undefined,
41
  payment_terms_label: string | undefined,
42
  custom_fields: string | undefined,
43
  acquisition_vat_summary: string | undefined,
44
  reverse_charge_vat_summary: string | undefined,
45
  acquisition_vat_total: string | undefined,
46
  reverse_charge_vat_total: string | undefined,
47
  created_time: string | undefined,
48
  created_by_id: string | undefined,
49
  last_modified_time: string | undefined,
50
  discount: string | undefined,
51
  discount_account_id: string | undefined,
52
  is_discount_before_tax: string | undefined,
53
) {
54
  const url = new URL(`https://www.zohoapis.com/books/v3/recurringbills`);
55
  for (const [k, v] of [
56
    ["organization_id", organization_id],
57
    ["recurring_bill_id", recurring_bill_id],
58
    ["vendor_id", vendor_id],
59
    ["vendor_name", vendor_name],
60
    ["status", status],
61
    ["recurrence_name", recurrence_name],
62
    ["currency_id", currency_id],
63
    ["currency_code", currency_code],
64
    ["currency_symbol", currency_symbol],
65
    ["start_date", start_date],
66
    ["end_date", end_date],
67
    ["source_of_supply", source_of_supply],
68
    ["place_of_supply", place_of_supply],
69
    ["destination_of_supply", destination_of_supply],
70
    ["gst_treatment", gst_treatment],
71
    ["gst_no", gst_no],
72
    ["tax_treatment", tax_treatment],
73
    ["vat_treatment", vat_treatment],
74
    ["vat_reg_no", vat_reg_no],
75
    ["is_abn_quoted", is_abn_quoted],
76
    ["abn", abn],
77
    ["is_reverse_charge_applied", is_reverse_charge_applied],
78
    ["pricebook_id", pricebook_id],
79
    ["pricebook_name", pricebook_name],
80
    ["is_inclusive_tax", is_inclusive_tax],
81
    ["line_items", line_items],
82
    ["is_tds_applied", is_tds_applied],
83
    ["notes", notes],
84
    ["terms", terms],
85
    ["payment_terms", payment_terms],
86
    ["payment_terms_label", payment_terms_label],
87
    ["custom_fields", custom_fields],
88
    ["acquisition_vat_summary", acquisition_vat_summary],
89
    ["reverse_charge_vat_summary", reverse_charge_vat_summary],
90
    ["acquisition_vat_total", acquisition_vat_total],
91
    ["reverse_charge_vat_total", reverse_charge_vat_total],
92
    ["created_time", created_time],
93
    ["created_by_id", created_by_id],
94
    ["last_modified_time", last_modified_time],
95
    ["discount", discount],
96
    ["discount_account_id", discount_account_id],
97
    ["is_discount_before_tax", is_discount_before_tax],
98
  ]) {
99
    if (v !== undefined && v !== "" && k !== undefined) {
100
      url.searchParams.append(k, v);
101
    }
102
  }
103
  const response = await fetch(url, {
104
    method: "GET",
105
    headers: {
106
      Authorization: "Zoho-oauthtoken " + auth.token,
107
    },
108
    body: undefined,
109
  });
110
  if (!response.ok) {
111
    const text = await response.text();
112
    throw new Error(`${response.status} ${text}`);
113
  }
114
  return await response.json();
115
}
116