1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a project change order |
7 | * Updates an existing project change order 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 | project?: { key?: string; id?: string; name?: string; href?: string } |
17 | location?: { key?: string; id?: number; name?: string; href?: string } |
18 | projectChangeOrderDate?: string |
19 | state?: 'draft' | 'posted' |
20 | changeRequestStatus?: { key?: string; id?: string; href?: string } |
21 | description?: string |
22 | projectContract?: { |
23 | key?: string |
24 | id?: string |
25 | name?: string |
26 | href?: string |
27 | } |
28 | projectContractLine?: { |
29 | key?: string |
30 | id?: string |
31 | name?: string |
32 | href?: string |
33 | } |
34 | priceEffectiveDate?: string |
35 | totalCost?: string |
36 | totalPrice?: string |
37 | sendToContact?: { key?: string; id?: string; href?: string } |
38 | item?: { key?: string; id?: string; name?: string; href?: string } |
39 | customer?: { key?: string; id?: string; name?: string; href?: string } |
40 | scope?: string |
41 | inclusions?: string |
42 | exclusions?: string |
43 | terms?: string |
44 | schedule?: { |
45 | scheduledStartDate?: string |
46 | actualStartDate?: string |
47 | scheduledCompletionDate?: string |
48 | revisedCompletionDate?: string |
49 | substantialCompletionDate?: string |
50 | actualCompletionDate?: string |
51 | noticeToProceedDate?: string |
52 | responseDueDate?: string |
53 | executedOnDate?: string |
54 | scheduleImpact?: string |
55 | } |
56 | internalReference?: { |
57 | referenceNumber?: string |
58 | initiatedBy?: { key?: string; id?: string; name?: string; href?: string } |
59 | verbalApprovalBy?: { |
60 | key?: string |
61 | id?: string |
62 | name?: string |
63 | href?: string |
64 | } |
65 | issuedBy?: { key?: string; id?: string; name?: string; href?: string } |
66 | issuedOnDate?: string |
67 | approvedBy?: { key?: string; id?: string; name?: string; href?: string } |
68 | approvedOnDate?: string |
69 | signedBy?: { key?: string; id?: string; name?: string; href?: string } |
70 | signedOnDate?: string |
71 | source?: string |
72 | sourceReferenceNumber?: string |
73 | } |
74 | externalReference?: { |
75 | referenceNumber?: string |
76 | verbalApprovalBy?: { key?: string; id?: string; href?: string } |
77 | approvedBy?: { key?: string; id?: string; href?: string } |
78 | approvedOnDate?: string |
79 | signedBy?: { key?: string; id?: string; href?: string } |
80 | signedOnDate?: string |
81 | } |
82 | attachment?: { key?: string; id?: string; href?: string } |
83 | status?: 'active' | 'inactive' |
84 | audit?: { |
85 | createdDateTime?: string |
86 | modifiedDateTime?: string |
87 | createdBy?: string |
88 | modifiedBy?: string |
89 | } |
90 | entity?: { key?: string; id?: string; name?: string; href?: string } |
91 | } & { id?: {} } |
92 | ) { |
93 | const url = new URL( |
94 | `https://api.intacct.com/ia/api/v1/objects/construction/project-change-order/${key}` |
95 | ) |
96 |
|
97 | const response = await fetch(url, { |
98 | method: 'PATCH', |
99 | headers: { |
100 | 'Content-Type': 'application/json', |
101 | Authorization: 'Bearer ' + auth.token |
102 | }, |
103 | body: JSON.stringify(body) |
104 | }) |
105 | if (!response.ok) { |
106 | const text = await response.text() |
107 | throw new Error(`${response.status} ${text}`) |
108 | } |
109 | return await response.json() |
110 | } |
111 |
|