0

Update a WIP setup

by
Published Oct 17, 2025

Updates an existing WIP setup object by setting the field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionConstruction User typeBusiness user with admin privileges PermissionsEdit WIP Setups

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 WIP setup
7
 * Updates an existing WIP setup object by setting the field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionConstruction
13
User typeBusiness user with admin privileges
14
PermissionsEdit WIP Setups
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	key: string,
23
	body: {
24
		key?: string
25
		id?: string
26
		postingJournal?: string
27
		reconcileMethod?: 'autoReverse' | 'autoReverseBegin' | 'autoReverseEnd' | 'netChange'
28
		autoCreateNextPeriod?: false | true
29
		wipCostBreakdownLevel?: 'wipScheduleProject' | 'project' | 'costCode' | 'costCodeAndCostType'
30
		allowGroupCostCodes?: false | true
31
		wipSetupAccounts?: {
32
			key?: string
33
			id?: string
34
			wipAccountType?:
35
				| 'cost'
36
				| 'revenue'
37
				| 'overbilling'
38
				| 'underbilling'
39
				| 'offset'
40
				| 'underbillingOffset'
41
				| 'overbillingOffset'
42
			accountNumber?: string
43
			accountTitle?: string
44
			href?: string
45
			wipSetup?: { key?: string; id?: string; href?: string }
46
			audit?: {
47
				createdDateTime?: string
48
				modifiedDateTime?: string
49
				createdBy?: string
50
				modifiedBy?: string
51
			}
52
		}[]
53
		href?: string
54
		audit?: {
55
			createdDateTime?: string
56
			modifiedDateTime?: string
57
			createdBy?: string
58
			modifiedBy?: string
59
		}
60
	}
61
) {
62
	const url = new URL(
63
		`https://api.intacct.com/ia/api/v1/objects/construction-forecasting/wip-setup/${key}`
64
	)
65

66
	const response = await fetch(url, {
67
		method: 'PATCH',
68
		headers: {
69
			'Content-Type': 'application/json',
70
			Authorization: 'Bearer ' + auth.token
71
		},
72
		body: JSON.stringify(body)
73
	})
74
	if (!response.ok) {
75
		const text = await response.text()
76
		throw new Error(`${response.status} ${text}`)
77
	}
78
	return await response.json()
79
}
80