1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a contract revenue template |
7 | * Creates a new contract revenue template. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | href?: string |
15 | description?: string |
16 | schedulePeriod?: 'monthly' | 'quarterly' | 'semiAnnually' | 'annually' |
17 | recognitionMethod?: |
18 | | 'straightLine' |
19 | | 'dailyRate' |
20 | | 'quantityBased' |
21 | | 'predefinedPercentages' |
22 | | 'projectPercentComplete' |
23 | | 'taskPercentComplete' |
24 | | 'recognizeRevenueOnInvoice' |
25 | recognitionSource?: |
26 | | 'estimatedHours' |
27 | | 'observedPercentCompleted' |
28 | | 'budgetedHours' |
29 | | 'plannedHours' |
30 | stepRevenue?: false | true |
31 | defaultPostingType?: 'automatic' | 'manual' |
32 | revenueAdjustmentOption?: 'oneTime' | 'distributed' | 'walkForward' |
33 | recognitionPercentages?: { |
34 | monthsOffset?: number |
35 | percentToRecognize?: string |
36 | thresholdPercent?: string |
37 | }[] |
38 | isSystemGenerated?: false | true |
39 | status?: 'active' | 'inactive' |
40 | audit?: { |
41 | createdDateTime?: string |
42 | modifiedDateTime?: string |
43 | createdBy?: string |
44 | modifiedBy?: string |
45 | createdByUser?: { key?: string; id?: string; href?: string } |
46 | modifiedByUser?: { key?: string; id?: string; href?: string } |
47 | } |
48 | } & {} |
49 | ) { |
50 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/revenue-template`) |
51 |
|
52 | const response = await fetch(url, { |
53 | method: 'POST', |
54 | headers: { |
55 | 'Content-Type': 'application/json', |
56 | Authorization: 'Bearer ' + auth.token |
57 | }, |
58 | body: JSON.stringify(body) |
59 | }) |
60 | if (!response.ok) { |
61 | const text = await response.text() |
62 | throw new Error(`${response.status} ${text}`) |
63 | } |
64 | return await response.json() |
65 | } |
66 |
|