1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a vendor |
7 | * Updates an existing vendor by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAccounts Payable |
13 | User typeBusiness |
14 | PermissionsList, View, Edit Vendors |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | name?: string |
27 | isOneTimeUse?: false | true |
28 | href?: string |
29 | status?: 'active' | 'activeNonPosting' | 'inactive' |
30 | state?: 's' | 'a' | 'r' |
31 | vendorType?: { key?: string; id?: string; href?: string } |
32 | parent?: { key?: string; id?: string; name?: string; href?: string } |
33 | accountGroup?: { key?: string; id?: string; href?: string } |
34 | accountlabel?: { key?: string; id?: string; href?: string } |
35 | defaultLeadTime?: number |
36 | filePaymentService?: 'ach' | 'bankFile' | 'none' |
37 | bankFiles?: { |
38 | paymentCountryCode?: |
39 | | 'us' |
40 | | 'af' |
41 | | 'ax' |
42 | | 'al' |
43 | | 'dz' |
44 | | 'as' |
45 | | 'ad' |
46 | | 'ao' |
47 | | 'ai' |
48 | | 'aq' |
49 | | 'ag' |
50 | | 'ar' |
51 | | 'am' |
52 | | 'aw' |
53 | | 'au' |
54 | | 'at' |
55 | | 'az' |
56 | | 'bs' |
57 | | 'bh' |
58 | | 'bd' |
59 | | 'bb' |
60 | | 'by' |
61 | | 'be' |
62 | | 'bz' |
63 | | 'bj' |
64 | | 'bm' |
65 | | 'bt' |
66 | | 'bo' |
67 | | 'bq' |
68 | | 'ba' |
69 | | 'bw' |
70 | | 'bv' |
71 | | 'br' |
72 | | 'io' |
73 | | 'bn' |
74 | | 'bg' |
75 | | 'bf' |
76 | | 'bi' |
77 | | 'kh' |
78 | | 'cm' |
79 | | 'ca' |
80 | | 'cv' |
81 | | 'ky' |
82 | | 'cf' |
83 | | 'td' |
84 | | 'cl' |
85 | | 'cn' |
86 | | 'cx' |
87 | | 'cc' |
88 | | 'co' |
89 | | 'km' |
90 | | 'cg' |
91 | | 'cd' |
92 | | 'ck' |
93 | | 'cr' |
94 | | 'ci' |
95 | | 'hr' |
96 | | 'cu' |
97 | | 'cw' |
98 | | 'cy' |
99 | | 'cz' |
100 | | 'dk' |
101 | | 'dj' |
102 | | 'dm' |
103 | | 'do' |
104 | | 'ec' |
105 | | 'eg' |
106 | | 'sv' |
107 | | 'gq' |
108 | | 'er' |
109 | | 'ee' |
110 | | 'sz' |
111 | | 'et' |
112 | | 'fk' |
113 | | 'fo' |
114 | | 'fj' |
115 | | 'fi' |
116 | | 'fr' |
117 | | 'gf' |
118 | | 'pf' |
119 | | 'tf' |
120 | | 'ga' |
121 | | 'gm' |
122 | | 'ge' |
123 | | 'de' |
124 | | 'gh' |
125 | | 'gi' |
126 | | 'gr' |
127 | | 'gl' |
128 | | 'gd' |
129 | | 'gp' |
130 | | 'gu' |
131 | | 'gt' |
132 | | 'gg' |
133 | | 'gn' |
134 | | 'gw' |
135 | | 'gy' |
136 | | 'ht' |
137 | | 'hm' |
138 | | 'hn' |
139 | | 'hk' |
140 | | 'hu' |
141 | | 'is' |
142 | | 'in' |
143 | | 'id' |
144 | | 'ir' |
145 | | 'iq' |
146 | | 'ie' |
147 | | 'im' |
148 | | 'il' |
149 | | 'it' |
150 | | 'jm' |
151 | | 'jp' |
152 | | 'je' |
153 | | 'jo' |
154 | | 'kz' |
155 | | 'ke' |
156 | | 'ki' |
157 | | 'kr' |
158 | | 'kp' |
159 | | 'xk' |
160 | | 'kw' |
161 | | 'kg' |
162 | | 'la' |
163 | | 'lv' |
164 | | 'lb' |
165 | | 'ls' |
166 | | 'lr' |
167 | | 'ly' |
168 | | 'li' |
169 | | 'lt' |
170 | | 'lu' |
171 | | 'mo' |
172 | | 'mk' |
173 | | 'mg' |
174 | | 'mw' |
175 | | 'my' |
176 | | 'mv' |
177 | | 'ml' |
178 | | 'mt' |
179 | | 'mh' |
180 | | 'mq' |
181 | | 'mr' |
182 | | 'mu' |
183 | | 'yt' |
184 | | 'mx' |
185 | | 'fm' |
186 | | 'md' |
187 | | 'mc' |
188 | | 'mn' |
189 | | 'me' |
190 | | 'ms' |
191 | | 'ma' |
192 | | 'mz' |
193 | | 'mm' |
194 | | 'na' |
195 | | 'nr' |
196 | | 'np' |
197 | | 'nl' |
198 | | 'an' |
199 | | 'nc' |
200 | | 'nz' |
201 | | 'ni' |
202 | | 'ne' |
203 | | 'ng' |
204 | | 'nu' |
205 | | 'nf' |
206 | | 'mp' |
207 | | 'no' |
208 | | 'om' |
209 | | 'pk' |
210 | | 'pw' |
211 | | 'ps' |
212 | | 'pa' |
213 | | 'pg' |
214 | | 'py' |
215 | | 'pe' |
216 | | 'ph' |
217 | | 'pn' |
218 | | 'pl' |
219 | | 'pt' |
220 | | 'pr' |
221 | | 'qa' |
222 | | 're' |
223 | | 'ro' |
224 | | 'ru' |
225 | | 'rw' |
226 | | 'bl' |
227 | | 'sh' |
228 | | 'kn' |
229 | | 'lc' |
230 | | 'mf' |
231 | | 'pm' |
232 | | 'vc' |
233 | | 'ws' |
234 | | 'sm' |
235 | | 'st' |
236 | | 'sa' |
237 | | 'sn' |
238 | | 'rs' |
239 | | 'sc' |
240 | | 'sl' |
241 | | 'sg' |
242 | | 'sx' |
243 | | 'sk' |
244 | | 'si' |
245 | | 'sb' |
246 | | 'so' |
247 | | 'za' |
248 | | 'gs' |
249 | | 'es' |
250 | | 'lk' |
251 | | 'sd' |
252 | | 'ss' |
253 | | 'sr' |
254 | | 'sj' |
255 | | 'se' |
256 | | 'ch' |
257 | | 'sy' |
258 | | 'tw' |
259 | | 'tj' |
260 | | 'tz' |
261 | | 'th' |
262 | | 'tl' |
263 | | 'tg' |
264 | | 'tk' |
265 | | 'to' |
266 | | 'tt' |
267 | | 'tn' |
268 | | 'tr' |
269 | | 'tm' |
270 | | 'tc' |
271 | | 'tv' |
272 | | 'ug' |
273 | | 'ua' |
274 | | 'ae' |
275 | | 'gb' |
276 | | 'um' |
277 | | 'uy' |
278 | | 'uz' |
279 | | 'vu' |
280 | | 'va' |
281 | | 've' |
282 | | 'vn' |
283 | | 'vg' |
284 | | 'vi' |
285 | | 'wf' |
286 | | 'eh' |
287 | | 'ye' |
288 | | 'zm' |
289 | | 'zw' |
290 | paymentCurrency?: string |
291 | } |
292 | taxId?: string |
293 | tpar?: { isTparEnabled?: false | true; name?: string } |
294 | t5018?: { isT5018Enabled?: false | true; t5018Number?: string } |
295 | form1099?: { |
296 | is1099Eligible?: false | true |
297 | nameOn1099?: string |
298 | type?: string |
299 | box?: string |
300 | } |
301 | attachment?: { key?: string; id?: string; href?: string } |
302 | isOnHold?: false | true |
303 | doNotPay?: false | true |
304 | alwaysCreateBill?: false | true |
305 | creditLimit?: number |
306 | retainagePercentage?: number |
307 | notes?: string |
308 | priceList?: { key?: string; id?: string; href?: string } |
309 | priceSchedule?: { key?: string; id?: string; href?: string } |
310 | overrideOffsetGLAccount?: { |
311 | key?: string |
312 | id?: string |
313 | name?: string |
314 | href?: string |
315 | } |
316 | defaultExpenseGLAccount?: { |
317 | key?: string |
318 | id?: string |
319 | name?: string |
320 | href?: string |
321 | } |
322 | discountPercent?: number |
323 | contacts?: { |
324 | default?: { |
325 | key?: string |
326 | id?: string |
327 | href?: string |
328 | lastName?: string |
329 | firstName?: string |
330 | middleName?: string |
331 | prefix?: string |
332 | printAs?: string |
333 | email1?: string |
334 | email2?: string |
335 | phone1?: string |
336 | phone2?: string |
337 | mobile?: string |
338 | pager?: string |
339 | fax?: string |
340 | URL1?: string |
341 | URL2?: string |
342 | companyName?: string |
343 | mailingAddress?: { |
344 | addressLine1?: string |
345 | addressLine2?: string |
346 | addressLine3?: string |
347 | city?: string |
348 | state?: string |
349 | postCode?: string |
350 | country?: string |
351 | } |
352 | } & { |
353 | hideContactList?: false | true |
354 | tax?: { |
355 | isTaxable?: false | true |
356 | group?: { key?: string; id?: string; href?: string } |
357 | } |
358 | electronicInvoiceDetails?: { |
359 | legalCategory?: string |
360 | mainActivity?: string |
361 | typeOfCompany?: string |
362 | registeredCapital?: number |
363 | valueAddedTaxRegime?: string |
364 | } |
365 | internationalTaxId?: string |
366 | } |
367 | primary?: { key?: string; id?: string; href?: string } |
368 | payTo?: { key?: string; id?: string; href?: string } |
369 | returnTo?: { key?: string; id?: string; href?: string } |
370 | recipient1099?: { key?: string; id?: string; href?: string } |
371 | } |
372 | contactList?: { |
373 | key?: string |
374 | id?: string |
375 | href?: string |
376 | categoryName?: string |
377 | contact?: { key?: string; id?: string; href?: string } |
378 | audit?: { |
379 | createdDateTime?: string |
380 | modifiedDateTime?: string |
381 | createdBy?: string |
382 | modifiedBy?: string |
383 | } |
384 | vendor?: { key?: string; id?: string; href?: string } |
385 | }[] |
386 | vendorEmailTemplates?: { |
387 | key?: string |
388 | id?: string |
389 | href?: string |
390 | vendor?: { key?: string; id?: string; href?: string } |
391 | txnDefinitionName?: string |
392 | emailTemplate?: { |
393 | key?: string |
394 | id?: string |
395 | name?: string |
396 | href?: string |
397 | } |
398 | }[] |
399 | vendorPaymentProviders?: { |
400 | key?: string |
401 | id?: string |
402 | href?: string |
403 | paymentProvider?: { |
404 | key?: string |
405 | id?: string |
406 | name?: string |
407 | href?: string |
408 | } |
409 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
410 | state?: |
411 | | 'requestInitiated' |
412 | | 'inProgress' |
413 | | 'requestReceived' |
414 | | 'requestFailed' |
415 | | 'awaitingAuthorization' |
416 | | 'subscribed' |
417 | | 'canceled' |
418 | | 'suspended' |
419 | preferredPaymentMethod?: { |
420 | key?: string |
421 | id?: string |
422 | name?: string |
423 | href?: string |
424 | } |
425 | status?: 'active' | 'inactive' |
426 | audit?: { |
427 | createdDateTime?: string |
428 | modifiedDateTime?: string |
429 | createdBy?: string |
430 | modifiedBy?: string |
431 | } |
432 | }[] |
433 | vendorBankFileSetup?: { |
434 | key?: string |
435 | id?: string |
436 | bankAccountNumber?: string |
437 | bankAccountName?: string |
438 | bsbNumber?: string |
439 | sortCode?: string |
440 | paymentReference?: string |
441 | branchCode?: string |
442 | bankAccountType?: string |
443 | bankAccountCode?: string |
444 | printPaymentProof?: false | true |
445 | businessIdCode?: string |
446 | creditorCode?: string |
447 | secondaryIdentifier?: string |
448 | vendor?: { key?: string; id?: string; href?: string } |
449 | href?: string |
450 | }[] |
451 | vendorAccountNumberList?: { |
452 | key?: string |
453 | id?: string |
454 | location?: { key?: string; id?: string; name?: string; href?: string } |
455 | vendorAccountNumber?: string |
456 | href?: string |
457 | vendor?: { key?: string; id?: string; href?: string } |
458 | }[] |
459 | preferredPaymentMethod?: |
460 | | 'printedCheck' |
461 | | 'chargeCard' |
462 | | 'EFT' |
463 | | 'cash' |
464 | | 'ACH' |
465 | | 'wellsFargoCheck' |
466 | | 'wellsFargoUSDWire' |
467 | | 'wellsFargoDomesticACH' |
468 | mergePaymentRequests?: false | true |
469 | sendPaymentNotification?: false | true |
470 | billingType?: 'openItem' | 'balanceForward' |
471 | paymentPriority?: 'urgent' | 'high' | 'normal' | 'low' |
472 | currency?: string |
473 | displayTermDiscountOnCheckStub?: false | true |
474 | term?: { key?: string; id?: string; href?: string } |
475 | billPayment?: { |
476 | defaultDateOptions?: 'none' | 'dueDate' | 'billDate' | 'discountDate' |
477 | offsetTypePlusMinus?: '+' | '-' |
478 | dueNumberOfDays?: number |
479 | billNumberOfDays?: number |
480 | } |
481 | vendorAccountNumber?: string |
482 | displayVendorAccountOnCheckStub?: false | true |
483 | totalDue?: string |
484 | lastBillCreatedDate?: string |
485 | lastPaymentMadeDate?: string |
486 | ach?: { |
487 | enablePayments?: false | true |
488 | routingNumber?: string |
489 | accountNumber?: string |
490 | accountType?: 'checkingAccount' | 'savingsAccount' |
491 | remittanceType?: 'businessCTX' | 'personalPPD' | 'businessCCD' |
492 | } |
493 | vendorRestriction?: 'unrestricted' | 'rootOnly' | 'restricted' |
494 | restrictedLocations?: { |
495 | key?: string |
496 | id?: string |
497 | href?: string |
498 | location?: { key?: string; id?: string; href?: string } |
499 | locationGroup?: { key?: string; id?: string; href?: string } |
500 | vendor?: { key?: string; id?: string; href?: string } |
501 | }[] |
502 | restrictedDepartments?: { |
503 | key?: string |
504 | id?: string |
505 | href?: string |
506 | department?: { key?: string; id?: string; href?: string } |
507 | departmentGroup?: { key?: string; id?: string; href?: string } |
508 | vendor?: { key?: string; id?: string; href?: string } |
509 | }[] |
510 | audit?: { |
511 | createdDateTime?: string |
512 | modifiedDateTime?: string |
513 | createdBy?: string |
514 | modifiedBy?: string |
515 | } |
516 | entity?: { key?: string; id?: string; name?: string; href?: string } |
517 | } & { id?: {} } |
518 | ) { |
519 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-payable/vendor/${key}`) |
520 |
|
521 | const response = await fetch(url, { |
522 | method: 'PATCH', |
523 | headers: { |
524 | 'Content-Type': 'application/json', |
525 | Authorization: 'Bearer ' + auth.token |
526 | }, |
527 | body: JSON.stringify(body) |
528 | }) |
529 | if (!response.ok) { |
530 | const text = await response.text() |
531 | throw new Error(`${response.status} ${text}`) |
532 | } |
533 | return await response.json() |
534 | } |
535 |
|