0

Create a Bill

by
Published Oct 17, 2025

Creates a Bill in Zoho Inventory. Description about the extra parameter attachment Allowed extensions are gif, png, jpeg, jpg, bmp and pdf.

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 Bill
7
 * Creates a Bill in Zoho Inventory. Description about the extra parameter attachment Allowed extensions are gif, png, jpeg, jpg, bmp and pdf.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    purchaseorder_id?: number;
14
    vendor_id: number;
15
    bill_number: string;
16
    date: string;
17
    due_date: string;
18
    reference_number?: string;
19
    currency_id?: number;
20
    exchange_rate?: number;
21
    is_item_level_tax_calc?: false | true;
22
    notes?: string;
23
    terms?: string;
24
    is_inclusive_tax?: false | true;
25
    custom_fields?: { customfield_id?: number; value?: string }[];
26
    line_items: {
27
      purchaseorder_item_id?: number;
28
      receive_item_id?: number;
29
      line_item_id?: number;
30
      name?: string;
31
      account_id?: number;
32
      account_name?: string;
33
      description?: string;
34
      bcy_rate?: number;
35
      rate?: number;
36
      quantity?: number;
37
      tax_id?: number;
38
      tds_tax_id?: string;
39
      tax_name?: string;
40
      tax_type?: string;
41
      tax_percentage?: number;
42
      item_total?: number;
43
      item_order?: number;
44
      unit?: string;
45
      image_id?: number;
46
      image_name?: string;
47
      image_type?: string;
48
      reverse_charge_tax_id?: string;
49
      hsn_or_sac?: string;
50
      tax_exemption_code?: string;
51
      location_id?: string;
52
      tax_exemption_id?: string;
53
    }[];
54
    location_id?: string;
55
    gst_treatment?: string;
56
    tax_treatment?: string;
57
    gst_no?: string;
58
    source_of_supply?: string;
59
    destination_of_supply?: string;
60
  },
61
) {
62
  const url = new URL(`https://www.zohoapis.com/inventory/v1/bills`);
63
  for (const [k, v] of [["organization_id", organization_id]]) {
64
    if (v !== undefined && v !== "" && k !== undefined) {
65
      url.searchParams.append(k, v);
66
    }
67
  }
68
  const response = await fetch(url, {
69
    method: "POST",
70
    headers: {
71
      "Content-Type": "application/json",
72
      Authorization: "Zoho-oauthtoken " + auth.token,
73
    },
74
    body: JSON.stringify(body),
75
  });
76
  if (!response.ok) {
77
    const text = await response.text();
78
    throw new Error(`${response.status} ${text}`);
79
  }
80
  return await response.json();
81
}
82