1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a subtotal template |
7 | * Creates a new purchasing subtotal template. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | moduleKey?: string |
15 | href?: string |
16 | lines?: { |
17 | key?: string |
18 | id?: string |
19 | description?: string |
20 | subtotalType?: 'discount' | 'charge' |
21 | lineNumber?: number |
22 | valueType?: 'amount' | 'percent' |
23 | defaultValue?: string |
24 | isApportioned?: false | true |
25 | txnType?: 'debit' | 'credit' |
26 | applyToLineNumber?: number |
27 | isTax?: false | true |
28 | isAvalaraTax?: false | true |
29 | glAccount?: { key?: string; id?: string; href?: string } |
30 | offsetGLAccount?: { key?: string; id?: string; href?: string } |
31 | href?: string |
32 | subtotalTemplate?: { key?: string; id?: string; href?: string } |
33 | }[] |
34 | audit?: { |
35 | createdDateTime?: string |
36 | modifiedDateTime?: string |
37 | createdBy?: string |
38 | modifiedBy?: string |
39 | } |
40 | } & { lines?: { glAccount?: {}; offsetGLAccount?: {} }[] } |
41 | ) { |
42 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/purchasing/subtotal-template`) |
43 |
|
44 | const response = await fetch(url, { |
45 | method: 'POST', |
46 | headers: { |
47 | 'Content-Type': 'application/json', |
48 | Authorization: 'Bearer ' + auth.token |
49 | }, |
50 | body: JSON.stringify(body) |
51 | }) |
52 | if (!response.ok) { |
53 | const text = await response.text() |
54 | throw new Error(`${response.status} ${text}`) |
55 | } |
56 | return await response.json() |
57 | } |
58 |
|