0

Update a revenue recognition template

by
Published Oct 17, 2025

Updates an existing revenue recognition 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 revenue recognition template
7
 * Updates an existing revenue recognition 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
		useStandard?: false | true
18
		schedulePeriod?: 'daily' | 'monthly' | 'quarterly' | 'semiAnnually' | 'annually'
19
		postingDay?:
20
			| 'daily'
21
			| '1'
22
			| '2'
23
			| '3'
24
			| '4'
25
			| '5'
26
			| '6'
27
			| '7'
28
			| '8'
29
			| '9'
30
			| '10'
31
			| '11'
32
			| '12'
33
			| '13'
34
			| '14'
35
			| '15'
36
			| '16'
37
			| '17'
38
			| '18'
39
			| '19'
40
			| '20'
41
			| '21'
42
			| '22'
43
			| '23'
44
			| '24'
45
			| '25'
46
			| '26'
47
			| '27'
48
			| '28'
49
			| '29'
50
			| '30'
51
			| '31'
52
			| 'endOfPeriod'
53
		recognitionTerm?: 'fixedPeriod' | 'contractTerm' | 'project'
54
		resumeOption?: 'catchUp' | 'walkforward'
55
		totalPeriods?: string
56
		recognitionMethod?:
57
			| 'straightLine'
58
			| 'straightLine,prorateExactDays'
59
			| 'straightLine,percentAllocation'
60
			| 'straightLine,percentAllocation,endOfPeriod'
61
			| 'exactDaysPerPeriod,prorateDays'
62
			| 'exactDaysPerPeriod,prorateDays,endOfPeriod'
63
			| 'percentCompleted'
64
			| 'milestone'
65
			| 'custom'
66
		recognitionStartDate?: 'transactionDate' | 'userSpecified'
67
		postingMethod?: 'automatic' | 'manual'
68
		latestVersion?: string
69
		milestoneSource?: 'project' | 'manual'
70
		calculation?: {
71
			source?: 'project' | 'task'
72
			basedOn?:
73
				| 'estimatedHours'
74
				| 'plannedHours'
75
				| 'budgetedHours'
76
				| 'budgetedCostFromGL'
77
				| 'budgetedCostFromSummary'
78
				| 'observed%Completed'
79
		}
80
		status?: 'active' | 'inactive'
81
		entity?: { key?: string; id?: string; name?: string; href?: string }
82
		audit?: {
83
			createdDateTime?: string
84
			modifiedDateTime?: string
85
			createdBy?: string
86
			modifiedBy?: string
87
		}
88
	} & { id?: {} }
89
) {
90
	const url = new URL(
91
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/revenue-recognition-template${key}`
92
	)
93

94
	const response = await fetch(url, {
95
		method: 'PATCH',
96
		headers: {
97
			'Content-Type': 'application/json',
98
			Authorization: 'Bearer ' + auth.token
99
		},
100
		body: JSON.stringify(body)
101
	})
102
	if (!response.ok) {
103
		const text = await response.text()
104
		throw new Error(`${response.status} ${text}`)
105
	}
106
	return await response.json()
107
}
108