1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an account allocation run |
7 | * Creates a new account allocation run. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | href?: string |
15 | allocationType?: 'dynamicAllocation' | 'restrictionRelease' |
16 | asOfDate?: string |
17 | glPostingDate?: string |
18 | email?: string |
19 | state?: 'success' | 'failed' | 'inProgress' | 'queued' | 'partialSuccess' |
20 | message?: string |
21 | parent?: { key?: string; id?: string; href?: string } |
22 | allocationRunType?: 'regular' | 'parent' | 'child' |
23 | accountAllocation?: { id?: string; key?: string; href?: string } |
24 | accountAllocationGroup?: { |
25 | href?: string |
26 | key?: string |
27 | id?: string |
28 | name?: string |
29 | } |
30 | dimensions?: { |
31 | employee?: { key?: string; id?: string; name?: string; href?: string } |
32 | project?: { key?: string; id?: string; name?: string; href?: string } |
33 | } |
34 | entity?: { key?: string; id?: string; name?: string; href?: string } |
35 | audit?: { |
36 | createdDateTime?: string |
37 | modifiedDateTime?: string |
38 | createdBy?: string |
39 | modifiedBy?: string |
40 | } |
41 | } & {} |
42 | ) { |
43 | const url = new URL( |
44 | `https://api.intacct.com/ia/api/v1/objects/general-ledger/account-allocation-run` |
45 | ) |
46 |
|
47 | const response = await fetch(url, { |
48 | method: 'POST', |
49 | headers: { |
50 | 'Content-Type': 'application/json', |
51 | Authorization: 'Bearer ' + auth.token |
52 | }, |
53 | body: JSON.stringify(body) |
54 | }) |
55 | if (!response.ok) { |
56 | const text = await response.text() |
57 | throw new Error(`${response.status} ${text}`) |
58 | } |
59 | return await response.json() |
60 | } |
61 |
|