1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a savings account |
7 | * Create a new savings account. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | href?: string |
15 | bankAccountDetails?: { |
16 | accountNumber?: string |
17 | bankName?: string |
18 | routingNumber?: string |
19 | branchId?: string |
20 | phoneNumber?: string |
21 | currency?: string |
22 | bankAddress?: { |
23 | city?: string |
24 | state?: string |
25 | postCode?: string |
26 | country?: string |
27 | addressLine1?: string |
28 | addressLine2?: string |
29 | addressLine3?: string |
30 | } |
31 | } |
32 | accounting?: { |
33 | glAccount?: { key?: string; id?: string; href?: string } |
34 | apJournal?: { key?: string; id?: string; href?: string } |
35 | arJournal?: { key?: string; id?: string; href?: string } |
36 | bankingTimeZone?: |
37 | | 'GMT (Greenwich Mean Time) Dublin, Edinburgh, London' |
38 | | 'GMT+00:00 Western Europe Time' |
39 | | 'GMT+01:00 Western Europe Summer Time' |
40 | | 'GMT+01:00 British Summer Time' |
41 | | 'GMT+01:00 Irish Summer Time' |
42 | | 'GMT+01:00 Central Europe Time' |
43 | | 'GMT+01:00 Berlin, Stockholm, Rome, Bern, Brussels' |
44 | | 'GMT+01:00 Lisbon, Warsaw' |
45 | | 'GMT+01:00 Paris, Madrid' |
46 | | 'GMT+01:00 Prague' |
47 | | 'GMT+02:00 Central Europe Summer Time' |
48 | | 'GMT+02:00 Eastern Europe Time' |
49 | | 'GMT+02:00 Athens, Helsinki, Istanbul' |
50 | | 'GMT+02:00 Cairo' |
51 | | 'GMT+02:00 Harare, Pretoria' |
52 | | 'GMT+02:00 Israel' |
53 | | 'GMT+03:00 Eastern Europe Summer Time' |
54 | | 'GMT+03:00 Baghdad, Kuwait, Nairobi, Riyadh' |
55 | | 'GMT+03:00 Moscow, St. Petersburg, Volgograd' |
56 | | 'GMT+03:30 Tehran' |
57 | | 'GMT+04:00 Moscow Summer Time' |
58 | | 'GMT+04:00 Abu Dhabi, Muscat, Tbilisi, Kazan' |
59 | | 'GMT+04:30 Kabul' |
60 | | 'GMT+05:00 Islamabad, Karachi, Sverdlovsk, Tashkent' |
61 | | 'GMT+05:30 Bombay, Calcutta, Madras, New Delhi' |
62 | | 'GMT+06:00 Almaty, Dhaka' |
63 | | 'GMT+07:00 Bangkok, Jakarta, Hanoi' |
64 | | 'GMT+08:00 Beijing, Chongqing, Urumqi' |
65 | | 'GMT+08:00 Hong Kong SAR, Perth, Singapore, Taipei' |
66 | | 'GMT+08:00 (Australian) Western Standard Time' |
67 | | 'GMT+09:00 Tokyo, Osaka, Sapporo, Seoul, Yakutsk' |
68 | | 'GMT+09:30 (Australian) Central Standard Time' |
69 | | 'GMT+10:30 (Australian) Central Daylight Time' |
70 | | 'GMT+09:30 Adelaide' |
71 | | 'GMT+09:30 Darwin' |
72 | | 'GMT+10:00 Brisbane, Melbourne, Sydney' |
73 | | 'GMT+10:00 Guam, Port Moresby' |
74 | | 'GMT+10:00 Vladivostok' |
75 | | 'GMT+10:00 (Australian) Eastern Standard Time' |
76 | | 'GMT+11:00 (Australian) Eastern Daylight Time' |
77 | | 'GMT+12:00 Fiji Islands, Marshall Islands' |
78 | | 'GMT+12:00 Kamchatka' |
79 | | 'GMT+12:00 Magadan, Solomon Islands, New Caledonia' |
80 | | 'GMT+12:00 Wellington, Auckland' |
81 | | 'GMT+13:00 Nuku`alofa' |
82 | | 'GMT+13:00 Samoa' |
83 | | 'GMT-01:00 Azores, Cape Verde Island' |
84 | | 'GMT-03:00 Brasilia' |
85 | | 'GMT-03:00 Buenos Aires, Georgetown' |
86 | | 'GMT-03:30 Newfoundland Standard Time' |
87 | | 'GMT-02:30 Newfoundland Daylight Time' |
88 | | 'GMT-04:00 Atlantic Standard Time' |
89 | | 'GMT-03:00 Atlantic Daylight Time' |
90 | | 'GMT-04:00 Caracas, La Paz' |
91 | | 'GMT-05:00 Bogota, Lima' |
92 | | 'GMT-05:00 Eastern Standard Time' |
93 | | 'GMT-04:00 Eastern Daylight Saving Time' |
94 | | 'GMT-05:00 Indiana (East)' |
95 | | 'GMT-06:00 Central Standard Time' |
96 | | 'GMT-05:00 Central Daylight Saving Time' |
97 | | 'GMT-06:00 Mexico City, Tegucigalpa' |
98 | | 'GMT-06:00 Saskatchewan' |
99 | | 'GMT-07:00 Arizona' |
100 | | 'GMT-07:00 Mountain Standard Time' |
101 | | 'GMT-06:00 Mountain Daylight Saving Time' |
102 | | 'GMT-08:00 Pacific Standard Time' |
103 | | 'GMT-07:00 Pacific Daylight Saving Time' |
104 | | 'GMT-09:00 Alaska Standard Time' |
105 | | 'GMT-08:00 Alaska Standard Daylight Saving Time' |
106 | | 'GMT-10:00 Hawaii' |
107 | | 'GMT-11:00 Midway Island, Samoa' |
108 | | 'GMT-12:00 Eniwetok, Kwajalein' |
109 | disableInterEntityTransfer?: false | true |
110 | serviceChargeGLAccount?: { key?: string; id?: string; href?: string } |
111 | serviceChargeAccountLabel?: { key?: string; id?: string; href?: string } |
112 | interestGLAccount?: { key?: string; id?: string; href?: string } |
113 | interestAccountLabel?: { key?: string; id?: string; href?: string } |
114 | } |
115 | reconciliation?: { |
116 | lastReconciledBalance?: string |
117 | lastReconciledDate?: string |
118 | cutOffDate?: string |
119 | inProgressBalance?: string |
120 | inProgressDate?: string |
121 | matchSequence?: { key?: string; id?: string; href?: string } |
122 | useMatchSequenceForAutoMatch?: false | true |
123 | useMatchSequenceForManualMatch?: false | true |
124 | } |
125 | department?: { key?: string; id?: string; href?: string } |
126 | location?: { key?: string; id?: string; href?: string } |
127 | status?: 'active' | 'inactive' |
128 | audit?: { |
129 | createdDateTime?: string |
130 | modifiedDateTime?: string |
131 | createdBy?: string |
132 | modifiedBy?: string |
133 | } |
134 | entity?: { key?: string; id?: string; name?: string; href?: string } |
135 | bankingCloudConnection?: { |
136 | name?: string |
137 | bankName?: string |
138 | status?: |
139 | | 'notConnected' |
140 | | 'connectionRequested' |
141 | | 'inProgress' |
142 | | 'pending' |
143 | | 'pendingConfirmation' |
144 | | 'connected' |
145 | | 'authRequired' |
146 | | 'verifyingAuth' |
147 | | 'inactiveFeed' |
148 | | 'inactiveClient' |
149 | | 'canceled' |
150 | | 'invalid' |
151 | | 'canceling' |
152 | | 'disconnecting' |
153 | lastBankTxnDateTime?: string |
154 | lastRefreshedDateTime?: string |
155 | refreshStatus?: 'queued' | 'refreshing' | 'success' | 'partialSuccess' | 'failure' |
156 | supportMultiAccountLinking?: false | true |
157 | } |
158 | financialInstitution?: { id?: string; key?: string; href?: string } |
159 | ruleSet?: { key?: string; id?: string; href?: string } |
160 | restrictions?: { |
161 | restrictionType?: 'unrestricted' | 'rootOnly' | 'restricted' |
162 | locations?: string[] |
163 | } |
164 | } & { bankAccountDetails?: {}; accounting?: {} } |
165 | ) { |
166 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/cash-management/savings-account`) |
167 |
|
168 | const response = await fetch(url, { |
169 | method: 'POST', |
170 | headers: { |
171 | 'Content-Type': 'application/json', |
172 | Authorization: 'Bearer ' + auth.token |
173 | }, |
174 | body: JSON.stringify(body) |
175 | }) |
176 | if (!response.ok) { |
177 | const text = await response.text() |
178 | throw new Error(`${response.status} ${text}`) |
179 | } |
180 | return await response.json() |
181 | } |
182 |
|