1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a contract revenue schedule |
7 | * Updates an existing contract revenue schedule 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 | journal?: 'J1' | 'J2' |
17 | status?: |
18 | | 'draft' |
19 | | 'inProgress' |
20 | | 'onHold' |
21 | | 'completed' |
22 | | 'terminated' |
23 | | 'pendingDelivery' |
24 | | 'pendingDeliveryAll' |
25 | | 'estimateRevalued' |
26 | | 'renewalForecast' |
27 | estimateRevaluationDate?: string |
28 | revenueScheduleLines?: { |
29 | key?: string |
30 | id?: string |
31 | href?: string |
32 | actualPostingDate?: string |
33 | scheduledPostingDate?: string |
34 | derivedPostingDate?: string |
35 | scheduledAmount?: string |
36 | scheduledBaseAmount?: string |
37 | postedBaseAmount?: string |
38 | meaDetails?: string |
39 | adjustedFor?: string |
40 | percentageRecognized?: string |
41 | sourceHours?: string |
42 | approvedHours?: string |
43 | computationMemo?: string |
44 | linkedBillingScheduleLine?: { key?: string; id?: string; href?: string } |
45 | contractRevenueSchedule?: { key?: string; id?: string; href?: string } |
46 | } & { |
47 | key?: string |
48 | id?: string |
49 | scheduledOperationKey?: string |
50 | state?: 'onHold' | 'terminated' | 'open' | 'posted' |
51 | scheduledAmount?: string |
52 | scheduledBaseAmount?: string |
53 | scheduledExchangeRate?: string |
54 | isHistorical?: false | true |
55 | audit?: { |
56 | createdDateTime?: string |
57 | modifiedDateTime?: string |
58 | createdBy?: string |
59 | modifiedBy?: string |
60 | createdByUser?: { key?: string; id?: string; href?: string } |
61 | modifiedByUser?: { key?: string; id?: string; href?: string } |
62 | } |
63 | } & { |
64 | scheduledPostingDate: string |
65 | posted?: false | true |
66 | actualPostingDate?: string |
67 | journalEntry?: { key?: string; id?: string; href?: string } |
68 | }[] |
69 | } |
70 | ) { |
71 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/revenue-schedule/${key}`) |
72 |
|
73 | const response = await fetch(url, { |
74 | method: 'PATCH', |
75 | headers: { |
76 | 'Content-Type': 'application/json', |
77 | Authorization: 'Bearer ' + auth.token |
78 | }, |
79 | body: JSON.stringify(body) |
80 | }) |
81 | if (!response.ok) { |
82 | const text = await response.text() |
83 | throw new Error(`${response.status} ${text}`) |
84 | } |
85 | return await response.json() |
86 | } |
87 |
|