1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a billing template |
7 | * Updates an existing billing template 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 | description?: string |
17 | method?: 'predefinedPercentages' | 'projectPercentComplete' | 'taskPercentComplete' |
18 | source?: 'estimatedHours' | 'observedPercentCompleted' | 'budgetedHours' | 'plannedHours' |
19 | isStepBilling?: false | true |
20 | lines?: { |
21 | key?: string |
22 | id?: string |
23 | href?: string |
24 | periodOffset?: string |
25 | percentToBill?: string |
26 | stepPercent?: string |
27 | contractBillingTemplate?: { key?: string; id?: string; href?: string } |
28 | status?: 'active' | 'inactive' |
29 | audit?: { |
30 | createdDateTime?: string |
31 | modifiedDateTime?: string |
32 | createdBy?: string |
33 | modifiedBy?: string |
34 | createdByUser?: { key?: string; id?: string; href?: string } |
35 | modifiedByUser?: { key?: string; id?: string; href?: string } |
36 | } |
37 | }[] |
38 | status?: 'active' | 'inactive' |
39 | audit?: { |
40 | createdDateTime?: string |
41 | modifiedDateTime?: string |
42 | createdBy?: string |
43 | modifiedBy?: string |
44 | createdByUser?: { key?: string; id?: string; href?: string } |
45 | modifiedByUser?: { key?: string; id?: string; href?: string } |
46 | } |
47 | } & { id?: {} } |
48 | ) { |
49 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/billing-template/${key}`) |
50 |
|
51 | const response = await fetch(url, { |
52 | method: 'PATCH', |
53 | headers: { |
54 | 'Content-Type': 'application/json', |
55 | Authorization: 'Bearer ' + auth.token |
56 | }, |
57 | body: JSON.stringify(body) |
58 | }) |
59 | if (!response.ok) { |
60 | const text = await response.text() |
61 | throw new Error(`${response.status} ${text}`) |
62 | } |
63 | return await response.json() |
64 | } |
65 |
|