0

Create a project contract

by
Published Oct 17, 2025

Creates a new project contract. You must specify a unique ID when creating a project contract unless document sequencing is configured, in which case the ID is auto-generated.

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 project contract
7
 * Creates a new project contract. You must specify a unique ID when creating a project contract unless document sequencing is configured, in which case the ID is auto-generated.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		name?: string
16
		project?: { key?: string; id?: string; name?: string; href?: string }
17
		location?: { key?: string; id?: string; name?: string; href?: string }
18
		customer?: { key?: string; id?: string; name?: string; href?: string }
19
		contractDate?: string
20
		description?: string
21
		projectContractType?: { key?: string; id?: string; href?: string }
22
		architect?: { key?: string; id?: string; href?: string }
23
		isBillable?: false | true
24
		attachment?: { key?: string; id?: string; href?: string }
25
		status?: 'active' | 'inactive'
26
		summary?: {
27
			totalPrice?: string
28
			originalPrice?: string
29
			revisionPrice?: string
30
			approvedChangePrice?: string
31
			pendingChangePrice?: string
32
			otherPrice?: string
33
			forecastPrice?: string
34
		}
35
		billing?: {
36
			billedPrice?: string
37
			totalBilledNetRetainage?: string
38
			percentBilled?: string
39
			percentBilledNetRetainage?: string
40
			totalRetainageHeld?: string
41
			totalRetainageReleased?: string
42
			retainageBalance?: string
43
			balanceToBill?: string
44
			balanceToBillNetRetainage?: string
45
			totalPaymentsReceived?: string
46
			netTotalBilled?: string
47
			netTotalPaymentsReceived?: string
48
			subtotalBilledAsTax?: string
49
			subtotalBilledAsDiscount?: string
50
			subtotalBilledAsCharge?: string
51
			lastApplicationNumber?: string
52
		}
53
		excludeFromWIPReporting?: false | true
54
		scope?: string
55
		inclusions?: string
56
		exclusions?: string
57
		terms?: string
58
		schedule?: {
59
			scheduledStartDate?: string
60
			actualStartDate?: string
61
			scheduledCompletionDate?: string
62
			revisedCompletionDate?: string
63
			substantialCompletionDate?: string
64
			actualCompletionDate?: string
65
			noticeToProceedDate?: string
66
			responseDueDate?: string
67
			executedOnDate?: string
68
			scheduleImpact?: string
69
		}
70
		internalReference?: {
71
			referenceNumber?: string
72
			initiatedBy?: { key?: string; id?: string; name?: string; href?: string }
73
			verbalApprovalBy?: {
74
				key?: string
75
				id?: string
76
				name?: string
77
				href?: string
78
			}
79
			issuedBy?: { key?: string; id?: string; name?: string; href?: string }
80
			issuedOnDate?: string
81
			approvedBy?: { key?: string; id?: string; name?: string; href?: string }
82
			approvedOnDate?: string
83
			signedBy?: { key?: string; id?: string; name?: string; href?: string }
84
			signedOnDate?: string
85
			source?: string
86
			sourceReferenceNumber?: string
87
		}
88
		externalReference?: {
89
			referenceNumber?: string
90
			verbalApprovalBy?: { key?: string; id?: string; href?: string }
91
			approvedBy?: { key?: string; id?: string; href?: string }
92
			approvedOnDate?: string
93
			signedBy?: { key?: string; id?: string; href?: string }
94
			signedOnDate?: string
95
		}
96
		audit?: {
97
			createdDateTime?: string
98
			modifiedDateTime?: string
99
			createdBy?: string
100
			modifiedBy?: string
101
		}
102
		entity?: { key?: string; id?: string; name?: string; href?: string }
103
	} & {}
104
) {
105
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/project-contract`)
106

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