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