0

Create a subtotal template line object

by
Published Oct 17, 2025

Creates a new subtotal template line object.

Script sage_intacct Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type SageIntacct = {
3
	token: string
4
}
5
/**
6
 * Create a subtotal template line object
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
		txnType?: 'debit' | 'credit'
21
		applyToLineNumber?: number
22
		isTax?: false | true
23
		isAvalaraTax?: false | true
24
		glAccount?: { key?: string; id?: string; href?: string }
25
		offsetGLAccount?: { key?: string; id?: string; href?: string }
26
		href?: string
27
		subtotalTemplate?: { key?: string; id?: string; href?: string }
28
	} & { glAccount?: {}; offsetGLAccount?: {}; subtotalTemplate?: {} }
29
) {
30
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/purchasing/subtotal-template-line`)
31

32
	const response = await fetch(url, {
33
		method: 'POST',
34
		headers: {
35
			'Content-Type': 'application/json',
36
			Authorization: 'Bearer ' + auth.token
37
		},
38
		body: JSON.stringify(body)
39
	})
40
	if (!response.ok) {
41
		const text = await response.text()
42
		throw new Error(`${response.status} ${text}`)
43
	}
44
	return await response.json()
45
}
46