1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a transaction allocation template |
7 | * Updates an existing allocation template and template lines by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCompany |
13 | User typeBusiness user with admin privileges |
14 | PermissionsEdit transaction allocations |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | description?: string |
27 | allocateBy?: 'percentage' | 'exactAmount' | 'fixedAmount' |
28 | documentNumber?: string |
29 | status?: 'active' | 'inactive' |
30 | attachment?: { key?: string; id?: string; href?: string } |
31 | audit?: { |
32 | createdDateTime?: string |
33 | modifiedDateTime?: string |
34 | createdBy?: string |
35 | modifiedBy?: string |
36 | } |
37 | href?: string |
38 | lines?: { |
39 | key?: string |
40 | id?: string |
41 | value?: string |
42 | valueType?: 'amount' | 'percent' |
43 | lineNumber?: number |
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 | txnAllocationTemplate?: { key?: string; id?: string; href?: string } |
86 | }[] |
87 | } & { id?: {} } |
88 | ) { |
89 | const url = new URL( |
90 | `https://api.intacct.com/ia/api/v1/objects/general-ledger/txn-allocation-template/${key}` |
91 | ) |
92 |
|
93 | const response = await fetch(url, { |
94 | method: 'PATCH', |
95 | headers: { |
96 | 'Content-Type': 'application/json', |
97 | Authorization: 'Bearer ' + auth.token |
98 | }, |
99 | body: JSON.stringify(body) |
100 | }) |
101 | if (!response.ok) { |
102 | const text = await response.text() |
103 | throw new Error(`${response.status} ${text}`) |
104 | } |
105 | return await response.json() |
106 | } |
107 |
|