1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a contract expense template |
7 | * Updates an existing contract expense 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 | amortizationSchedulePeriod?: 'monthly' | 'quarterly' | 'semiAnnually' | 'annually' |
18 | postingDay?: number |
19 | amortizationMethod?: 'straightLine' | 'dailyRate' | 'predefinedPercentages' |
20 | defaultPostingType?: 'automatic' | 'manual' |
21 | lines?: { |
22 | key?: string |
23 | id?: string |
24 | href?: string |
25 | periodOffset?: string |
26 | percentToRecognize?: string |
27 | contractExpenseTemplate?: { 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/expense-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 |
|