1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a change request |
7 | * Creates a new change request. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionConstruction, Project Costing and Billing |
13 | User typeBusiness, Project Manager |
14 | PermissionsList, View, Add Change requests |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | href?: string |
26 | project?: { key?: string; id?: string; name?: string; href?: string } |
27 | projectCustomer?: { |
28 | key?: string |
29 | id?: string |
30 | name?: string |
31 | href?: string |
32 | } |
33 | changeRequestDate?: string |
34 | description?: string |
35 | changeRequestStatus?: { |
36 | key?: string |
37 | id?: string |
38 | workflowType?: |
39 | | 'none' |
40 | | 'original' |
41 | | 'revision' |
42 | | 'forecast' |
43 | | 'approvedChange' |
44 | | 'pendingChange' |
45 | | 'other' |
46 | href?: string |
47 | } |
48 | changeRequestType?: { key?: string; id?: string; href?: string } |
49 | changeRequestState?: 'draft' | 'posted' |
50 | costEffectiveDate?: string |
51 | priceEffectiveDate?: string |
52 | totalCost?: string |
53 | totalPrice?: string |
54 | projectChangeOrder?: { key?: string; id?: string; href?: string } |
55 | projectContractLineSource?: |
56 | | 'none' |
57 | | 'projectChangeOrder' |
58 | | 'changeRequest' |
59 | | 'changeRequestLine' |
60 | projectContract?: { |
61 | key?: string |
62 | id?: string |
63 | name?: string |
64 | href?: string |
65 | } |
66 | projectContractLine?: { |
67 | key?: string |
68 | id?: string |
69 | name?: string |
70 | href?: string |
71 | } |
72 | scope?: string |
73 | inclusions?: string |
74 | exclusions?: string |
75 | terms?: string |
76 | schedule?: { |
77 | scheduledStartDate?: string |
78 | actualStartDate?: string |
79 | scheduledCompletionDate?: string |
80 | revisedCompletionDate?: string |
81 | substantialCompletionDate?: string |
82 | actualCompletionDate?: string |
83 | noticeToProceedDate?: string |
84 | responseDueDate?: string |
85 | executedOnDate?: string |
86 | scheduleImpact?: string |
87 | } |
88 | internalReference?: { |
89 | referenceNumber?: string |
90 | initiatedBy?: { key?: string; id?: string; name?: string; href?: string } |
91 | verbalApprovalBy?: { |
92 | key?: string |
93 | id?: string |
94 | name?: string |
95 | href?: string |
96 | } |
97 | issuedBy?: { key?: string; id?: string; name?: string; href?: string } |
98 | issuedOnDate?: string |
99 | approvedBy?: { key?: string; id?: string; name?: string; href?: string } |
100 | approvedOnDate?: string |
101 | signedBy?: { key?: string; id?: string; name?: string; href?: string } |
102 | signedOnDate?: string |
103 | source?: string |
104 | sourceReferenceNumber?: string |
105 | } |
106 | externalReference?: { |
107 | referenceNumber?: string |
108 | verbalApprovalBy?: { key?: string; id?: string; href?: string } |
109 | approvedBy?: { key?: string; id?: string; href?: string } |
110 | approvedOnDate?: string |
111 | signedBy?: { key?: string; id?: string; href?: string } |
112 | signedOnDate?: string |
113 | } |
114 | location?: { key?: string; id?: string; name?: string; href?: string } |
115 | changeRequestLines?: { |
116 | key?: string |
117 | id?: string |
118 | href?: string |
119 | changeRequest?: { key?: string; id?: string; href?: string } |
120 | workflowType?: |
121 | | 'none' |
122 | | 'original' |
123 | | 'revision' |
124 | | 'forecast' |
125 | | 'approvedChange' |
126 | | 'pendingChange' |
127 | | 'other' |
128 | dimensions?: { |
129 | location?: { key?: string; id?: string; name?: string; href?: string } |
130 | department?: { |
131 | key?: string |
132 | id?: string |
133 | name?: string |
134 | href?: string |
135 | } |
136 | employee?: { key?: string; id?: string; name?: string; href?: string } |
137 | project?: { key?: string; id?: string; name?: string; href?: string } |
138 | customer?: { key?: string; id?: string; name?: string; href?: string } |
139 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
140 | item?: { key?: string; id?: string; name?: string; href?: string } |
141 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
142 | class?: { key?: string; id?: string; name?: string; href?: string } |
143 | task?: { id?: string; key?: string; name?: string; href?: string } |
144 | costType?: { id?: string; key?: string; name?: string; href?: string } |
145 | asset?: { id?: string; key?: string; name?: string; href?: string } |
146 | contract?: { id?: string; key?: string; name?: string; href?: string } |
147 | affiliateEntity?: { |
148 | key?: string |
149 | id?: string |
150 | href?: string |
151 | name?: string |
152 | } |
153 | } & { |
154 | location?: { key?: string; id?: string; name?: string; href?: string } |
155 | department?: { |
156 | key?: string |
157 | id?: string |
158 | name?: string |
159 | href?: string |
160 | } |
161 | } |
162 | numberOfProductionUnits?: string |
163 | productionUnitDescription?: string |
164 | quantity?: string |
165 | externalUOM?: string |
166 | unitCost?: string |
167 | cost?: string |
168 | unitPrice?: string |
169 | price?: string |
170 | priceMarkupPercent?: string |
171 | priceMarkupAmount?: string |
172 | linePrice?: string |
173 | projectChangeOrder?: { key?: string; id?: string; href?: string } |
174 | memo?: string |
175 | projectEstimate?: { key?: string; id?: string; href?: string } |
176 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
177 | projectContract?: { |
178 | key?: string |
179 | id?: string |
180 | name?: string |
181 | href?: string |
182 | } |
183 | projectContractLine?: { |
184 | key?: string |
185 | id?: string |
186 | name?: string |
187 | href?: string |
188 | } |
189 | audit?: { |
190 | createdDateTime?: string |
191 | modifiedDateTime?: string |
192 | createdBy?: string |
193 | modifiedBy?: string |
194 | } |
195 | }[] |
196 | attachment?: { key?: string; id?: string; href?: string } |
197 | audit?: { |
198 | createdDateTime?: string |
199 | modifiedDateTime?: string |
200 | createdBy?: string |
201 | modifiedBy?: string |
202 | } |
203 | entity?: { key?: string; id?: string; name?: string; href?: string } |
204 | } & {} |
205 | ) { |
206 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/change-request`) |
207 |
|
208 | const response = await fetch(url, { |
209 | method: 'POST', |
210 | headers: { |
211 | 'Content-Type': 'application/json', |
212 | Authorization: 'Bearer ' + auth.token |
213 | }, |
214 | body: JSON.stringify(body) |
215 | }) |
216 | if (!response.ok) { |
217 | const text = await response.text() |
218 | throw new Error(`${response.status} ${text}`) |
219 | } |
220 | return await response.json() |
221 | } |
222 |
|