0

Update a transaction definition

by
Published Oct 17, 2025

Updates an existing purchasing transaction definition by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionPurchasing User typeBusiness, Employee, Project Manager, Warehouse PermissionsList, View, Edit Purchasing transactions

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 a transaction definition
7
 * Updates an existing purchasing transaction definition by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionPurchasing
13
User typeBusiness, Employee, Project Manager, Warehouse
14
PermissionsList, View, Edit Purchasing transactions
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
		href?: string
27
		docClass?: 'quote' | 'order' | 'list' | 'invoice' | 'adjustment' | 'other'
28
		workflowCategory?: 'quote' | 'order' | 'invoice' | 'shipping' | 'return'
29
		disableTax?: false | true
30
		enableUserOrGroupPermmission?: false | true
31
		enableOverrideTax?: false | true
32
		enableNumberingSequence?: false | true
33
		preserveNumberingSequence?: false | true
34
		inheritDocumentNumber?: false | true
35
		xslTemplate?: string
36
		description?: string
37
		inventoryUpdateType?: 'no' | 'quantity' | 'value' | 'quantityAndValue'
38
		txnPostingMethod?: 'toAP' | 'toGL' | 'noPosting'
39
		partialConvertMethod?:
40
			| 'leaveTransactionOpen'
41
			| 'closeOriginalAndCreateBackOrder'
42
			| 'closeTransaction'
43
		affectsCost?: false | true
44
		exchangeRateType?: { key?: string; id?: string; href?: string }
45
		overrideExchangeRateType?: false | true
46
		showBaseCurrency?: false | true
47
		enableCreditLimitCheck?: false | true
48
		freezeRecallValue?: false | true
49
		overridePrice?: false | true
50
		enableSubtotals?: false | true
51
		showExpandedTaxDetails?: false | true
52
		allowDepartmentOverride?: false | true
53
		allowLocationOverride?: false | true
54
		requireSupplyOfPrices?: false | true
55
		fixedMessage?: string
56
		editPolicy?: 'noEdit' | 'beforePrinting' | 'editInDraftOnly' | 'all'
57
		deletePolicy?: 'beforePrinting' | 'all' | 'noDelete'
58
		customerVendorEditRule?: 'always' | 'exceptConvertedDocuments' | 'never'
59
		printPayToContact?: false | true
60
		printReturnToContact?: false | true
61
		printDeliverToContact?: false | true
62
		allowEditingPayToContact?: false | true
63
		allowEditingReturnToContact?: false | true
64
		allowEditingDeliverToContact?: false | true
65
		contactOneTitle?: string
66
		contactTwoTitle?: string
67
		contactThreeTitle?: string
68
		enableWarnOnLowQuantity?: false | true
69
		warehouseSelectionMethod?:
70
			| 'sortByID'
71
			| 'sortByName'
72
			| 'warehouseWithAvailableInventory'
73
			| 'useTheDefaultWarehouse'
74
		postToGL?: false | true
75
		enableAllocations?: false | true
76
		documentConversionPolicy?: 'newDocumentOnly' | 'newDocumentOrConvert' | 'convertOnly'
77
		multiEntityRuleForTransaction?: 'topLevelOrEntity' | 'topLevelOnly' | 'entityOnly'
78
		subtotalTemplate?: { key?: string; id?: string; href?: string }
79
		lineLevelSimpleTax?: false | true
80
		enableRetainage?: false | true
81
		enableAdditionalInformationScope?: false | true
82
		enableAdditionalInformationSchedule?: false | true
83
		enableInternalReference?: false | true
84
		enableExternalReference?: false | true
85
		enableBond?: false | true
86
		documentChangeType?: 'noChange' | 'enableChange' | 'changeOrder'
87
		enablePrimaryDocumentWorkflow?: false | true
88
		increaseOrDecreaseInventory?: 'increase' | 'decrease'
89
		reportingCategory?:
90
			| 'bidsAndQuotes'
91
			| 'purchaseOrders'
92
			| 'purchaseOrderChangeOrders'
93
			| 'purchaseReceivers'
94
			| 'purchaseOrderInvoices'
95
			| 'purchaseReturns'
96
			| 'purchaseCredits'
97
			| 'purchaseDebits'
98
			| 'purchaseClearingReceivers'
99
			| 'subcontractBids'
100
			| 'subcontracts'
101
			| 'subcontractChangeOrders'
102
			| 'subcontractInvoices'
103
			| 'internalSupplyRequisitions'
104
			| 'purchaseRequisitions'
105
			| 'blanketPurchaseOrdersOrVendorContracts'
106
			| 'grantRequests'
107
			| 'grantAwards'
108
		initialPriceList?: { key?: string; id?: string; href?: string }
