0

Update a subtotal template line

by
Published Oct 17, 2025

Updates an existing subtotal template line object by setting field values. Any fields not provided remain unchanged.

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
 * Update a subtotal template line
7
 * Updates an existing subtotal template line object by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		description?: string
16
		subtotalType?: 'discount' | 'charge'
17
		lineNumber?: number
18
		valueType?: 'amount' | 'percent'
19
		defaultValue?: 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
		applyToLineNumber?: number
25
		isTax?: false | true
26
		isAvalaraTax?: false | true
27
		href?: string
28
		subtotalTemplate?: { key?: string; id?: string; href?: string }
29
	} & {}
30
) {
31
	const url = new URL(
32
		`https://api.intacct.com/ia/api/v1/objects/order-entry/subtotal-template-line/${key}`
33
	)
34

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