1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a revenue recognition template |
7 | * Creates a new revenue recognition 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 | useStandard?: false | true |
17 | schedulePeriod?: 'daily' | 'monthly' | 'quarterly' | 'semiAnnually' | 'annually' |
18 | postingDay?: |
19 | | 'daily' |
20 | | '1' |
21 | | '2' |
22 | | '3' |
23 | | '4' |
24 | | '5' |
25 | | '6' |
26 | | '7' |
27 | | '8' |
28 | | '9' |
29 | | '10' |
30 | | '11' |
31 | | '12' |
32 | | '13' |
33 | | '14' |
34 | | '15' |
35 | | '16' |
36 | | '17' |
37 | | '18' |
38 | | '19' |
39 | | '20' |
40 | | '21' |
41 | | '22' |
42 | | '23' |
43 | | '24' |
44 | | '25' |
45 | | '26' |
46 | | '27' |
47 | | '28' |
48 | | '29' |
49 | | '30' |
50 | | '31' |
51 | | 'endOfPeriod' |
52 | recognitionTerm?: 'fixedPeriod' | 'contractTerm' | 'project' |
53 | resumeOption?: 'catchUp' | 'walkforward' |
54 | totalPeriods?: string |
55 | recognitionMethod?: |
56 | | 'straightLine' |
57 | | 'straightLine,prorateExactDays' |
58 | | 'straightLine,percentAllocation' |
59 | | 'straightLine,percentAllocation,endOfPeriod' |
60 | | 'exactDaysPerPeriod,prorateDays' |
61 | | 'exactDaysPerPeriod,prorateDays,endOfPeriod' |
62 | | 'percentCompleted' |
63 | | 'milestone' |
64 | | 'custom' |
65 | recognitionStartDate?: 'transactionDate' | 'userSpecified' |
66 | postingMethod?: 'automatic' | 'manual' |
67 | latestVersion?: string |
68 | milestoneSource?: 'project' | 'manual' |
69 | calculation?: { |
70 | source?: 'project' | 'task' |
71 | basedOn?: |
72 | | 'estimatedHours' |
73 | | 'plannedHours' |
74 | | 'budgetedHours' |
75 | | 'budgetedCostFromGL' |
76 | | 'budgetedCostFromSummary' |
77 | | 'observed%Completed' |
78 | } |
79 | status?: 'active' | 'inactive' |
80 | entity?: { key?: string; id?: string; name?: string; href?: string } |
81 | audit?: { |
82 | createdDateTime?: string |
83 | modifiedDateTime?: string |
84 | createdBy?: string |
85 | modifiedBy?: string |
86 | } |
87 | } & {} |
88 | ) { |
89 | const url = new URL( |
90 | `https://api.intacct.com/ia/api/v1/objects/accounts-receivable/revenue-recognition-template` |
91 | ) |
92 |
|
93 | const response = await fetch(url, { |
94 | method: 'POST', |
95 | headers: { |
96 | 'Content-Type': 'application/json', |
97 | Authorization: 'Bearer ' + auth.token |
98 | }, |
99 | body: JSON.stringify(body) |
100 | }) |
101 | if (!response.ok) { |
102 | const text = await response.text() |
103 | throw new Error(`${response.status} ${text}`) |
104 | } |
105 | return await response.json() |
106 | } |
107 |
|