1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a renewal template |
7 | * Updates an existing order entry renewal template 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 | name?: string |
16 | href?: string |
17 | description?: string |
18 | salesTxnCreation?: { |
19 | enableTxnCreation?: false | true |
20 | transactionDefinition?: { key?: string; id?: string; href?: string } |
21 | daysBeforeAfter?: number |
22 | beforeOrAfterContractEnd?: 'before' | 'after' |
23 | txnDateOnRenewedDocument?: 'calculatedDate' | 'contractEndDatePlusOneDay' |
24 | txnLineItemStartDate?: 'sameAsDocumentDate' | 'withInheritedOffsetFromParent' |
25 | } |
26 | contractPricing?: { |
27 | pricingType?: 'sameAsOriginal' | 'defaultPricing' | 'markupOrMarkdown' |
28 | markup?: 'percentageMarkup' | 'percentageDiscount' | 'actualMarkup' | 'actualDiscount' |
29 | markupValue?: string |
30 | } |
31 | renewalNotifications?: { |
32 | customerEmail?: { |
33 | enableNotification?: false | true |
34 | from?: string |
35 | to?: 'customerContact' | 'customerBillToContact' | 'customerShipToContact' |
36 | daysBeforeAfter?: number |
37 | beforeOrAfterContractRenewal?: 'before' | 'after' |
38 | emailTemplate?: { key?: string; id?: string; href?: string } |
39 | } |
40 | internalEmail?: { |
41 | enableNotification?: false | true |
42 | from?: string |
43 | to?: string |
44 | beforeOrAfterContractRenewal?: 'before' | 'after' |
45 | daysBeforeAfter?: number |
46 | emailTemplate?: { key?: string; id?: string; href?: string } |
47 | } |
48 | } |
49 | salesforceOpportunity?: { |
50 | enableSalesforceOpportunity?: false | true |
51 | beforeOrAfterContractRenewal?: 'before' | 'after' |
52 | daysBeforeAfter?: string |
53 | renewalName?: string |
54 | inheritProductsFromParent?: false | true |
55 | stage?: |
56 | | 'prospecting' |
57 | | 'qualification' |
58 | | 'needsAnalysis' |
59 | | 'valueProposition' |
60 | | 'idDecisionMakers' |
61 | | 'proposalPriceQuote' |
62 | | 'negotiationReview' |
63 | | 'closedWon' |
64 | | 'closedLost' |
65 | } |
66 | latestVersion?: string |
67 | transactionType?: 'salesTransaction' | 'contract' | 'evergreen' |
68 | renewalState?: 'inProgress' | 'draft' |
69 | defaultTerm?: { period?: 'years' | 'months' | 'days'; length?: string } |
70 | status?: 'active' | 'inactive' |
71 | entity?: { key?: string; id?: string; name?: string; href?: string } |
72 | } & { id?: {} } |
73 | ) { |
74 | const url = new URL( |
75 | `https://api.intacct.com/ia/api/v1/objects/order-entry/renewal-template/${key}` |
76 | ) |
77 |
|
78 | const response = await fetch(url, { |
79 | method: 'PATCH', |
80 | headers: { |
81 | 'Content-Type': 'application/json', |
82 | Authorization: 'Bearer ' + auth.token |
83 | }, |
84 | body: JSON.stringify(body) |
85 | }) |
86 | if (!response.ok) { |
87 | const text = await response.text() |
88 | throw new Error(`${response.status} ${text}`) |
89 | } |
90 | return await response.json() |
91 | } |
92 |
|