1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a transaction allocation template |
7 | * Creates a new transaction allocation template, optionally including allocation template lines. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCompany |
13 | User typeBusiness user with admin privileges |
14 | PermissionsAdd transaction allocations |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | description?: string |
26 | allocateBy?: 'percentage' | 'exactAmount' | 'fixedAmount' |
27 | documentNumber?: string |
28 | status?: 'active' | 'inactive' |
29 | attachment?: { key?: string; id?: string; href?: string } |
30 | audit?: { |
31 | createdDateTime?: string |
32 | modifiedDateTime?: string |
33 | createdBy?: string |
34 | modifiedBy?: string |
35 | } |
36 | href?: string |
37 | lines?: { |
38 | key?: string |
39 | id?: string |
40 | value?: string |
41 | valueType?: 'amount' | 'percent' |
42 | lineNumber?: number |
43 | dimensions?: { |
44 | location?: { key?: string; id?: string; name?: string; href?: string } |
45 | department?: { |
46 | key?: string |
47 | id?: string |
48 | name?: string |
49 | href?: string |
50 | } |
51 | employee?: { key?: string; id?: string; name?: string; href?: string } |
52 | project?: { key?: string; id?: string; name?: string; href?: string } |
53 | customer?: { key?: string; id?: string; name?: string; href?: string } |
54 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
55 | item?: { key?: string; id?: string; name?: string; href?: string } |
56 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
57 | class?: { key?: string; id?: string; name?: string; href?: string } |
58 | task?: { id?: string; key?: string; name?: string; href?: string } |
59 | costType?: { id?: string; key?: string; name?: string; href?: string } |
60 | asset?: { id?: string; key?: string; name?: string; href?: string } |
61 | contract?: { id?: string; key?: string; name?: string; href?: string } |
62 | affiliateEntity?: { |
63 | key?: string |
64 | id?: string |
65 | href?: string |
66 | name?: string |
67 | } |
68 | } & { |
69 | location?: { key?: string; id?: string; name?: string; href?: string } |
70 | department?: { |
71 | key?: string |
72 | id?: string |
73 | name?: string |
74 | href?: string |
75 | } |
76 | } |
77 | audit?: { |
78 | createdDateTime?: string |
79 | modifiedDateTime?: string |
80 | createdBy?: string |
81 | modifiedBy?: string |
82 | } |
83 | href?: string |
84 | txnAllocationTemplate?: { key?: string; id?: string; href?: string } |
85 | }[] |
86 | } & { lines: {}[] } |
87 | ) { |
88 | const url = new URL( |
89 | `https://api.intacct.com/ia/api/v1/objects/general-ledger/txn-allocation-template` |
90 | ) |
91 |
|
92 | const response = await fetch(url, { |
93 | method: 'POST', |
94 | headers: { |
95 | 'Content-Type': 'application/json', |
96 | Authorization: 'Bearer ' + auth.token |
97 | }, |
98 | body: JSON.stringify(body) |
99 | }) |
100 | if (!response.ok) { |
101 | const text = await response.text() |
102 | throw new Error(`${response.status} ${text}`) |
103 | } |
104 | return await response.json() |
105 | } |
106 |
|