0

Update a summary

by
Published Oct 17, 2025

Updates an existing AR summary 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 summary
7
 * Updates an existing AR summary 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
		name?: string
17
		summaryCreationType?: 'system' | 'manual'
18
		glPostingDate?: string
19
		recordType?: 'invoice' | 'payment' | 'adjustment' | 'discount' | 'overpayment'
20
		totalAmount?: string
21
		state?: 'open' | 'closed'
22
		parent?: { key?: string; id?: string; href?: string }
23
		preventGLPosting?: false | true
24
		isQuickPaymentSummary?: false | true
25
		status?: 'active' | 'inactive'
26
		entity?: { key?: string; id?: string; name?: string; href?: string }
27
	} & { id?: {} }
28
) {
29
	const url = new URL(
30
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/summary/${key}`
31
	)
32

33
	const response = await fetch(url, {
34
		method: 'PATCH',
35
		headers: {
36
			'Content-Type': 'application/json',
37
			Authorization: 'Bearer ' + auth.token
38
		},
39
		body: JSON.stringify(body)
40
	})
41
	if (!response.ok) {
42
		const text = await response.text()
43
		throw new Error(`${response.status} ${text}`)
44
	}
45
	return await response.json()
46
}
47