0

Update an advance

by
Published Oct 17, 2025

Updates an existing advance by setting field values. Any fields not provided remain unchanged. Advances that have not yet been applied to an invoice can be updated. The General Ledger account book for the advance must also be open. If an advance was applied to an invoice and later unapplied, it cannot be updated. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness, Employee, Project Manager, and Warehouse users PermissionsList, View, Edit Advances

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 an advance
7
 * Updates an existing advance by setting field values. Any fields not provided remain unchanged. Advances that have not yet been applied to an invoice can be updated. The General Ledger account book for the advance must also be open. If an advance was applied to an invoice and later unapplied, it cannot be updated.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness, Employee, Project Manager, and Warehouse users
14
PermissionsList, View, Edit Advances
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
		recordType?: string
27
		href?: string
28
		referenceNumber?: string
29
		description?: string
30
		state?:
31
			| 'reversed'
32
			| 'reversal'
33
			| 'draft'
34
			| 'reconciled'
35
			| 'fullyApplied'
36
			| 'partiallyApplied'
37
			| 'posted'
38
			| 'selected'
39
		totalEntered?: string
40
		txnTotalEntered?: string
41
		paymentInformation?: {
42
			paymentDate?: string
43
			totalPaid?: string
44
			totalSelected?: string
45
			txnTotalSelected?: string
46
			txnTotalPaid?: string
47
			totalDue?: string
48
			totalTxnAmountDue?: string
49
			paymentMethod?: 'printedCheck' | 'creditCard' | 'eft' | 'cash' | 'ach'
50
			receiptDate?: string
51
			financialEntity?: { key?: string; id?: string; href?: string }
52
			currency?: {
53
				exchangeRateDate?: string
54
				exchangeRateTypeId?: string
55
				exchangeRate?: number
56
				baseCurrency?: string
57
				txnCurrency?: string
58
			}
59
		}
60
		reconciliationGroup?: {
61
			clearingDate?: string
62
			cleared?: 'true' | 'false' | 'matched'
63
		}
64
		isSystemGenerated?: false | true
65
		createdDate?: string
66
		deposit?: { key?: string; id?: string; href?: string }
67
		advanceSummary?: { href?: string; key?: string; id?: string }
68
		customer?: { href?: string; id?: string; key?: string; name?: string }
69
		glAccount?: {
70
			href?: string
71
			id?: string
72
			key?: string
73
			undepositedGLAccountNumber?: string
74
		}
75
		attachment?: { key?: string; id?: string; href?: string }
76
		items?: {
77
			key?: string
78
			id?: string
79
			href?: string
80
			baseAmount?: string
81
			txnAmount?: string
82
			memo?: string
83
			currency?: {
84
				baseCurrency?: string
85
				txnCurrency?: string
86
				exchangeRate?: { date?: string; rate?: number; typeId?: string }
87
			}
88
			lineNumber?: number
89
			paymentInformation?: {
90
				totalPaid?: string
91
				txnTotalPaid?: string
92
				totalSelected?: string
93
				txnTotalSelected?: string
94
			}
95
			baseLocation?: {
96
				key?: string
97
				id?: string
98
				name?: string
99
				href?: string
100
			} & { key?: string }
101
			accountLabel?: {
102
				key?: string
103
				id?: string
104
				name?: string
105
				href?: string
106
			}
107
			glAccount?: { key?: string; id?: string; name?: string; href?: string }
108
			dimensions?: {
109
				location?: { key?: string; id?: string; name?: string; href?: string }
110
				department?: {
111
					key?: string
112
					id?: string
113
					name?: string
114
					href?: string
115
				}
116
				employee?: { key?: string; id?: string; name?: string; href?: string }
117
				project?: { key?: string; id?: string; name?: string; href?: string }
118
				customer?: { key?: string; id?: string; name?: string; href?: string }
119
				vendor?: { key?: string; id?: string; name?: string; href?: string }
120
				item?: { key?: string; id?: string; name?: string; href?: string }
121
				warehouse?: { key?: string; id?: string; name?: string; href?: string }
122
				class?: { key?: string; id?: string; name?: string; href?: string }
123
				task?: { id?: string; key?: string; name?: string; href?: string }
124
				costType?: { id?: string; key?: string; name?: string; href?: string }
125
				asset?: { id?: string; key?: string; name?: string; href?: string }
126
				contract?: { id?: string; key?: string; name?: string; href?: string }
127
				affiliateEntity?: {
128
					key?: string
129
					id?: string
130
					href?: string
131
					name?: string
132
				}
133
			} & {
134
				location?: { key?: string; id?: string; name?: string; href?: string }
135
				department?: {
136
					key?: string
137
					id?: string
138
					name?: string
139
					href?: string
140
				}
141
			}
142
			arAdvance?: {
143
				id?: string
144
				key?: string
145
				href?: string
146
				recordType?: string
147
			}
148
			audit?: {
149
				createdDateTime?: string
150
				modifiedDateTime?: string
151
				createdBy?: string
152
				modifiedBy?: string
153
			}
154
		}[]
155
		entity?: { key?: string; id?: string; name?: string; href?: string }
156
		audit?: {
157
			createdDateTime?: string
158
			modifiedDateTime?: string
159
			createdBy?: string
160
			modifiedBy?: string
161
		}
162
	} & { id?: {} }
163
) {
164
	const url = new URL(
165
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/advance/${key}`
166
	)
167

168
	const response = await fetch(url, {
169
		method: 'PATCH',
170
		headers: {
171
			'Content-Type': 'application/json',
172
			Authorization: 'Bearer ' + auth.token
173
		},
174
		body: JSON.stringify(body)
175
	})
176
	if (!response.ok) {
177
		const text = await response.text()
178
		throw new Error(`${response.status} ${text}`)
179
	}
180
	return await response.json()
181
}
182