0

Create an employee expense

by
Published Oct 17, 2025

Creates a new employee expense. You must specify a unique employee expense ID when creating an employee expense unless document sequencing is configured, in which case the ID is auto-generated. Permissions and other requirements SubscriptionTime & Expenses User typeBusiness, Employee PermissionsAdd Expenses

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
 * Create an employee expense
7
 * Creates a new employee expense. You must specify a unique employee expense ID when creating an employee expense unless document sequencing is configured, in which case the ID is auto-generated.
8

9

10
Permissions and other requirements
11

12
SubscriptionTime & Expenses
13
User typeBusiness, Employee
14
PermissionsAdd Expenses
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		createdDate?: string
26
		employee?: { key?: string; id?: string; href?: string }
27
		employeeContact?: {
28
			key?: string
29
			id?: string
30
			firstName?: string
31
			lastName?: string
32
			href?: string
33
		}
34
		state?:
35
			| 'draft'
36
			| 'submitted'
37
			| 'partiallyApproved'
38
			| 'partiallyDeclined'
39
			| 'approved'
40
			| 'posted'
41
			| 'declined'
42
			| 'reversalPending'
43
			| 'reversed'
44
			| 'reversal'
45
			| 'paid'
46
			| 'confirmed'
47
			| 'voided'
48
			| 'partiallyPaid'
49
			| 'selected'
50
		basePayment?: {
51
			baseCurrency?: string
52
			paidDate?: string
53
			totalEntered?: string
54
			totalPaid?: string
55
			totalDue?: string
56
			totalSelected?: string
57
		}
58
		reimbursement?: {
59
			reimbursementCurrency?: string
60
			totalEntered?: string
61
			totalPaid?: string
62
			totalDue?: string
63
			totalSelected?: string
64
		}
65
		expenseReportNumber?: string
66
		expenseSummary?: {
67
			key?: string
68
			id?: string
69
			title?: string
70
			postingDate?: string
71
			state?: 'open' | 'closed'
72
			preventGLPosting?: false | true
73
			href?: string
74
		}
75
		nonReimbursable?: {
76
			baseTotalEntered?: string
77
			reimbursementTotalEntered?: string
78
		}
79
		memo?: string
80
		description?: string
81
		reclassificationNotes?: string
82
		attachment?: { key?: string; id?: string; href?: string }
83
		audit?: {
84
			createdDateTime?: string
85
			modifiedDateTime?: string
86
			createdBy?: string
87
			modifiedBy?: string
88
		} & { createdDateTime?: string }
89
		lines?: {
90
			key?: string
91
			id?: string
92
			href?: string
93
			entryDate?: string
94
			baseCurrency?: string
95
			baseAmount?: string
96
			reimbursementCurrency?: string
97
			reimbursementAmount?: string
98
			txnCurrency?: string
99
			txnAmount?: string
100
			totalSelected?: string
101
			totalPaid?: string
102
			quantity?: string
103
			unitRate?: string
104
			paidTo?: string
105
			paidFor?: string
106
			glAccount?: { key?: string; id?: string; name?: string; href?: string }
107
			expenseType?: { key?: string; id?: string; href?: string }
108
			lineNumber?: number
109
			reimburseToBaseConversion?: {
110
				exchangeRateDate?: string
111
				exchangeRateTypeId?: string
112
				exchangeRate?: string
113
			}
114
			transactionToReimburseConversion?: {
115
				exchangeRate?: string
116
				exchangeRateDate?: string
117
				exchangeRateTypeId?: string
118
			}
119
			state?:
120
				| 'draft'
121
				| 'submitted'
122
				| 'partiallyApproved'
123
				| 'partiallyDeclined'
124
				| 'approved'
125
				| 'posted'
126
				| 'declined'
127
				| 'reversalPending'
128
				| 'reversed'
129
				| 'reversal'
130
				| 'paid'
131
				| 'confirmed'
132
				| 'voided'
133
				| 'partiallyPaid'
134
				| 'saved'
135
			isBillable?: false | true
136
			isBilled?: false | true
137
			form1099?: { isForm1099?: string; type?: string; box?: string }
138
			paymentType?: {
139
				key?: string
140
				id?: string
141
				isNonReimbursable?: false | true
142
				href?: string
143
			}
144
			electronicReceipt?: { id?: string; key?: string; href?: string }
145
			electronicReceiptLine?: { id?: string; key?: string; href?: string }
146
			audit?: {
147
				createdDateTime?: string
148
				modifiedDateTime?: string
149
				createdBy?: string
150
				modifiedBy?: string
151
			}
152
			dimensions?: {
153
				location?: { key?: string; id?: string; name?: string; href?: string }
154
				department?: {
155
					key?: string
156
					id?: string
157
					name?: string
158
					href?: string
159
				}
160
				employee?: { key?: string; id?: string; name?: string; href?: string }
161
				project?: { key?: string; id?: string; name?: string; href?: string }
162
				customer?: { key?: string; id?: string; name?: string; href?: string }
163
				vendor?: { key?: string; id?: string; name?: string; href?: string }
164
				item?: { key?: string; id?: string; name?: string; href?: string }
165
				warehouse?: { key?: string; id?: string; name?: string; href?: string }
166
				class?: { key?: string; id?: string; name?: string; href?: string }
167
				task?: { id?: string; key?: string; name?: string; href?: string }
168
				costType?: { id?: string; key?: string; name?: string; href?: string }
169
				asset?: { id?: string; key?: string; name?: string; href?: string }
170
				contract?: { id?: string; key?: string; name?: string; href?: string }
171
				affiliateEntity?: {
172
					key?: string
173
					id?: string
174
					href?: string
175
					name?: string
176
				}
177
			} & {
178
				location?: { key?: string; id?: string; name?: string; href?: string }
179
				department?: {
180
					key?: string
181
					id?: string
182
					name?: string
183
					href?: string
184
				}
185
			}
186
			employeeExpense?: { id?: string; key?: string; href?: string }
187
		}[]
188
		entity?: { key?: string; id?: string; name?: string; href?: string }
189
	} & {}
190
) {
191
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/expenses/employee-expense`)
192

193
	const response = await fetch(url, {
194
		method: 'POST',
195
		headers: {
196
			'Content-Type': 'application/json',
197
			Authorization: 'Bearer ' + auth.token
198
		},
199
		body: JSON.stringify(body)
200
	})
201
	if (!response.ok) {
202
		const text = await response.text()
203
		throw new Error(`${response.status} ${text}`)
204
	}
205
	return await response.json()
206
}
207