109
		documentSequence?: { key?: string; id?: string; href?: string }
110
		specialPriceList?: { key?: string; id?: string; href?: string }
111
		updatePriceList?: { key?: string; id?: string; href?: string }
112
		apTerm?: { key?: string; id?: string; href?: string }
113
		warehouse?: { key?: string; id?: string; href?: string }
114
		status?: 'active' | 'inactive'
115
		entity?: { key?: string; id?: string; name?: string; href?: string }
116
		audit?: {
117
			createdDateTime?: string
118
			modifiedDateTime?: string
119
			createdBy?: string
120
			modifiedBy?: string
121
		}
122
		additionalGLDetail?: {
123
			key?: string
124
			id?: string
125
			href?: string
126
			isOffset?: false | true
127
			txnType?: 'debit' | 'credit'
128
			moduleType?: 'subledger' | 'inventory' | 'additional'
129
			lineNumber?: number
130
			glAccount?: { key?: string; id?: string; href?: string }
131
			location?: { href?: string; key?: string; id?: string }
132
			department?: { href?: string; key?: string; id?: string }
133
			itemGLGroup?: { key?: string; id?: string; href?: string }
134
			warehouse?: { key?: string; id?: string; href?: string }
135
			status?: 'active' | 'inactive'
136
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
137
		}[]
138
		accountPayableOrDirectGLDetail?: {
139
			key?: string
140
			id?: string
141
			href?: string
142
			isOffset?: false | true
143
			txnType?: 'debit' | 'credit'
144
			moduleType?: 'subledger' | 'inventory' | 'additional'
145
			lineNumber?: number
146
			glAccount?: { key?: string; id?: string; href?: string }
147
			location?: { href?: string; key?: string; id?: string }
148
			department?: { href?: string; key?: string; id?: string }
149
			itemGLGroup?: { href?: string; key?: string; id?: string }
150
			warehouse?: { href?: string; key?: string; id?: string }
151
			status?: 'active' | 'inactive'
152
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
153
		}[]
154
		inventoryTotalDetail?: {
155
			key?: string
156
			id?: string
157
			href?: string
158
			maintainType?: 'quantity' | 'value' | 'quantityAndValue'
159
			operation?: 'add' | 'subtract'
160
			inventoryTotal?: { key?: string; id?: string; href?: string }
161
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
162
		}[]
163
		subtotalDetail?: {
164
			key?: string
165
			id?: string
166
			href?: string
167
			subtotalType?: 'discount' | 'charge'
168
			lineNumber?: number
169
			description?: string
170
			valueType?: 'amount' | 'percent'
171
			subtotalValue?: string
172
			isApportioned?: false | true
173
			glAccount?: { key?: string; id?: string; href?: string }
174
			offsetGLAccount?: { key?: string; id?: string; href?: string }
175
			txnType?: 'debit' | 'credit'
176
			appliedToLineNumber?: number
177
			isTax?: false | true
178
			department?: { href?: string; key?: string; id?: string }
179
			location?: { key?: string; id?: string; href?: string }
180
			enableAvalaraTax?: false | true
181
			entity?: { href?: string; key?: string; id?: string }
182
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
183
		}[]
184
		sourceDocumentDetail?: {
185
			key?: string
186
			id?: string
187
			href?: string
188
			sourceDocument?: { href?: string; key?: string; id?: string }
189
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
190
		}[]
191
		entitySettingDetail?: {
192
			key?: string
193
			id?: string
194
			href?: string
195
			enableNumberingSequence?: false | true
196
			preserveNumberingSequence?: false | true
197
			canInheritSourceDocumentNumber?: false | true
198
			documentTemplate?: { key?: string; id?: string }
199
			subtotalTemplate?: { href?: string; key?: string; id?: string }
200
			showExpandedTaxDetail?: false | true
201
			enableOverrideTax?: false | true
202
			enableLineLevelSimpleTax?: false | true
203
			entity?: { href?: string; key?: string; id?: string }
204
			documentSequence?: { key?: string; href?: string; id?: string }
205
			audit?: {
206
				createdDateTime?: string
207
				modifiedDateTime?: string
208
				createdBy?: string
209
				modifiedBy?: string
210
			}
211
			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
212
		}[]
213
	} & { id?: {} }
214
) {
215
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/purchasing/txn-definition/${key}`)
216

217
	const response = await fetch(url, {
218
		method: 'PATCH',
219
		headers: {
220
			'Content-Type': 'application/json',
221
			Authorization: 'Bearer ' + auth.token
222
		},
223
		body: JSON.stringify(body)
224
	})
225
	if (!response.ok) {
226
		const text = await response.text()
227
		throw new Error(`${response.status} ${text}`)
228
	}
229
	return await response.json()
230
}
231