1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a task |
7 | * Creates a new project task. |
8 |
|
9 | `id` is required if document sequencing is not enabled for tasks. If document sequencing is enabled, you can provide an `id` value to use instead of the document sequence value. |
10 |
|
11 |
|
12 | Permissions and other requirements |
13 |
|
14 | SubscriptionProjects |
15 | User typeBusiness, Project Manager |
16 | PermissionsAdd Tasks |
17 |
|
18 |
|
19 |
|
20 |
|
21 | */ |
22 | export async function main( |
23 | auth: SageIntacct, |
24 | body: { |
25 | key?: string |
26 | id?: string |
27 | name?: string |
28 | description?: string |
29 | parent?: { key?: string; id?: string; name?: string; href?: string } |
30 | project?: { |
31 | key?: string |
32 | id?: string |
33 | name?: string |
34 | startDate?: string |
35 | endDate?: string |
36 | href?: string |
37 | } |
38 | customer?: { key?: string; id?: string; name?: string; href?: string } |
39 | item?: { key?: string; id?: string; name?: string; href?: string } |
40 | planned?: { startDate?: string; endDate?: string } |
41 | actual?: { startDate?: string; endDate?: string } |
42 | duration?: { |
43 | planned?: number |
44 | plannedBillable?: number |
45 | estimated?: number |
46 | estimatedBillable?: number |
47 | actual?: number |
48 | actualBillable?: number |
49 | approved?: number |
50 | approvedBillable?: number |
51 | remaining?: number |
52 | } |
53 | percentComplete?: number |
54 | observedPercentComplete?: number |
55 | isMilestone?: false | true |
56 | isUtilized?: false | true |
57 | isBillable?: false | true |
58 | wbsCode?: string |
59 | priority?: number |
60 | taskStatus?: 'notStarted' | 'planned' | 'inProgress' | 'completed' | 'onHold' |
61 | timeType?: { key?: string; id?: string; href?: string } |
62 | class?: { key?: string; id?: string; name?: string; href?: string } |
63 | attachment?: { key?: string; id?: string; href?: string } |
64 | dependentOn?: { key?: string; id?: string; name?: string; href?: string } |
65 | productionUnits?: { estimate?: number; description?: string } |
66 | root?: { id?: string; key?: string; name?: string; href?: string } |
67 | standardTask?: { id?: string; key?: string; name?: string; href?: string } |
68 | href?: string |
69 | audit?: { |
70 | createdDateTime?: string |
71 | modifiedDateTime?: string |
72 | createdBy?: string |
73 | modifiedBy?: string |
74 | } |
75 | } & {} |
76 | ) { |
77 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/projects/task`) |
78 |
|
79 | const response = await fetch(url, { |
80 | method: 'POST', |
81 | headers: { |
82 | 'Content-Type': 'application/json', |
83 | Authorization: 'Bearer ' + auth.token |
84 | }, |
85 | body: JSON.stringify(body) |
86 | }) |
87 | if (!response.ok) { |
88 | const text = await response.text() |
89 | throw new Error(`${response.status} ${text}`) |
90 | } |
91 | return await response.json() |
92 | } |
93 |
|