1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an account allocation definition |
7 | * Creates a new account allocation definition. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | name?: string |
15 | description?: string |
16 | methodology?: string |
17 | journal?: { key?: string; id?: string; href?: string } |
18 | attachment?: { key?: string; id?: string; href?: string } |
19 | latestVersion?: number |
20 | dimensionTreatment?: { |
21 | location?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
22 | department?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
23 | project?: 'notConsidered' | 'preserveValues' | 'allocationFocus' | 'perDimensionValue' |
24 | customer?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
25 | vendor?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
26 | employee?: 'notConsidered' | 'preserveValues' | 'allocationFocus' | 'perDimensionValue' |
27 | class?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
28 | item?: 'notConsidered' | 'preserveValues' | 'allocationFocus' |
29 | warehouse?: 'notConsidered' |
30 | contract?: 'notConsidered' |
31 | } |
32 | activityDelta?: false | true |
33 | autoReversePriorPostedJournalEntry?: false | true |
34 | glAccountAllocationSource?: { |
35 | key?: string |
36 | id?: string |
37 | percentToAllocate?: string |
38 | timePeriod?: { key?: string; id?: string; href?: string } |
39 | reportingBook?: 'accrual' | 'cash' |
40 | currency?: string |
41 | useAmountsFrom?: 'mainReportingBookAndAlternateBooks' | 'alternateBooksOnly' |
42 | glAccountAllocation?: { key?: string; id?: string; href?: string } |
43 | glAccountGroup?: { key?: string; id?: string; href?: string } |
44 | dimensions?: { |
45 | location?: { key?: string; id?: string; name?: string; href?: string } |
46 | department?: { |
47 | key?: string |
48 | id?: string |
49 | name?: string |
50 | href?: string |
51 | } |
52 | employee?: { key?: string; id?: string; name?: string; href?: string } |
53 | project?: { key?: string; id?: string; name?: string; href?: string } |
54 | customer?: { key?: string; id?: string; name?: string; href?: string } |
55 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
56 | item?: { key?: string; id?: string; name?: string; href?: string } |
57 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
58 | class?: { key?: string; id?: string; name?: string; href?: string } |
59 | task?: { id?: string; key?: string; name?: string; href?: string } |
60 | costType?: { id?: string; key?: string; name?: string; href?: string } |
61 | asset?: { id?: string; key?: string; name?: string; href?: string } |
62 | contract?: { id?: string; key?: string; name?: string; href?: string } |
63 | affiliateEntity?: { |
64 | key?: string |
65 | id?: string |
66 | href?: string |
67 | name?: string |
68 | } |
69 | } & { |
70 | location?: { key?: string; id?: string; name?: string; href?: string } |
71 | department?: { |
72 | key?: string |
73 | id?: string |
74 | name?: string |
75 | href?: string |
76 | } |
77 | } |
78 | audit?: { |
79 | createdDateTime?: string |
80 | modifiedDateTime?: string |
81 | createdBy?: string |
82 | modifiedBy?: string |
83 | } |
84 | href?: string |
85 | }[] |
86 | glAccountAllocationBasis?: { |
87 | key?: string |
88 | id?: string |
89 | glAccountAllocation?: { key?: string; id?: string; href?: string } |
90 | accumulation?: 'activity' | 'endingBalance' |
91 | timePeriod?: { key?: string; id?: string; href?: string } |
92 | reportingBook?: 'accrual' | 'cash' |
93 | allocationMethod?: 'dynamicRelativeAccountFinancial' | 'dynamicRelativeAccountStatistical' |
94 | skipNegative?: false | true |
95 | useAmountsFrom?: 'mainReportingBookAndAlternateBooks' | 'alternateBooksOnly' |
96 | glAccountGroup?: { key?: string; id?: string; href?: string } |
97 | dimensions?: { |
98 | location?: { key?: string; id?: string; name?: string; href?: string } |
99 | department?: { |
100 | key?: string |
101 | id?: string |
102 | name?: string |
103 | href?: string |
104 | } |
105 | employee?: { key?: string; id?: string; name?: string; href?: string } |
106 | project?: { key?: string; id?: string; name?: string; href?: string } |
107 | customer?: { key?: string; id?: string; name?: string; href?: string } |
108 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
109 | item?: { key?: string; id?: string; name?: string; href?: string } |
110 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
111 | class?: { key?: string; id?: string; name?: string; href?: string } |
112 | task?: { id?: string; key?: string; name?: string; href?: string } |
113 | costType?: { id?: string; key?: string; name?: string; href?: string } |
114 | asset?: { id?: string; key?: string; name?: string; href?: string } |
115 | contract?: { id?: string; key?: string; name?: string; href?: string } |
116 | affiliateEntity?: { |
117 | key?: string |
118 | id?: string |
119 | href?: string |
120 | name?: string |
121 | } |
122 | } & { |
123 | location?: { key?: string; id?: string; name?: string; href?: string } |
124 | department?: { |
125 | key?: string |
126 | id?: string |
127 | name?: string |
128 | href?: string |
129 | } |
130 | } |
131 | audit?: { |
132 | createdDateTime?: string |
133 | modifiedDateTime?: string |
134 | createdBy?: string |
135 | modifiedBy?: string |
136 | } |
137 | href?: string |
138 | }[] |
139 | glAccountAllocationTarget?: { |
140 | key?: string |
141 | id?: string |
142 | glAccountAllocation?: { key?: string; id?: string; href?: string } |
143 | glAccountGroup?: { key?: string; id?: string; href?: string } |
144 | isBillable?: false | true |
145 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
146 | journal?: { key?: string; id?: string; title?: string; href?: string } |
147 | dimensions?: { |
148 | class?: { key?: string; name?: string; id?: string; href?: string } |
149 | customer?: { key?: string; name?: string; id?: string; href?: string } |
150 | employee?: { key?: string; name?: string; id?: string; href?: string } |
151 | department?: { |
152 | key?: string |
153 | id?: string |
154 | name?: string |
155 | href?: string |
156 | } |
157 | location?: { key?: string; id?: string; name?: string; href?: string } |
158 | project?: { key?: string; name?: string; id?: string; href?: string } |
159 | vendor?: { key?: string; name?: string; id?: string; href?: string } |
160 | warehouse?: { key?: string; name?: string; id?: string; href?: string } |
161 | item?: { key?: string; name?: string; id?: string; href?: string } |
162 | contract?: { key?: string; name?: string; id?: string; href?: string } |
163 | } |
164 | audit?: { |
165 | createdDateTime?: string |
166 | modifiedDateTime?: string |
167 | createdBy?: string |
168 | modifiedBy?: string |
169 | } |
170 | href?: string |
171 | }[] |
172 | glAccountAllocationReverse?: { |
173 | key?: string |
174 | id?: string |
175 | glAccountAllocation?: { key?: string; id?: string; href?: string } |
176 | useSourceAccount?: false | true |
177 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
178 | dimensions?: { |
179 | class?: { key?: string; name?: string; id?: string; href?: string } |
180 | customer?: { key?: string; name?: string; id?: string; href?: string } |
181 | employee?: { key?: string; name?: string; id?: string; href?: string } |
182 | department?: { |
183 | key?: string |
184 | id?: string |
185 | name?: string |
186 | href?: string |
187 | } |
188 | location?: { key?: string; id?: string; name?: string; href?: string } |
189 | project?: { key?: string; name?: string; id?: string; href?: string } |
190 | vendor?: { key?: string; name?: string; id?: string; href?: string } |
191 | warehouse?: { key?: string; name?: string; id?: string; href?: string } |
192 | item?: { key?: string; name?: string; id?: string; href?: string } |
193 | contract?: { key?: string; name?: string; id?: string; href?: string } |
194 | } |
195 | audit?: { |
196 | createdDateTime?: string |
197 | modifiedDateTime?: string |
198 | createdBy?: string |
199 | modifiedBy?: string |
200 | } |
201 | href?: string |
202 | }[] |
203 | allowAllocation?: 'withinOneEntity' | 'acrossEntities' |
204 | status?: 'active' | 'inactive' |
205 | audit?: { |
206 | createdDateTime?: string |
207 | modifiedDateTime?: string |
208 | createdBy?: string |
209 | modifiedBy?: string |
210 | } & { createdBy?: string; modifiedBy?: string } |
211 | entity?: { key?: string; id?: string; name?: string; href?: string } |
212 | href?: string |
213 | } & {} |
214 | ) { |
215 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-allocation`) |
216 |
|
217 | const response = await fetch(url, { |
218 | method: 'POST', |
219 | headers: { |
220 | 'Content-Type': 'application/json', |
221 | Authorization: 'Bearer ' + auth.token |
222 | }, |
223 | body: JSON.stringify(body) |
224 | }) |
225 | if (!response.ok) { |
226 | const text = await response.text() |
227 | throw new Error(`${response.status} ${text}`) |
228 | } |
229 | return await response.json() |
230 | } |
231 |
|