1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a bill line |
7 | * Updates an existing bill line by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAccounts Payable, Purchasing |
13 | User typeBusiness |
14 | PermissionsList, View, Edit bill lines |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | id?: string |
25 | key?: string |
26 | href?: string |
27 | lineNumber?: string |
28 | hasForm1099?: string |
29 | form1099?: { type?: string; box?: string } |
30 | createdDate?: string |
31 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
32 | overrideOffsetGLAccount?: { |
33 | key?: string |
34 | id?: string |
35 | name?: string |
36 | href?: string |
37 | } |
38 | accountLabel?: { key?: string; id?: string; href?: string } |
39 | baseAmount?: string |
40 | txnAmount?: string |
41 | totalTxnAmount?: string |
42 | memo?: string |
43 | allocation?: { key?: string; id?: string; href?: string } |
44 | currency?: { |
45 | baseCurrency?: string |
46 | txnCurrency?: string |
47 | exchangeRate?: { date?: string; rate?: number; typeId?: string } |
48 | } |
49 | paymentInformation?: { |
50 | totalBaseAmountPaid?: string |
51 | totalTxnAmountPaid?: string |
52 | totalBaseAmountSelectedForPayment?: string |
53 | totalTxnAmountSelectedForPayment?: string |
54 | } |
55 | releaseToPay?: false | true |
56 | isSubTotal?: 'subtotal' | 'tax' |
57 | baseLocation?: { |
58 | key?: string |
59 | id?: string |
60 | name?: string |
61 | href?: string |
62 | } & { key?: string } |
63 | retainage?: { |
64 | hasRetainage?: false | true |
65 | percentage?: string |
66 | baseAmountRetained?: string |
67 | txnAmountRetained?: string |
68 | txnAmountReleased?: string |
69 | release?: false | true |
70 | } |
71 | project?: { isBillable?: false | true; isBilled?: false | true } |
72 | fixedAsset?: { |
73 | nameOfAcquiredAsset?: string |
74 | includeTaxInAssetCost?: false | true |
75 | } |
76 | purchasing?: { |
77 | document?: { key?: string; id?: string; href?: string } |
78 | documentLine?: { key?: string; id?: string; href?: string } |
79 | } |
80 | taxEntries?: { |
81 | key?: string |
82 | id?: string |
83 | baseTaxAmount?: string |
84 | txnTaxAmount?: string |
85 | taxRate?: number |
86 | } & { |
87 | purchasingTaxDetail?: { key?: string; id?: string; href?: string } |
88 | billLine?: { id?: string; key?: string; href?: string } |
89 | isPartialExemption?: false | true |
90 | }[] |
91 | dimensions?: { |
92 | location?: { key?: string; id?: string; name?: string; href?: string } |
93 | department?: { key?: string; id?: string; name?: string; href?: string } |
94 | employee?: { key?: string; id?: string; name?: string; href?: string } |
95 | project?: { key?: string; id?: string; name?: string; href?: string } |
96 | customer?: { key?: string; id?: string; name?: string; href?: string } |
97 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
98 | item?: { key?: string; id?: string; name?: string; href?: string } |
99 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
100 | class?: { key?: string; id?: string; name?: string; href?: string } |
101 | task?: { id?: string; key?: string; name?: string; href?: string } |
102 | costType?: { id?: string; key?: string; name?: string; href?: string } |
103 | asset?: { id?: string; key?: string; name?: string; href?: string } |
104 | contract?: { id?: string; key?: string; name?: string; href?: string } |
105 | affiliateEntity?: { |
106 | key?: string |
107 | id?: string |
108 | href?: string |
109 | name?: string |
110 | } |
111 | } & { |
112 | location?: { key?: string; id?: string; name?: string; href?: string } |
113 | department?: { key?: string; id?: string; name?: string; href?: string } |
114 | } |
115 | bill?: { id?: string; key?: string; href?: string } |
116 | } & { id?: {} } |
117 | ) { |
118 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-payable/bill-line/${key}`) |
119 |
|
120 | const response = await fetch(url, { |
121 | method: 'PATCH', |
122 | headers: { |
123 | 'Content-Type': 'application/json', |
124 | Authorization: 'Bearer ' + auth.token |
125 | }, |
126 | body: JSON.stringify(body) |
127 | }) |
128 | if (!response.ok) { |
129 | const text = await response.text() |
130 | throw new Error(`${response.status} ${text}`) |
131 | } |
132 | return await response.json() |
133 | } |
134 |
|