0

Create an earning type

by
Published Oct 17, 2025

Creates a new earning type.

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
 * Create an earning type
7
 * Creates a new earning type.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		billableGLAccount?: {
15
			key?: string
16
			id?: string
17
			name?: string
18
			href?: string
19
		}
20
		nonBillableGLAccount?: {
21
			key?: string
22
			id?: string
23
			name?: string
24
			href?: string
25
		}
26
		rateMultiplier?: string
27
		calculationMethod?: 'hourly' | 'salary'
28
		audit?: {
29
			createdDateTime?: string
30
			modifiedDateTime?: string
31
			createdBy?: string
32
			modifiedBy?: string
33
		}
34
	} & {}
35
) {
36
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/earning-type`)
37

38
	const response = await fetch(url, {
39
		method: 'POST',
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