1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create bill lines |
7 | * Creates new bill lines |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAccounts Payable |
13 | User typeBusiness |
14 | PermissionsList, View, Add bill lines |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: |
23 | | ({ |
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?: { |
93 | key?: string |
94 | id?: string |
95 | name?: string |
96 | href?: string |
97 | } |
98 | department?: { |
99 | key?: string |
100 | id?: string |
101 | name?: string |
102 | href?: string |
103 | } |
104 | employee?: { |
105 | key?: string |
106 | id?: string |
107 | name?: string |
108 | href?: string |
109 | } |
110 | project?: { key?: string; id?: string; name?: string; href?: string } |
111 | customer?: { |
112 | key?: string |
113 | id?: string |
114 | name?: string |
115 | href?: string |
116 | } |
117 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
118 | item?: { key?: string; id?: string; name?: string; href?: string } |
119 | warehouse?: { |
120 | key?: string |
121 | id?: string |
122 | name?: string |
123 | href?: string |
124 | } |
125 | class?: { key?: string; id?: string; name?: string; href?: string } |
126 | task?: { id?: string; key?: string; name?: string; href?: string } |
127 | costType?: { |
128 | id?: string |
129 | key?: string |
130 | name?: string |
131 | href?: string |
132 | } |
133 | asset?: { id?: string; key?: string; name?: string; href?: string } |
134 | contract?: { |
135 | id?: string |
136 | key?: string |
137 | name?: string |
138 | href?: string |
139 | } |
140 | affiliateEntity?: { |
141 | key?: string |
142 | id?: string |
143 | href?: string |
144 | name?: string |
145 | } |
146 | } & { |
147 | location?: { |
148 | key?: string |
149 | id?: string |
150 | name?: string |
151 | href?: string |
152 | } |
153 | department?: { |
154 | key?: string |
155 | id?: string |
156 | name?: string |
157 | href?: string |
158 | } |
159 | } |
160 | bill?: { id?: string; key?: string; href?: string } |
161 | } & {}) |
162 | | ({ |
163 | id?: string |
164 | key?: string |
165 | href?: string |
166 | lineNumber?: string |
167 | hasForm1099?: string |
168 | form1099?: { type?: string; box?: string } |
169 | createdDate?: string |
170 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
171 | overrideOffsetGLAccount?: { |
172 | key?: string |
173 | id?: string |
174 | name?: string |
175 | href?: string |
176 | } |
177 | accountLabel?: { key?: string; id?: string; href?: string } |
178 | baseAmount?: string |
179 | txnAmount?: string |
180 | totalTxnAmount?: string |
181 | memo?: string |
182 | allocation?: { key?: string; id?: string; href?: string } |
183 | currency?: { |
184 | baseCurrency?: string |
185 | txnCurrency?: string |
186 | exchangeRate?: { date?: string; rate?: number; typeId?: string } |
187 | } |
188 | paymentInformation?: { |
189 | totalBaseAmountPaid?: string |
190 | totalTxnAmountPaid?: string |
191 | totalBaseAmountSelectedForPayment?: string |
192 | totalTxnAmountSelectedForPayment?: string |
193 | } |
194 | releaseToPay?: false | true |
195 | isSubTotal?: 'subtotal' | 'tax' |
196 | baseLocation?: { |
197 | key?: string |
198 | id?: string |
199 | name?: string |
200 | href?: string |
201 | } & { key?: string } |
202 | retainage?: { |
203 | hasRetainage?: false | true |
204 | percentage?: string |
205 | baseAmountRetained?: string |
206 | txnAmountRetained?: string |
207 | txnAmountReleased?: string |
208 | release?: false | true |
209 | } |
210 | project?: { isBillable?: false | true; isBilled?: false | true } |
211 | fixedAsset?: { |
212 | nameOfAcquiredAsset?: string |
213 | includeTaxInAssetCost?: false | true |
214 | } |
215 | purchasing?: { |
216 | document?: { key?: string; id?: string; href?: string } |
217 | documentLine?: { key?: string; id?: string; href?: string } |
218 | } |
219 | taxEntries?: { |
220 | key?: string |
221 | id?: string |
222 | baseTaxAmount?: string |
223 | txnTaxAmount?: string |
224 | taxRate?: number |
225 | } & { |
226 | purchasingTaxDetail?: { key?: string; id?: string; href?: string } |
227 | billLine?: { id?: string; key?: string; href?: string } |
228 | isPartialExemption?: false | true |
229 | }[] |
230 | dimensions?: { |
231 | location?: { |
232 | key?: string |
233 | id?: string |
234 | name?: string |
235 | href?: string |
236 | } |
237 | department?: { |
238 | key?: string |
239 | id?: string |
240 | name?: string |
241 | href?: string |
242 | } |
243 | employee?: { |
244 | key?: string |
245 | id?: string |
246 | name?: string |
247 | href?: string |
248 | } |
249 | project?: { key?: string; id?: string; name?: string; href?: string } |
250 | customer?: { |
251 | key?: string |
252 | id?: string |
253 | name?: string |
254 | href?: string |
255 | } |
256 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
257 | item?: { key?: string; id?: string; name?: string; href?: string } |
258 | warehouse?: { |
259 | key?: string |
260 | id?: string |
261 | name?: string |
262 | href?: string |
263 | } |
264 | class?: { key?: string; id?: string; name?: string; href?: string } |
265 | task?: { id?: string; key?: string; name?: string; href?: string } |
266 | costType?: { |
267 | id?: string |
268 | key?: string |
269 | name?: string |
270 | href?: string |
271 | } |
272 | asset?: { id?: string; key?: string; name?: string; href?: string } |
273 | contract?: { |
274 | id?: string |
275 | key?: string |
276 | name?: string |
277 | href?: string |
278 | } |
279 | affiliateEntity?: { |
280 | key?: string |
281 | id?: string |
282 | href?: string |
283 | name?: string |
284 | } |
285 | } & { |
286 | location?: { |
287 | key?: string |
288 | id?: string |
289 | name?: string |
290 | href?: string |
291 | } |
292 | department?: { |
293 | key?: string |
294 | id?: string |
295 | name?: string |
296 | href?: string |
297 | } |
298 | } |
299 | bill?: { id?: string; key?: string; href?: string } |
300 | } & { dimensions: {} }) |
301 | ) { |
302 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-payable/bill-line`) |
303 |
|
304 | const response = await fetch(url, { |
305 | method: 'POST', |
306 | headers: { |
307 | 'Content-Type': 'application/json', |
308 | Authorization: 'Bearer ' + auth.token |
309 | }, |
310 | body: JSON.stringify(body) |
311 | }) |
312 | if (!response.ok) { |
313 | const text = await response.text() |
314 | throw new Error(`${response.status} ${text}`) |
315 | } |
316 | return await response.json() |
317 | } |
318 |
|