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