0

Update an earning type

by
Published Oct 17, 2025

Updates an existing earning type 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 an earning type
7
 * Updates an existing earning type 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
		billableGLAccount?: {
16
			key?: string
17
			id?: string
18
			name?: string
19
			href?: string
20
		}
21
		nonBillableGLAccount?: {
22
			key?: string
23
			id?: string
24
			name?: string
25
			href?: string
26
		}
27
		rateMultiplier?: string
28
		calculationMethod?: 'hourly' | 'salary'
29
		audit?: {
30
			createdDateTime?: string
31
			modifiedDateTime?: string
32
			createdBy?: string
33
			modifiedBy?: string
34
		}
35
	} & { id?: {} }
36
) {
37
	const url = new URL(
38
		`https://api.intacct.com/ia/api/v1/objects/company-config/earning-type/${key}`
39
	)
40

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