1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an account group |
7 | * Creates a new account group. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | title?: string |
15 | displayTotalLineAs?: string |
16 | manager?: string |
17 | calculationMethod?: 'period' | 'startOfPeriod' | 'endOfPeriod' |
18 | normalBalance?: 'debit' | 'credit' |
19 | groupType?: |
20 | | 'accounts' |
21 | | 'groups' |
22 | | 'statisticalAccounts' |
23 | | 'computation' |
24 | | 'category' |
25 | | 'statisticalCategory' |
26 | isKPI?: false | true |
27 | includeChildAmount?: false | true |
28 | accountGroupPurpose?: { key?: string; id?: string; href?: string } |
29 | reportFilters?: { |
30 | location?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
31 | debitOrCredit?: 'both' | 'debitOnly' | 'creditOnly' |
32 | department?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
33 | vendor?: 'noFilter' | 'specificHierarchy' | 'specific' | 'unspecified' |
34 | customer?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
35 | project?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
36 | employee?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
37 | item?: 'noFilter' | 'specific' | 'nullValue' |
38 | class?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
39 | contract?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
40 | task?: 'noFilter' | 'nullValue' |
41 | warehouse?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
42 | costType?: 'noFilter' | 'nullValue' |
43 | asset?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue' |
44 | affiliateEntity?: 'noFilter' | 'specific' | 'nullValue' |
45 | } |
46 | dimensions?: { |
47 | location?: { key?: string; id?: string; name?: string; href?: string } |
48 | department?: { key?: string; id?: string; name?: string; href?: string } |
49 | employee?: { key?: string; id?: string; name?: string; href?: string } |
50 | project?: { key?: string; id?: string; name?: string; href?: string } |
51 | customer?: { key?: string; id?: string; name?: string; href?: string } |
52 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
53 | item?: { key?: string; id?: string; name?: string; href?: string } |
54 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
55 | class?: { key?: string; id?: string; name?: string; href?: string } |
56 | task?: { id?: string; key?: string; name?: string; href?: string } |
57 | costType?: { id?: string; key?: string; name?: string; href?: string } |
58 | asset?: { id?: string; key?: string; name?: string; href?: string } |
59 | contract?: { id?: string; key?: string; name?: string; href?: string } |
60 | affiliateEntity?: { |
61 | key?: string |
62 | id?: string |
63 | href?: string |
64 | name?: string |
65 | } |
66 | } & { |
67 | location?: { key?: string; id?: string; name?: string; href?: string } |
68 | locationGroup?: { |
69 | key?: string |
70 | id?: string |
71 | name?: string |
72 | href?: string |
73 | } |
74 | department?: { key?: string; id?: string; name?: string; href?: string } |
75 | departmentGroup?: { |
76 | key?: string |
77 | id?: string |
78 | name?: string |
79 | href?: string |
80 | } |
81 | } |
82 | accountRanges?: { |
83 | key?: string |
84 | id?: string |
85 | sortOrder?: number |
86 | rangeFrom?: string |
87 | rangeTo?: string |
88 | glAccountGroup?: { key?: string; id?: string; href?: string } |
89 | audit?: { |
90 | createdDateTime?: string |
91 | modifiedDateTime?: string |
92 | createdBy?: string |
93 | modifiedBy?: string |
94 | } |
95 | href?: string |
96 | }[] |
97 | statisticalAccountRanges?: { |
98 | key?: string |
99 | id?: string |
100 | sortOrder?: number |
101 | rangeFrom?: string |
102 | rangeTo?: string |
103 | glAccountGroup?: { key?: string; id?: string; href?: string } |
104 | audit?: { |
105 | createdDateTime?: string |
106 | modifiedDateTime?: string |
107 | createdBy?: string |
108 | modifiedBy?: string |
109 | } |
110 | href?: string |
111 | }[] |
112 | accountGroupMembers?: { |
113 | key?: string |
114 | id?: string |
115 | href?: string |
116 | sortOrder?: number |
117 | accountGroup?: { key?: string; id?: string; href?: string } |
118 | glAccountGroup?: { key?: string; id?: string; href?: string } |
119 | audit?: { |
120 | createdDateTime?: string |
121 | modifiedDateTime?: string |
122 | createdBy?: string |
123 | modifiedBy?: string |
124 | } |
125 | }[] |
126 | accountGroupCategoryMembers?: { |
127 | key?: string |
128 | id?: string |
129 | href?: string |
130 | sortOrder?: number |
131 | accountCategory?: { key?: string; id?: string; href?: string } |
132 | glAccountGroup?: { key?: string; id?: string; href?: string } |
133 | audit?: { |
134 | createdDateTime?: string |
135 | modifiedDateTime?: string |
136 | createdBy?: string |
137 | modifiedBy?: string |
138 | } |
139 | }[] |
140 | statisticalAccountGroupCategoryMembers?: { |
141 | key?: string |
142 | id?: string |
143 | href?: string |
144 | sortOrder?: number |
145 | accountCategory?: { key?: string; id?: string; href?: string } |
146 | glAccountGroup?: { key?: string; id?: string; href?: string } |
147 | audit?: { |
148 | createdDateTime?: string |
149 | modifiedDateTime?: string |
150 | createdBy?: string |
151 | modifiedBy?: string |
152 | } |
153 | }[] |
154 | accountGroupComputation?: { |
155 | key?: string |
156 | id?: string |
157 | href?: string |
158 | formulaLeft?: |
159 | | { glAccountGroup?: { id?: string; key?: string; href?: string } } |
160 | | { |
161 | glAccount?: { |
162 | id?: string |
163 | key?: string |
164 | name?: string |
165 | href?: string |
166 | } |
167 | asOf?: 'startOfPeriod' | 'endOfPeriod' | 'forPeriod' |
168 | } |
169 | | { constant?: string } |
170 | operator?: 'add' | 'subtract' | 'multiply' | 'divide' |
171 | formulaRight?: |
172 | | { glAccountGroup?: { id?: string; key?: string; href?: string } } |
173 | | { |
174 | glAccount?: { |
175 | id?: string |
176 | key?: string |
177 | name?: string |
178 | href?: string |
179 | } |
180 | asOf?: 'startOfPeriod' | 'endOfPeriod' | 'forPeriod' |
181 | } |
182 | | { constant?: string } |
183 | numberOfDecimalPlaces?: number |
184 | displayAs?: |
185 | | 'number' |
186 | | 'percent' |
187 | | 'ratioWithDecimals' |
188 | | 'ratioWithoutDecimals' |
189 | | 'dailyAverage' |
190 | | 'weeklyAverage' |
191 | | 'monthlyAverage' |
192 | | 'quarterlyAverage' |
193 | unit?: string |
194 | unitPlacement?: 'left' | 'right' |
195 | glAccountGroup?: { key?: string; id?: string; href?: string } |
196 | audit?: { |
197 | createdDateTime?: string |
198 | modifiedDateTime?: string |
199 | createdBy?: string |
200 | modifiedBy?: string |
201 | } |
202 | }[] |
203 | audit?: { |
204 | createdDateTime?: string |
205 | modifiedDateTime?: string |
206 | createdBy?: string |
207 | modifiedBy?: string |
208 | } |
209 | href?: string |
210 | } & {} |
211 | ) { |
212 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-group`) |
213 |
|
214 | const response = await fetch(url, { |
215 | method: 'POST', |
216 | headers: { |
217 | 'Content-Type': 'application/json', |
218 | Authorization: 'Bearer ' + auth.token |
219 | }, |
220 | body: JSON.stringify(body) |
221 | }) |
222 | if (!response.ok) { |
223 | const text = await response.text() |
224 | throw new Error(`${response.status} ${text}`) |
225 | } |
226 | return await response.json() |
227 | } |
228 |
|