0

Update a contract revenue template

by
Published Oct 17, 2025

Updates a existing contract revenue template 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 contract revenue template
7
 * Updates a existing contract revenue template 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
		description?: string
17
		schedulePeriod?: 'monthly' | 'quarterly' | 'semiAnnually' | 'annually'
18
		recognitionMethod?:
19
			| 'straightLine'
20
			| 'dailyRate'
21
			| 'quantityBased'
22
			| 'predefinedPercentages'
23
			| 'projectPercentComplete'
24
			| 'taskPercentComplete'
25
			| 'recognizeRevenueOnInvoice'
26
		recognitionSource?:
27
			| 'estimatedHours'
28
			| 'observedPercentCompleted'
29
			| 'budgetedHours'
30
			| 'plannedHours'
31
		stepRevenue?: false | true
32
		defaultPostingType?: 'automatic' | 'manual'
33
		revenueAdjustmentOption?: 'oneTime' | 'distributed' | 'walkForward'
34
		recognitionPercentages?: {
35
			monthsOffset?: number
36
			percentToRecognize?: string
37
			thresholdPercent?: string
38
		}[]
39
		isSystemGenerated?: false | true
40
		status?: 'active' | 'inactive'
41
		audit?: {
42
			createdDateTime?: string
43
			modifiedDateTime?: string
44
			createdBy?: string
45
			modifiedBy?: string
46
			createdByUser?: { key?: string; id?: string; href?: string }
47
			modifiedByUser?: { key?: string; id?: string; href?: string }
48
		}
49
	} & { id?: {} }
50
) {
51
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/revenue-template/${key}`)
52

53
	const response = await fetch(url, {
54
		method: 'PATCH',
55
		headers: {
56
			'Content-Type': 'application/json',
57
			Authorization: 'Bearer ' + auth.token
58
		},
59
		body: JSON.stringify(body)
60
	})
61
	if (!response.ok) {
62
		const text = await response.text()
63
		throw new Error(`${response.status} ${text}`)
64
	}
65
	return await response.json()
66
}
67