0

Create Bill

by
Published Jun 6, 2022

Creates a bill. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#create-a-bill)

Script quickbooks Verified

The script

Submitted by hugo697 Bun
Verified 323 days ago
1
import QuickBooks from "node-quickbooks";
2

3
type Quickbooks = {
4
  realmId: string;
5
  token: string;
6
  isSandBox: boolean;
7
};
8

9
export async function main(
10
  resource: Quickbooks,
11
  bill: {
12
    VendorRef: {
13
      value: string;
14
      name?: string;
15
    };
16
    Line: {
17
      Id?: string;
18
      DetailType: "AccountBasedExpenseLineDetail";
19
      Amount: number;
20
      AccountBasedExpenseLineDetail: {
21
        AccountRef: {
22
          value: string;
23
          name?: string;
24
        };
25
        TaxAmount?: number;
26
        TaxInclusiveAmt?: number;
27
        ClassRef?: {
28
          value: string;
29
          name?: string;
30
        };
31
        TaxCodeRef?: {
32
          value: string;
33
          name?: string;
34
        };
35
        BillableStatus?: string;
36
        CustomerRef?: {
37
          value: string;
38
          name?: string;
39
        };
40
      };
41
      Description?: string;
42
      LineNum?: number;
43
    }[];
44
    CurrencyRef?: {
45
      value: string;
46
      name?: string;
47
    };
48
  }
49
) {
50
  const qbo = new QuickBooks("", "", resource.token, false, resource.realmId, resource.isSandBox, true, null, "2.0");
51

52
  return new Promise((resolve, reject) => {
53
    qbo.createBill(bill, function (err: any, result: any) {
54
      if (err) {
55
        reject(err);
56
      } else {
57
        resolve(result);
58
      }
59
    });
60
  });
61
}
62