1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a contract billing schedule |
7 | * Updates an existing contract billing 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 | status?: 'draft' | 'inProgress' | 'onHold' | 'completed' | 'terminated' | 'estimateRevalued' |
17 | lines?: { |
18 | key?: string |
19 | id?: string |
20 | href?: string |
21 | scheduledBillingDate?: string |
22 | billed?: false | true |
23 | actualBillingDate?: string |
24 | actualBaseAmount?: string |
25 | actualExchangeRate?: string |
26 | sourceHours?: string |
27 | approvedHours?: string |
28 | documentId?: string |
29 | computationMemo?: string |
30 | servicePeriodStartDate?: string |
31 | servicePeriodEndDate?: string |
32 | linkedBillingScheduleLine?: { key?: string; id?: string; href?: string } |
33 | contractBillingSchedule?: { key?: string; id?: string; href?: string } |
34 | contractUsage?: { key?: string; id?: string; href?: string } |
35 | } & { |
36 | key?: string |
37 | id?: string |
38 | scheduledOperationKey?: string |
39 | state?: 'onHold' | 'terminated' | 'open' | 'posted' |
40 | scheduledAmount?: string |
41 | scheduledBaseAmount?: string |
42 | scheduledExchangeRate?: string |
43 | isHistorical?: false | true |
44 | audit?: { |
45 | createdDateTime?: string |
46 | modifiedDateTime?: string |
47 | createdBy?: string |
48 | modifiedBy?: string |
49 | createdByUser?: { key?: string; id?: string; href?: string } |
50 | modifiedByUser?: { key?: string; id?: string; href?: string } |
51 | } |
52 | }[] |
53 | estimateRevaluationDate?: string |
54 | } |
55 | ) { |
56 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/billing-schedule/${key}`) |
57 |
|
58 | const response = await fetch(url, { |
59 | method: 'PATCH', |
60 | headers: { |
61 | 'Content-Type': 'application/json', |
62 | Authorization: 'Bearer ' + auth.token |
63 | }, |
64 | body: JSON.stringify(body) |
65 | }) |
66 | if (!response.ok) { |
67 | const text = await response.text() |
68 | throw new Error(`${response.status} ${text}`) |
69 | } |
70 | return await response.json() |
71 | } |
72 |
|