1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a WIP period |
7 | * Creates a new WIP period. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionConstruction |
13 | User typeBusiness, Project Manager |
14 | PermissionsAdd WIP Periods |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | periodName?: string |
26 | periodStartDate?: string |
27 | periodEndDate?: string |
28 | fiscalYear?: string |
29 | state?: 'unposted' | 'posted' |
30 | notes?: string |
31 | isHistoricalImport?: false | true |
32 | lastRefreshDateTime?: string |
33 | createdFromEntity?: { |
34 | key?: string |
35 | id?: string |
36 | name?: string |
37 | href?: string |
38 | } |
39 | assignedEntity?: { |
40 | key?: string |
41 | id?: string |
42 | name?: string |
43 | href?: string |
44 | } |
45 | endOfPriorYearPeriod?: { |
46 | key?: string |
47 | id?: string |
48 | periodName?: string |
49 | href?: string |
50 | } |
51 | audit?: { |
52 | createdDateTime?: string |
53 | modifiedDateTime?: string |
54 | createdBy?: string |
55 | modifiedBy?: string |
56 | } |
57 | wipProjects?: { |
58 | key?: string |
59 | id?: string |
60 | isFinalized?: false | true |
61 | glPostedDate?: string |
62 | estimatedCostToDateAmount?: string |
63 | jobToDateCosts?: string |
64 | estimatedCostToComplete?: string |
65 | estimatedCostAtCompletion?: string |
66 | pendingEstimatesAmount?: string |
67 | estimatedPercentComplete?: string |
68 | projectManagerForecast?: { |
69 | costToComplete?: string |
70 | costAtCompletion?: string |
71 | percentComplete?: string |
72 | contractValue?: string |
73 | lastUpdatedDate?: string |
74 | } |
75 | cfoForecast?: { |
76 | costToComplete?: string |
77 | costAtCompletion?: string |
78 | percentComplete?: string |
79 | contractValue?: string |
80 | lastUpdatedDate?: string |
81 | } |
82 | costAtCompletionVariance?: string |
83 | totalContractValue?: string |
84 | contractVarianceAmount?: string |
85 | jobToDateBillings?: string |
86 | earnedToDateAmount?: string |
87 | remainingBacklogAmount?: string |
88 | overUnderBillingAmount?: string |
89 | earnedProfitToDateAmount?: string |
90 | grossProfitPercentOfContract?: string |
91 | grossProfitPercentOfCost?: string |
92 | totalGrossProfitEstimatedAtCompletion?: string |
93 | cfoForecastGrossProfitAtCompletion?: string |
94 | grossProfitVarianceAmount?: string |
95 | cfoForecastGrossProfitMarginPercent?: string |
96 | priorYearsProfit?: string |
97 | endOfPriorYearEarnedToDateAmount?: string |
98 | endOfPriorYearEarnedProfit?: string |
99 | remainingProfit?: string |
100 | yearToDateCostAmount?: string |
101 | yearToDateBillingAmount?: string |
102 | yearToDateEarnedRevenueAmount?: string |
103 | jobToDateOverBillingAmount?: string |
104 | jobToDateUnderBillingAmount?: string |
105 | yearToDateEarnedProfitAmount?: string |
106 | currentPeriodBillingAmount?: string |
107 | currentPeriodCostAmount?: string |
108 | currentPeriodEarnedProfitAmount?: string |
109 | currentPeriodEarnedRevenueAmount?: string |
110 | notes?: string |
111 | forecastDetails?: { |
112 | key?: string |
113 | id?: string |
114 | wipPeriod?: { |
115 | key?: string |
116 | id?: string |
117 | periodName?: string |
118 | href?: string |
119 | } |
120 | assignedEntity?: { |
121 | key?: string |
122 | id?: string |
123 | name?: string |
124 | href?: string |
125 | } |
126 | wipProject?: { key?: string; id?: string; href?: string } |
127 | project?: { key?: string; id?: string; name?: string; href?: string } |
128 | costType?: { id?: string; key?: string; name?: string; href?: string } |
129 | task?: { id?: string; key?: string; name?: string; href?: string } |
130 | groupTask?: { id?: string; key?: string; name?: string; href?: string } |
131 | costAndEstimateDetail?: { |
132 | key?: string |
133 | jobToDateCosts?: string |
134 | estimatedCostToDateAmount?: string |
135 | estimatedCostAtCompletion?: string |
136 | pendingEstimatesAmount?: string |
137 | estimatedCostToComplete?: string |
138 | estimatedPercentComplete?: string |
139 | estimateVsForecastVariance?: string |
140 | href?: string |
141 | } |
142 | projectManagerForecast?: { |
143 | key?: string |
144 | costToComplete?: string |
145 | costAtCompletion?: string |
146 | percentComplete?: string |
147 | notes?: string |
148 | pmUserUpdatedDate?: string |
149 | costToCompleteVariance?: string |
150 | costAtCompletionVariance?: string |
151 | href?: string |
152 | } |
153 | priorPeriodProjectManagerForecast?: { |
154 | costToComplete?: string |
155 | costAtCompletion?: string |
156 | percentComplete?: string |
157 | } |
158 | href?: string |
159 | }[] |
160 | href?: string |
161 | audit?: { |
162 | createdDateTime?: string |
163 | modifiedDateTime?: string |
164 | createdBy?: string |
165 | modifiedBy?: string |
166 | } |
167 | project?: { |
168 | key?: string |
169 | id?: string |
170 | name?: string |
171 | description?: string |
172 | status?: 'active' | 'inactive' |
173 | startDate?: string |
174 | endDate?: string |
175 | href?: string |
176 | } |
177 | customer?: { key?: string; id?: string; name?: string; href?: string } |
178 | projectType?: { key?: string; id?: string; href?: string } |
179 | projectStatus?: { key?: string; id?: string; href?: string } |
180 | location?: { key?: string; id?: string; name?: string; href?: string } |
181 | class?: { key?: string; id?: string; name?: string; href?: string } |
182 | department?: { key?: string; id?: string; name?: string; href?: string } |
183 | manager?: { key?: string; id?: string; name?: string; href?: string } |
184 | wipPeriod?: { |
185 | key?: string |
186 | id?: string |
187 | periodName?: string |
188 | href?: string |
189 | } |
190 | }[] |
191 | href?: string |
192 | } & {} |
193 | ) { |
194 | const url = new URL( |
195 | `https://api.intacct.com/ia/api/v1/objects/construction-forecasting/wip-period` |
196 | ) |
197 |
|
198 | const response = await fetch(url, { |
199 | method: 'POST', |
200 | headers: { |
201 | 'Content-Type': 'application/json', |
202 | Authorization: 'Bearer ' + auth.token |
203 | }, |
204 | body: JSON.stringify(body) |
205 | }) |
206 | if (!response.ok) { |
207 | const text = await response.text() |
208 | throw new Error(`${response.status} ${text}`) |
209 | } |
210 | return await response.json() |
211 | } |
212 |
|