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