0

Create a term

by
Published Oct 17, 2025

Creates a new AR term. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness PermissionsList, View, Add AR terms

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 a term
7
 * Creates a new AR term.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness
14
PermissionsList, View, Add AR terms
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
		status?: 'active' | 'inactive'
27
		description?: string
28
		audit?: {
29
			createdDateTime?: string
30
			modifiedDateTime?: string
31
			createdBy?: string
32
			modifiedBy?: string
33
		}
34
		due?: {
35
			days?: number
36
			from?:
37
				| 'fromInvoiceDate'
38
				| 'ofTheMonthOfInvoiceDate'
39
				| 'ofNextMonthFromInvoiceDate'
40
				| 'of2ndMonthFromInvoiceDate'
41
				| 'of3rdMonthFromInvoiceDate'
42
				| 'of4thMonthFromInvoiceDate'
43
				| 'of5thMonthFromInvoiceDate'
44
				| 'of6thMonthFromInvoiceDate'
45
				| 'afterEndOfMonthOfInvoiceDate'
46
				| 'fromInvoiceDateExtendingToEom'
47
		}
48
		discount?: {
49
			days?: number
50
			amount?: number
51
			from?:
52
				| 'fromInvoiceDate'
53
				| 'ofTheMonthOfInvoiceDate'
54
				| 'ofNextMonthFromInvoiceDate'
55
				| 'of2ndMonthFromInvoiceDate'
56
				| 'of3rdMonthFromInvoiceDate'
57
				| 'of4thMonthFromInvoiceDate'
58
				| 'of5thMonthFromInvoiceDate'
59
				| 'of6thMonthFromInvoiceDate'
60
				| 'afterEndOfMonthOfInvoiceDate'
61
				| 'fromInvoiceDateExtendingToEom'
62
			unit?: 'amount' | 'percentage'
63
			graceDays?: number
64
			value?: string
65
			calculateOn?: 'lineItemsTotal' | 'invoiceTotal'
66
		}
67
		penalty?: {
68
			cycle?:
69
				| 'noPenalty'
70
				| 'daily'
71
				| 'weekly'
72
				| 'biweekly'
73
				| 'monthly'
74
				| 'bimonthly'
75
				| 'quarterly'
76
				| 'halfYearly'
77
				| 'annually'
78
			amount?: number
79
			unit?: 'amount' | 'percentage'
80
			graceDays?: number
81
		}
82
	} & {}
83
) {
84
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/term`)
85

86
	const response = await fetch(url, {
87
		method: 'POST',
88
		headers: {
89
			'Content-Type': 'application/json',
90
			Authorization: 'Bearer ' + auth.token
91
		},
92
		body: JSON.stringify(body)
93
	})
94
	if (!response.ok) {
95
		const text = await response.text()
96
		throw new Error(`${response.status} ${text}`)
97
	}
98
	return await response.json()
99
}
100