1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a checking account |
7 | * Updates an existing checking account by setting field values. Any fields not provided remain unchanged. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | key: string, |
12 | body: { |
13 | key?: string |
14 | id?: string |
15 | bankAccountDetails?: { |
16 | accountNumber?: string |
17 | bankName?: string |
18 | accountHolderName?: string |
19 | routingNumber?: string |
20 | branchId?: string |
21 | phoneNumber?: string |
22 | currency?: string |
23 | bankAddress?: { |
24 | city?: string |
25 | state?: string |
26 | postCode?: string |
27 | country?: string |
28 | addressLine1?: string |
29 | addressLine2?: string |
30 | addressLine3?: string |
31 | } |
32 | } |
33 | accounting?: { |
34 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
35 | apJournal?: { key?: string; id?: string; href?: string } |
36 | arJournal?: { key?: string; id?: string; href?: string } |
37 | disableInterEntityTransfer?: false | true |
38 | serviceChargeGLAccount?: { key?: string; id?: string; href?: string } |
39 | serviceChargeAccountLabel?: { key?: string; id?: string; href?: string } |
40 | interestGLAccount?: { key?: string; id?: string; href?: string } |
41 | interestAccountLabel?: { key?: string; id?: string; href?: string } |
42 | bankingTimeZone?: |
43 | | 'GMT (Greenwich Mean Time) Dublin, Edinburgh, London' |
44 | | 'GMT+00:00 Western Europe Time' |
45 | | 'GMT+01:00 Western Europe Summer Time' |
46 | | 'GMT+01:00 British Summer Time' |
47 | | 'GMT+01:00 Irish Summer Time' |
48 | | 'GMT+01:00 Central Europe Time' |
49 | | 'GMT+01:00 Berlin, Stockholm, Rome, Bern, Brussels' |
50 | | 'GMT+01:00 Lisbon, Warsaw' |
51 | | 'GMT+01:00 Paris, Madrid' |
52 | | 'GMT+01:00 Prague' |
53 | | 'GMT+02:00 Central Europe Summer Time' |
54 | | 'GMT+02:00 Eastern Europe Time' |
55 | | 'GMT+02:00 Athens, Helsinki, Istanbul' |
56 | | 'GMT+02:00 Cairo' |
57 | | 'GMT+02:00 Harare, Pretoria' |
58 | | 'GMT+02:00 Israel' |
59 | | 'GMT+03:00 Eastern Europe Summer Time' |
60 | | 'GMT+03:00 Baghdad, Kuwait, Nairobi, Riyadh' |
61 | | 'GMT+03:00 Moscow, St. Petersburg, Volgograd' |
62 | | 'GMT+03:30 Tehran' |
63 | | 'GMT+04:00 Moscow Summer Time' |
64 | | 'GMT+04:00 Abu Dhabi, Muscat, Tbilisi, Kazan' |
65 | | 'GMT+04:30 Kabul' |
66 | | 'GMT+05:00 Islamabad, Karachi, Sverdlovsk, Tashkent' |
67 | | 'GMT+05:30 Bombay, Calcutta, Madras, New Delhi' |
68 | | 'GMT+06:00 Almaty, Dhaka' |
69 | | 'GMT+07:00 Bangkok, Jakarta, Hanoi' |
70 | | 'GMT+08:00 Beijing, Chongqing, Urumqi' |
71 | | 'GMT+08:00 Hong Kong SAR, Perth, Singapore, Taipei' |
72 | | 'GMT+08:00 (Australian) Western Standard Time' |
73 | | 'GMT+09:00 Tokyo, Osaka, Sapporo, Seoul, Yakutsk' |
74 | | 'GMT+09:30 (Australian) Central Standard Time' |
75 | | 'GMT+10:30 (Australian) Central Daylight Time' |
76 | | 'GMT+09:30 Adelaide' |
77 | | 'GMT+09:30 Darwin' |
78 | | 'GMT+10:00 Brisbane, Melbourne, Sydney' |
79 | | 'GMT+10:00 Guam, Port Moresby' |
80 | | 'GMT+10:00 Vladivostok' |
81 | | 'GMT+10:00 (Australian) Eastern Standard Time' |
82 | | 'GMT+11:00 (Australian) Eastern Daylight Time' |
83 | | 'GMT+12:00 Fiji Islands, Marshall Islands' |
84 | | 'GMT+12:00 Kamchatka' |
85 | | 'GMT+12:00 Magadan, Solomon Islands, New Caledonia' |
86 | | 'GMT+12:00 Wellington, Auckland' |
87 | | 'GMT+13:00 Nuku`alofa' |
88 | | 'GMT+13:00 Samoa' |
89 | | 'GMT-01:00 Azores, Cape Verde Island' |
90 | | 'GMT-03:00 Brasilia' |
91 | | 'GMT-03:00 Buenos Aires, Georgetown' |
92 | | 'GMT-03:30 Newfoundland Standard Time' |
93 | | 'GMT-02:30 Newfoundland Daylight Time' |
94 | | 'GMT-04:00 Atlantic Standard Time' |
95 | | 'GMT-03:00 Atlantic Daylight Time' |
96 | | 'GMT-04:00 Caracas, La Paz' |
97 | | 'GMT-05:00 Bogota, Lima' |
98 | | 'GMT-05:00 Eastern Standard Time' |
99 | | 'GMT-04:00 Eastern Daylight Saving Time' |
100 | | 'GMT-05:00 Indiana (East)' |
101 | | 'GMT-06:00 Central Standard Time' |
102 | | 'GMT-05:00 Central Daylight Saving Time' |
103 | | 'GMT-06:00 Mexico City, Tegucigalpa' |
104 | | 'GMT-06:00 Saskatchewan' |
105 | | 'GMT-07:00 Arizona' |
106 | | 'GMT-07:00 Mountain Standard Time' |
107 | | 'GMT-06:00 Mountain Daylight Saving Time' |
108 | | 'GMT-08:00 Pacific Standard Time' |
109 | | 'GMT-07:00 Pacific Daylight Saving Time' |
110 | | 'GMT-09:00 Alaska Standard Time' |
111 | | 'GMT-08:00 Alaska Standard Daylight Saving Time' |
112 | | 'GMT-10:00 Hawaii' |
113 | | 'GMT-11:00 Midway Island, Samoa' |
114 | | 'GMT-12:00 Eniwetok, Kwajalein' |
115 | } |
116 | reconciliation?: { |
117 | lastReconciledBalance?: string |
118 | lastReconciledDate?: string |
119 | cutOffDate?: string |
120 | inProgressBalance?: string |
121 | inProgressDate?: string |
122 | matchSequence?: { key?: string; id?: string; href?: string } |
123 | useMatchSequenceForAutoMatch?: false | true |
124 | useMatchSequenceForManualMatch?: false | true |
125 | } |
126 | checkPrinting?: { |
127 | disablePrinting?: false | true |
128 | addressSettings?: { |
129 | printAddress?: false | true |
130 | addressToPrint?: 'company' | 'custom' |
131 | name?: string |
132 | address?: { |
133 | addressLine1?: string |
134 | addressLine2?: string |
135 | addressLine3?: string |
136 | city?: string |
137 | state?: string |
138 | postCode?: string |
139 | country?: string |
140 | countryCode?: string |
141 | phone?: string |
142 | } |
143 | printLogo?: false | true |
144 | } |
145 | signatures?: { |
146 | firstSignature?: string |
147 | limitForFirstSignatureAmount?: string |
148 | useSecondSignature?: false | true |
149 | secondSignature?: string |
150 | limitForSecondSignatureAmount?: string |
151 | thresholdForSecondSignatureAmount?: string |
152 | } |
153 | printSettings?: { |
154 | printOn?: 'prePrintedCheckStock' | 'blankCheckStock' |
155 | nextCheckNumber?: string |
156 | printingFormat?: |
157 | | 'standard' |
158 | | 'business' |
159 | | 'highSecurity' |
160 | | 'cadCheck' |
161 | | 'jpmorganChaseBusiness' |
162 | | 'jpmorganChaseStandard' |
163 | paperFormat?: 'top' | 'middle' | 'bottom' |
164 | printLineItems?: false | true |
165 | printLocation?: 'id' | 'name' | 'both' |
166 | additionalText?: string |
167 | numberOfChecksInPreview?: 'one' | 'three' |
168 | } |
169 | micrSettings?: { |
170 | accountNumberAlignment?: 'left' | 'right' |
171 | accountNumberPositioning?: number |
172 | minCheckNumberLength?: string |
173 | regionalSettings?: { |
174 | printCode45?: false | true |
175 | printUSFundsUnderCheckAmount?: false | true |
176 | printOnUsSymbol?: false | true |
177 | positionOfOnUsSymbol?: 'position31' | 'position32' |
178 | } |
179 | } |
180 | } |
181 | department?: { key?: string; id?: string; href?: string } |
182 | location?: { key?: string; id?: string; href?: string } |
183 | status?: 'active' | 'inactive' |
184 | ach?: { |
185 | enableACH?: false | true |
186 | bankId?: string |
187 | companyName?: string |
188 | companyIdentification?: string |
189 | originatingFinancialInstitution?: string |
190 | companyEntryDescription?: string |
191 | companyDiscretionaryData?: string |
192 | useRecommendedSetup?: false | true |
193 | recordTypeCode?: string |
194 | serviceClassCode?: '220' | '200' |
195 | originatorStatusCode?: string |
196 | batchId?: string |
197 | traceNumberSequence?: string |
198 | paymentNumberSequence?: string |
199 | useTraceNumber?: 'useAsPayment' | 'useNumberingSequence' |
200 | } |
201 | bankFile?: { |
202 | enableBankFile?: false | true |
203 | bankFileFormat?: string |
204 | bankCode?: string |
205 | apcaNumber?: string |
206 | bsbNumber?: string |
207 | sunNumber?: string |
208 | sortCode?: string |
209 | seedValue?: string |
210 | userReference?: string |
211 | clientCode?: string |
212 | serviceType?: string |
213 | originatorId?: string |
214 | businessIdCode?: string |
215 | processingDataCenterCode?: string |
216 | debtorBankNumber?: string |
217 | branchTransitNumber?: string |
218 | returnAccountNumber?: string |
219 | messageIdPrefix?: string |
220 | } |
221 | audit?: { |
222 | createdDateTime?: string |
223 | modifiedDateTime?: string |
224 | createdBy?: string |
225 | modifiedBy?: string |
226 | } |
227 | bankingCloudConnection?: { |
228 | name?: string |
229 | bankName?: string |
230 | status?: |
231 | | 'notConnected' |
232 | | 'connectionRequested' |
233 | | 'inProgress' |
234 | | 'pending' |
235 | | 'pendingConfirmation' |
236 | | 'connected' |
237 | | 'authRequired' |
238 | | 'verifyingAuth' |
239 | | 'inactiveFeed' |
240 | | 'inactiveClient' |
241 | | 'canceled' |
242 | | 'invalid' |
243 | | 'canceling' |
244 | | 'disconnecting' |
245 | lastBankTxnDateTime?: string |
246 | lastRefreshedDateTime?: string |
247 | refreshStatus?: 'queued' | 'refreshing' | 'success' | 'partialSuccess' | 'failure' |
248 | supportMultiAccountLinking?: false | true |
249 | } |
250 | financialInstitution?: { id?: string; key?: string; href?: string } |
251 | entity?: { key?: string; id?: string; name?: string; href?: string } |
252 | ruleSet?: { key?: string; id?: string; name?: string; href?: string } |
253 | restrictions?: { |
254 | restrictionType?: 'unrestricted' | 'rootOnly' | 'restricted' |
255 | locations?: string[] |
256 | } |
257 | paymentProviderBankAccounts?: { |
258 | key?: string |
259 | id?: string |
260 | state?: |
261 | | 'inProgress' |
262 | | 'canceled' |
263 | | 'requestInitiated' |
264 | | 'requestReceived' |
265 | | 'requestFailed' |
266 | | 'awaitingAuthorization' |
267 | | 'subscribed' |
268 | | 'suspended' |
269 | providerReferenceNumber?: string |
270 | authenticationURL?: string |
271 | checkStartNumber?: string |
272 | isRebateAccount?: false | true |
273 | remittanceEmail?: string |
274 | bankAccount?: { |
275 | key?: string |
276 | id?: string |
277 | currency?: string |
278 | href?: string |
279 | } |
280 | paymentProvider?: { key?: string; id?: string; href?: string } |
281 | href?: string |
282 | audit?: { |
283 | createdDateTime?: string |
284 | modifiedDateTime?: string |
285 | createdBy?: string |
286 | modifiedBy?: string |
287 | } |
288 | status?: 'active' | 'inactive' |
289 | }[] |
290 | } & { id?: {} } |
291 | ) { |
292 | const url = new URL( |
293 | `https://api.intacct.com/ia/api/v1/objects/cash-management/checking-account/${key}` |
294 | ) |
295 |
|
296 | const response = await fetch(url, { |
297 | method: 'PATCH', |
298 | headers: { |
299 | 'Content-Type': 'application/json', |
300 | Authorization: 'Bearer ' + auth.token |
301 | }, |
302 | body: JSON.stringify(body) |
303 | }) |
304 | if (!response.ok) { |
305 | const text = await response.text() |
306 | throw new Error(`${response.status} ${text}`) |
307 | } |
308 | return await response.json() |
309 | } |
310 |
|