0

Update a Purchasing tax detail

by
Published Oct 17, 2025

Updates an existing Purchasing tax detail 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 Purchasing tax detail
7
 * Updates an existing Purchasing tax detail 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
		status?: 'active' | 'inactive'
17
		taxUniqueId?: string
18
		taxRate?: 'standard' | 'reduced' | 'exempt' | 'zero' | 'federal' | 'provincial'
19
		amountToTax?: 'fullAmount' | 'amountWithinRange'
20
		description?: string
21
		taxPercent?: number
22
		taxLimit?: {
23
			minTaxable?: number
24
			maxTaxable?: number
25
			minTax?: number
26
			maxTax?: number
27
		}
28
		reverseCharge?: false | true
29
		useExpenseAccount?: false | true
30
		isSystemGenerated?: false | true
31
		taxAuthority?: { id?: string; key?: string; href?: string }
32
		purchaseGLAccount?: { id?: string; key?: string; href?: string }
33
		taxSolution?: { key?: string; id?: string; href?: string }
34
	} & { id?: {} }
35
) {
36
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/tax/purchasing-tax-detail/${key}`)
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