1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a billing price list entry |
7 | * Updates an existing billing 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 | billingPriceList?: { key?: string; id?: string; href?: string } |
17 | currency?: { |
18 | exchangeRateDate?: string |
19 | exchangeRateTypeId?: string |
20 | exchangeRate?: number |
21 | baseCurrency?: string |
22 | txnCurrency?: string |
23 | } |
24 | priceType?: 'range' | 'tiered' |
25 | flatAmountFrequency?: 'oneTime' | 'useBillingTemplate' | 'includeWithEveryInvoice' |
26 | usageQuantityResetPeriod?: 'afterEachRenewal' | 'afterEachInvoice' |
27 | roundingType?: 'standard' | 'roundUp' | 'roundDown' |
28 | isQuantityRecurring?: false | true |
29 | variableUnitDivisor?: string |
30 | tieredPricingType?: 'volume' | 'step' | 'absolute' |
31 | item?: { key?: string; id?: string; name?: string; href?: string } |
32 | lines?: { |
33 | key?: string |
34 | id?: string |
35 | href?: string |
36 | startDate?: string |
37 | flatAmount?: string |
38 | variableUnitRate?: string |
39 | includedUnits?: string |
40 | memo?: string |
41 | billingPriceListEntry?: { key?: string; id?: string; href?: string } |
42 | tiers?: { |
43 | key?: string |
44 | id?: string |
45 | href?: string |
46 | beginQuantity?: string |
47 | tierRate?: string |
48 | billingPriceListEntryLine?: { |
49 | key?: string |
50 | id?: string |
51 | href?: string |
52 | } |
53 | audit?: { |
54 | createdDateTime?: string |
55 | modifiedDateTime?: string |
56 | createdBy?: string |
57 | modifiedBy?: string |
58 | createdByUser?: { key?: string; id?: string; href?: string } |
59 | modifiedByUser?: { key?: string; id?: string; href?: string } |
60 | } |
61 | }[] |
62 | audit?: { |
63 | createdDateTime?: string |
64 | modifiedDateTime?: string |
65 | createdBy?: string |
66 | modifiedBy?: string |
67 | createdByUser?: { key?: string; id?: string; href?: string } |
68 | modifiedByUser?: { key?: string; id?: string; href?: string } |
69 | } |
70 | }[] |
71 | audit?: { |
72 | createdDateTime?: string |
73 | modifiedDateTime?: string |
74 | createdBy?: string |
75 | modifiedBy?: string |
76 | createdByUser?: { key?: string; id?: string; href?: string } |
77 | modifiedByUser?: { key?: string; id?: string; href?: string } |
78 | } |
79 | status?: 'active' | 'inactive' |
80 | } |
81 | ) { |
82 | const url = new URL( |
83 | `https://api.intacct.com/ia/api/v1/objects/contracts/billing-price-list-entry/${key}` |
84 | ) |
85 |
|
86 | const response = await fetch(url, { |
87 | method: 'PATCH', |
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 |
|