0

Update a MEA price list entry

by
Published Oct 17, 2025

Updates an existing MEA price list entry by setting field values. Any fields not provided remain unchanged.

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 MEA price list entry
7
 * Updates an existing MEA price list entry by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		href?: string
16
		meaPriceList?: { key?: string; id?: string; href?: string }
17
		fairValueCategory?: { key?: string; id?: string; href?: string }
18
		item?: { key?: string; id?: string; name?: string; href?: string }
19
		currency?: {
20
			exchangeRateDate?: string
21
			exchangeRateTypeId?: string
22
			exchangeRate?: number
23
			baseCurrency?: string
24
			txnCurrency?: string
25
		}
26
		priceType?: 'amount' | 'percent' | 'priceRange' | 'noFairValue'
27
		calculatePercentageBasedOn?: 'extendedFairValuePrice' | 'extendedContractLinePrice'
28
		usePriceRange?: false | true
29
		priceRangeVarianceType?: 'amount' | 'percent'
30
		priceRuleOutsideRange?: 'fairValue' | 'nearestBoundary'
31
		lines?: {
32
			key?: string
33
			id?: string
34
			href?: string
35
			meaPriceListEntry?: { key?: string; id?: string; href?: string }
36
			startDate?: string
37
			amountOrPercent?: string
38
			markDown?: string
39
			markUp?: string
40
			lowerLimit?: string
41
			upperLimit?: string
42
			memo?: string
43
			audit?: {
44
				createdDateTime?: string
45
				modifiedDateTime?: string
46
				createdBy?: string
47
				modifiedBy?: string
48
				createdByUser?: { key?: string; id?: string; href?: string }
49
				modifiedByUser?: { key?: string; id?: string; href?: string }
50
			}
51
		}[]
52
		audit?: {
53
			createdDateTime?: string
54
			modifiedDateTime?: string
55
			createdBy?: string
56
			modifiedBy?: string
57
			createdByUser?: { key?: string; id?: string; href?: string }
58
			modifiedByUser?: { key?: string; id?: string; href?: string }
59
		}
60
		status?: 'active' | 'inactive'
61
	}
62
) {
63
	const url = new URL(
64
		`https://api.intacct.com/ia/api/v1/objects/contracts/mea-price-list-entry/${key}`
65
	)
66

67
	const response = await fetch(url, {
68
		method: 'PATCH',
69
		headers: {
70
			'Content-Type': 'application/json',
71
			Authorization: 'Bearer ' + auth.token
72
		},
73
		body: JSON.stringify(body)
74
	})
75
	if (!response.ok) {
76
		const text = await response.text()
77
		throw new Error(`${response.status} ${text}`)
78
	}
79
	return await response.json()
80
}
81