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