0

Update a transaction definition account detail object

by
Published Oct 17, 2025

Updates an existing transaction definition Account Payable or direct GL account detail object. 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 account detail object
7
 * Updates an existing transaction definition Account Payable or direct GL account detail object. 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
		isOffset?: false | true
17
		txnType?: 'debit' | 'credit'
18
		moduleType?: 'subledger' | 'inventory' | 'additional'
19
		lineNumber?: number
20
		glAccount?: { key?: string; id?: string; href?: string }
21
		location?: { href?: string; key?: string; id?: string }
22
		department?: { href?: string; key?: string; id?: string }
23
		itemGLGroup?: { href?: string; key?: string; id?: string }
24
		warehouse?: { href?: string; key?: string; id?: string }
25
		status?: 'active' | 'inactive'
26
		purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
27
	} & { id?: {} }
28
) {
29
	const url = new URL(
30
		`https://api.intacct.com/ia/api/v1/objects/purchasing/txn-definition-ap-direct-gl-detail/${key}`
31
	)
32

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