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