0

Create an electronic receipt

by
Published Oct 17, 2025

Creates a new electronic receipt. Specify a unique electronic receipt ID when creating an electronic receipt unless document sequencing is configured. If document sequencing is configured, then the ID is auto-generated. Permissions and other requirements SubscriptionTime and Expense User typeBusiness, Employee PermissionsList, View, Edit, Delete, Upload, Manage staff electronic receipts

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 electronic receipt
7
 * Creates a new electronic receipt. Specify a unique electronic receipt ID when creating an electronic receipt unless document sequencing is configured. If document sequencing is configured, then the ID is auto-generated.        
8

9

10
Permissions and other requirements
11

12
SubscriptionTime and Expense
13
User typeBusiness, Employee
14
PermissionsList, View, Edit, Delete, Upload, Manage staff electronic receipts
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		href?: string
26
		createdDate?: string
27
		employee?: { key?: string; id?: string; href?: string }
28
		employeeContact?: {
29
			key?: string
30
			id?: string
31
			firstName?: string
32
			lastName?: string
33
			href?: string
34
		}
35
		state?: 'draft' | 'used' | 'review' | 'analyzing'
36
		receiptNumber?: string
37
		description?: string
38
		currency?: string
39
		totalAmount?: string
40
		baseCurrency?: string
41
		baseTotal?: string
42
		attachment?: { key?: string; id?: string; href?: string }
43
		audit?: {
44
			createdDateTime?: string
45
			modifiedDateTime?: string
46
			createdBy?: string
47
			modifiedBy?: string
48
		} & { createdDateTime?: string }
49
		lines?: {
50
			key?: string
51
			id?: string
52
			href?: string
53
			entryDate?: string
54
			currency?: string
55
			txnAmount?: string
56
			baseCurrency?: string
57
			baseAmount?: string
58
			quantity?: string
59
			unitRate?: string
60
			paidTo?: string
61
			paidFor?: string
62
			glAccount?: { key?: string; id?: string; name?: string; href?: string }
63
			expenseType?: { key?: string; id?: string; href?: string }
64
			lineNumber?: number
65
			state?: 'draft' | 'used' | 'review' | 'analyzing'
66
			audit?: {
67
				createdDateTime?: string
68
				modifiedDateTime?: string
69
				createdBy?: string
70
				modifiedBy?: string
71
			}
72
			dimensions?: {
73
				location?: { key?: string; id?: string; name?: string; href?: string }
74
				department?: {
75
					key?: string
76
					id?: string
77
					name?: string
78
					href?: string
79
				}
80
				employee?: { key?: string; id?: string; name?: string; href?: string }
81
				project?: { key?: string; id?: string; name?: string; href?: string }
82
				customer?: { key?: string; id?: string; name?: string; href?: string }
83
				vendor?: { key?: string; id?: string; name?: string; href?: string }
84
				item?: { key?: string; id?: string; name?: string; href?: string }
85
				warehouse?: { key?: string; id?: string; name?: string; href?: string }
86
				class?: { key?: string; id?: string; name?: string; href?: string }
87
				task?: { id?: string; key?: string; name?: string; href?: string }
88
				costType?: { id?: string; key?: string; name?: string; href?: string }
89
				asset?: { id?: string; key?: string; name?: string; href?: string }
90
				contract?: { id?: string; key?: string; name?: string; href?: string }
91
				affiliateEntity?: {
92
					key?: string
93
					id?: string
94
					href?: string
95
					name?: string
96
				}
97
			} & {
98
				location?: { key?: string; id?: string; name?: string; href?: string }
99
				department?: {
100
					key?: string
101
					id?: string
102
					name?: string
103
					href?: string
104
				}
105
			}
106
			electronicReceipt?: { id?: string; key?: string; href?: string }
107
		}[]
108
	} & {}
109
) {
110
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/expenses/electronic-receipt`)
111

112
	const response = await fetch(url, {
113
		method: 'POST',
114
		headers: {
115
			'Content-Type': 'application/json',
116
			Authorization: 'Bearer ' + auth.token
117
		},
118
		body: JSON.stringify(body)
119
	})
120
	if (!response.ok) {
121
		const text = await response.text()
122
		throw new Error(`${response.status} ${text}`)
123
	}
124
	return await response.json()
125
}
126