0

Update a transaction definition subtotal detail object

by
Published Oct 17, 2025

Updates an existing transaction definition subtotal detail 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 transaction definition subtotal detail object
7
 * Updates an existing transaction definition subtotal detail 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
		href?: string
16
		subtotalType?: 'discount' | 'charge'
17
		lineNumber?: number
18
		description?: string
19
		valueType?: 'amount' | 'percent'
20
		subtotalValue?: string
21
		isApportioned?: false | true
22
		glAccount?: { key?: string; id?: string; href?: string }
23
		offsetGLAccount?: { key?: string; id?: string; href?: string }
24
		txnType?: 'debit' | 'credit'
25
		appliedToLineNumber?: number
26
		isTax?: false | true
27
		department?: { href?: string; key?: string; id?: string }
28
		location?: { key?: string; id?: string; href?: string }
29
		enableAvalaraTax?: false | true
30
		entity?: { href?: string; key?: string; id?: string }
31
		purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
32
	} & { id?: {} }
33
) {
34
	const url = new URL(
35
		`https://api.intacct.com/ia/api/v1/objects/purchasing/txn-definition-subtotal-detail/${key}`
36
	)
37

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