@@ -39,17 +39,15 @@ const { getBrowserContext, closeBrowser } = require('../util/browser');
39
39
const { ChangeRequestMappings, ChangeActionRequestMappings, NewFacilityMappings, MtfiMappings } = require ( '../util/mapping/ChangeRequestMappings' ) ;
40
40
41
41
async function renewCCOFApplication ( req , res ) {
42
- log . info ( 'renew CCOF application called' ) ;
43
42
try {
44
43
const application = req . body ;
45
- let payload = {
44
+ const payload = {
46
45
ccof_providertype : application . providerType == 'GROUP' ? ORGANIZATION_PROVIDER_TYPES . GROUP : ORGANIZATION_PROVIDER_TYPES . FAMILY ,
47
46
ccof_applicationtype : CCOF_APPLICATION_TYPES . RENEW ,
48
47
'ccof_ProgramYear@odata.bind' : `/ccof_program_years(${ application . programYearId } )` ,
49
48
'ccof_Organization@odata.bind' : `/ccof_program_years(${ application . organizationId } )` ,
50
49
} ;
51
- log . info ( 'Payload for renew is: ' , payload . toJSON ) ;
52
- let applicationGuid = await postOperation ( 'ccof_applications' , payload ) ;
50
+ const applicationGuid = await postOperation ( 'ccof_applications' , payload ) ;
53
51
//After the application is created, get the application guid
54
52
return res . status ( HttpStatus . CREATED ) . json ( { applicationId : applicationGuid } ) ;
55
53
} catch ( e ) {
@@ -74,7 +72,6 @@ async function patchCCFRIApplication(req, res) {
74
72
75
73
async function deleteCCFRIApplication ( req , res ) {
76
74
try {
77
- log . info ( 'deleteCCFRIApplication - ccfriId: ' , req . params . ccfriId ) ;
78
75
await deleteOperationWithObjectId ( 'ccof_applicationccfris' , req . params . ccfriId ) ;
79
76
return res . status ( HttpStatus . OK ) . json ( ) ;
80
77
} catch ( e ) {
@@ -85,12 +82,12 @@ async function deleteCCFRIApplication(req, res) {
85
82
86
83
//creates or updates CCFRI application.
87
84
async function updateCCFRIApplication ( req , res ) {
88
- let body = req . body ;
89
- let retVal = [ ] ;
85
+ const body = req . body ;
86
+ const retVal = [ ] ;
90
87
try {
91
88
await Promise . all (
92
89
body . map ( async ( facility ) => {
93
- let payload = {
90
+ const payload = {
94
91
ccof_ccfrioptin : facility . optInResponse ,
95
92
'ccof_Facility@odata.bind' : `/accounts(${ facility . facilityID } )` ,
96
93
'ccof_Application@odata.bind' : `/ccof_applications(${ facility . applicationID } )` ,
@@ -114,13 +111,11 @@ async function updateCCFRIApplication(req, res) {
114
111
//requirements changed so now we DO bind to main app... leaving this here for now just in case it changes again.
115
112
// if (!facility.changeRequestNewFacilityId){
116
113
// payload = {...payload, 'ccof_Application@odata .bind': `/ccof_applications(${facility.applicationID})`};
117
- // }
118
- log . info ( 'patch ccfri payload' , payload ) ;
114
+ // };
119
115
120
116
let response = undefined ;
121
117
if ( facility . ccfriApplicationId ) {
122
118
response = await patchOperationWithObjectId ( 'ccof_applicationccfris' , facility . ccfriApplicationId , payload ) ;
123
- log . info ( 'CCFRI RESP!!!!!!!' , response ) ;
124
119
retVal . push ( response ) ;
125
120
} else {
126
121
response = await postOperation ( 'ccof_applicationccfris' , payload ) ;
@@ -134,13 +129,12 @@ async function updateCCFRIApplication(req, res) {
134
129
135
130
//if this ccfri application is linked to a new facility change request, add the linkage to the New Facility Change Request
136
131
if ( facility . changeRequestNewFacilityId ) {
137
- let resp = await updateChangeRequestNewFacility ( facility . changeRequestNewFacilityId , {
132
+ const resp = await updateChangeRequestNewFacility ( facility . changeRequestNewFacilityId , {
138
133
'ccof_ccfri@odata.bind' : `/ccof_applicationccfris(${ facility . ccfriApplicationId ? facility . ccfriApplicationId : response } )` ,
139
134
} ) ;
140
135
retVal . push ( resp ) ;
141
136
}
142
137
await sleep ( 100 ) ; //slow down the hits to dynamics.
143
- //log.info('res data:' , response);
144
138
} ) ,
145
139
) ; //end for each
146
140
} catch ( e ) {
@@ -166,38 +160,28 @@ async function getApprovableFeeSchedules(req, res) {
166
160
/* child care and program year GUIDs are looked up in AddNewFees.vue */
167
161
168
162
async function upsertParentFees ( req , res ) {
169
- let body = req . body ;
170
-
171
- log . info ( body ) ;
163
+ const body = req . body ;
172
164
let hasError = false ;
173
- let theResponse = [ ] ;
174
165
175
166
//the front end sends over an array of objects. This loops through the array and sends a dynamics API request
176
167
//for each object.
177
168
body . forEach ( async ( feeGroup ) => {
178
169
//only call the delete API if there is a GUID acossciated to that child care category fee group
179
170
if ( feeGroup ?. deleteMe && feeGroup ?. parentFeeGUID ) {
180
171
try {
181
- let response = await deleteOperationWithObjectId ( 'ccof_application_ccfri_childcarecategories' , feeGroup . parentFeeGUID ) ;
182
- log . info ( 'delete feeGroup res:' , response ) ;
183
- theResponse . push ( res . status ( HttpStatus . OK ) . json ( response ) ) ;
172
+ await deleteOperationWithObjectId ( 'ccof_application_ccfri_childcarecategories' , feeGroup . parentFeeGUID ) ;
184
173
} catch ( e ) {
185
- //log.info(e);
186
174
hasError = true ;
187
175
return res . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . json ( ) ;
188
- //theResponse.push( res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ));
189
176
}
190
177
} else if ( feeGroup ?. feeFrequency ) {
191
- let childCareCategory = `/ccof_childcare_categories(${ feeGroup . childCareCategory } )` ;
192
- let programYear = `/ccof_program_years(${ feeGroup . programYear } )` ;
193
-
194
- // log.info(feeGroup.notes);
195
- // log.info(feeGroup.ccfriApplicationGuid);
196
-
197
- let payload = {
178
+ const childCareCategory = `/ccof_childcare_categories(${ feeGroup . childCareCategory } )` ;
179
+ const programYear = `/ccof_program_years(${ feeGroup . programYear } )` ;
180
+ const payload = {
198
181
ccof_frequency : feeGroup . feeFrequency ,
199
182
'ccof_ChildcareCategory@odata.bind' : childCareCategory ,
200
183
'ccof_ProgramYear@odata.bind' : programYear ,
184
+ 'ccof_ApplicationCCFRI@odata.bind' : `/ccof_applicationccfris(${ feeGroup . ccfriApplicationGuid } )` ,
201
185
} ;
202
186
203
187
Object . assign ( payload , {
@@ -214,13 +198,10 @@ async function upsertParentFees(req, res) {
214
198
ccof_feb : feeGroup . febFee ,
215
199
ccof_mar : feeGroup . marFee ,
216
200
} ) ;
217
- let url = `_ccof_applicationccfri_value=${ feeGroup . ccfriApplicationGuid } ,_ccof_childcarecategory_value=${ feeGroup . childCareCategory } ,_ccof_programyear_value=${ feeGroup . programYear } ` ;
201
+ const url = `_ccof_applicationccfri_value=${ feeGroup . ccfriApplicationGuid } ,_ccof_childcarecategory_value=${ feeGroup . childCareCategory } ,_ccof_programyear_value=${ feeGroup . programYear } ` ;
218
202
try {
219
- let response = await patchOperationWithObjectId ( 'ccof_application_ccfri_childcarecategories' , url , payload ) ;
220
- theResponse . push ( res . status ( HttpStatus . CREATED ) . json ( response ) ) ;
203
+ await patchOperationWithObjectId ( 'ccof_application_ccfri_childcarecategories' , url , payload ) ;
221
204
} catch ( e ) {
222
- //log.info(e);
223
- theResponse . push ( res . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . json ( e . data ? e . data : e ?. status ) ) ;
224
205
hasError = true ;
225
206
}
226
207
}
@@ -229,33 +210,25 @@ async function upsertParentFees(req, res) {
229
210
//if no notes, don't bother sending any requests. Even if left blank, front end will send over an empty string
230
211
//so body[0].notes will always exist
231
212
232
- let payload = {
213
+ const payload = {
233
214
ccof_informationccfri : body [ 0 ] . notes ,
234
215
ccof_formcomplete : body [ 0 ] . ccof_formcomplete ,
235
216
ccof_has_rfi : body [ 0 ] . ccof_has_rfi ,
236
217
ccof_feecorrectccfri : body [ 0 ] . existingFeesCorrect ,
237
218
ccof_chargefeeccfri : body [ 0 ] . hasClosureFees ,
238
219
} ;
239
220
240
- log . info ( body [ 0 ] . hasClosureFees ) ;
241
221
try {
242
- let response = await patchOperationWithObjectId ( 'ccof_applicationccfris' , body [ 0 ] . ccfriApplicationGuid , payload ) ;
243
- log . info ( 'notesRes' , response ) ;
244
- theResponse . push ( res . status ( HttpStatus . CREATED ) . json ( response ) ) ;
222
+ await patchOperationWithObjectId ( 'ccof_applicationccfris' , body [ 0 ] . ccfriApplicationGuid , payload ) ;
245
223
} catch ( e ) {
246
- theResponse . push ( res . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . json ( e . data ? e . data : e ?. status ) ) ;
247
224
hasError = true ;
248
225
}
249
226
250
227
//dates array will always exist - even if blank.
251
228
//we should save the empty field to dynamics if user selects "no" on "Do you charge parent fees at this facility for any closures on business days"
252
- log . info ( body [ 0 ] . facilityClosureDates ) ;
253
229
try {
254
- let response = await postClosureDates ( body [ 0 ] . facilityClosureDates , body [ 0 ] . ccfriApplicationGuid , res ) ;
255
- //log.info('datesRes', response);
256
- theResponse . push ( res . status ( HttpStatus . CREATED ) . json ( response ) ) ;
230
+ await postClosureDates ( body [ 0 ] . facilityClosureDates , body [ 0 ] . ccfriApplicationGuid , res ) ;
257
231
} catch ( e ) {
258
- theResponse . push ( res . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . json ( e . data ? e . data : e ?. status ) ) ;
259
232
hasError = true ;
260
233
}
261
234
@@ -274,22 +247,20 @@ function formatTimeForBack(timeString) {
274
247
}
275
248
276
249
async function postClosureDates ( dates , ccfriApplicationGuid , res ) {
277
- let retVal = [ ] ;
250
+ const retVal = [ ] ;
278
251
279
252
//delete all the old closure dates from the application - otherwise we will get duplicates when we save
280
- let dynamicsClosureDates = await getCCFRIClosureDates ( ccfriApplicationGuid ) ;
253
+ const dynamicsClosureDates = await getCCFRIClosureDates ( ccfriApplicationGuid ) ;
281
254
282
255
//don't bother trying to delete if there are no dates saved
283
256
if ( dynamicsClosureDates . length > 0 ) {
284
257
try {
285
258
await Promise . all (
286
259
dynamicsClosureDates . map ( async ( date ) => {
287
260
await deleteOperationWithObjectId ( 'ccof_application_ccfri_closures' , date . closureDateId ) ;
288
- //log.info(response);
289
261
} ) ,
290
262
) ;
291
263
} catch ( e ) {
292
- log . info ( 'something broke when deleting existing closure dates.' ) ;
293
264
log . info ( e ) ;
294
265
//return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status );
295
266
}
@@ -299,14 +270,14 @@ async function postClosureDates(dates, ccfriApplicationGuid, res) {
299
270
//if the user selects an end date, create a start and end date. else, use the only date for start and end.
300
271
await Promise . all (
301
272
dates . map ( async ( date ) => {
302
- let payload = {
273
+ const payload = {
303
274
ccof_startdate : formatTimeForBack ( date . formattedStartDate ) ,
304
275
ccof_paidclosure : date . feesPaidWhileClosed ,
305
276
ccof_enddate : date . formattedEndDate ? formatTimeForBack ( date . formattedEndDate ) : formatTimeForBack ( date . formattedStartDate ) ,
306
277
ccof_comment : date . closureReason ,
307
278
'ccof_ApplicationCCFRI@odata.bind' : `/ccof_applicationccfris(${ ccfriApplicationGuid } )` ,
308
279
} ;
309
- let response = await postOperation ( 'ccof_application_ccfri_closures' , payload ) ;
280
+ const response = await postOperation ( 'ccof_application_ccfri_closures' , payload ) ;
310
281
retVal . push ( response ) ;
311
282
} ) ,
312
283
) ;
@@ -319,13 +290,13 @@ async function postClosureDates(dates, ccfriApplicationGuid, res) {
319
290
320
291
async function getECEWEApplication ( req , res ) {
321
292
try {
322
- let operation =
293
+ const operation =
323
294
'ccof_applications(' +
324
295
req . params . applicationId +
325
296
')?$select=ccof_ecewe_optin,ccof_ecewe_employeeunion,ccof_ecewe_selecttheapplicablefundingmodel,ccof_ecewe_selecttheapplicablesector,ccof_public_sector_employer,ccof_ecewe_confirmation&$expand=ccof_ccof_application_ccof_applicationecewe_application($select=ccof_name,_ccof_facility_value,ccof_optintoecewe,statuscode)' ;
326
297
let eceweApp = await getOperation ( operation ) ;
327
298
eceweApp = new MappableObjectForFront ( eceweApp , ECEWEApplicationMappings ) ;
328
- let forFrontFacilities = [ ] ;
299
+ const forFrontFacilities = [ ] ;
329
300
Object . values ( eceweApp . data . facilities ) . forEach ( ( value ) => forFrontFacilities . push ( new MappableObjectForFront ( value , ECEWEFacilityMappings ) . data ) ) ;
330
301
eceweApp . data . facilities = forFrontFacilities ;
331
302
return res . status ( HttpStatus . OK ) . json ( eceweApp ) ;
@@ -342,38 +313,38 @@ async function updateECEWEApplication(req, res) {
342
313
application . ccof_ecewe_employeeunion = application . ccof_ecewe_optin == 0 ? null : application . ccof_ecewe_employeeunion ;
343
314
try {
344
315
log . verbose ( 'updateECEWEApplication: payload' , application ) ;
345
- let response = await patchOperationWithObjectId ( 'ccof_applications' , req . params . applicationId , application ) ;
316
+ const response = await patchOperationWithObjectId ( 'ccof_applications' , req . params . applicationId , application ) ;
346
317
return res . status ( HttpStatus . OK ) . json ( response ) ;
347
318
} catch ( e ) {
348
319
return res . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . json ( e . data ? e . data : e ?. status ) ;
349
320
}
350
321
}
351
322
352
323
async function updateECEWEFacilityApplication ( req , res ) {
353
- let facilities = req . body ;
354
- let forBackFacilities = [ ] ;
324
+ const facilities = req . body ;
325
+ const forBackFacilities = [ ] ;
355
326
let response ;
356
327
Object . values ( facilities ) . forEach ( ( value ) => forBackFacilities . push ( new MappableObjectForBack ( value , ECEWEFacilityMappings ) . data ) ) ;
357
328
let eceweApplicationId ;
358
329
try {
359
- for ( let key in forBackFacilities ) {
330
+ for ( const key in forBackFacilities ) {
360
331
// add join attributes for application and facility
361
332
forBackFacilities [ key ] [ 'ccof_application@odata.bind' ] = '/ccof_applications(' + req . params . applicationId + ')' ;
362
333
forBackFacilities [ key ] [ 'ccof_Facility@odata.bind' ] = '/accounts(' + forBackFacilities [ key ] . _ccof_facility_value + ')' ;
363
334
eceweApplicationId = forBackFacilities [ key ] . ccof_applicationeceweid ;
364
- let changeRequestNewFacilityId = forBackFacilities [ key ] . ccof_change_request_new_facilityid ;
335
+ const changeRequestNewFacilityId = forBackFacilities [ key ] . ccof_change_request_new_facilityid ;
365
336
// remove attributes that are already used in payload join (above) and not needed.
366
337
delete forBackFacilities [ key ] . ccof_applicationeceweid ;
367
338
delete forBackFacilities [ key ] . _ccof_facility_value ;
368
339
delete forBackFacilities [ key ] . ccof_change_request_new_facilityid ;
369
340
370
- let facility = forBackFacilities [ key ] ;
341
+ const facility = forBackFacilities [ key ] ;
371
342
if ( eceweApplicationId ) {
372
343
// send PATCH (update existing ECEWE facility)
373
344
response = await patchOperationWithObjectId ( 'ccof_applicationecewes' , eceweApplicationId , facility ) ;
374
345
} else {
375
346
// send POST (create a new ECEWE facility)
376
- let operation = 'ccof_applicationecewes' ;
347
+ const operation = 'ccof_applicationecewes' ;
377
348
response = await postOperation ( operation , facility ) ;
378
349
facilities [ key ] . eceweApplicationId = response ;
379
350
//if this is a new facility change request, link ECEWE application to the New Facility Change Request
@@ -391,7 +362,7 @@ async function updateECEWEFacilityApplication(req, res) {
391
362
/* Get the user declaration for a given application id. */
392
363
async function getDeclaration ( req , res ) {
393
364
try {
394
- let operation = 'ccof_applications(' + req . params . applicationId + ')?$select=ccof_consent,ccof_submittedby,ccof_declarationastatus,ccof_declarationbstatus,statuscode' ;
365
+ const operation = 'ccof_applications(' + req . params . applicationId + ')?$select=ccof_consent,ccof_submittedby,ccof_declarationastatus,ccof_declarationbstatus,statuscode' ;
395
366
let declaration = await getOperation ( operation ) ;
396
367
declaration = new MappableObjectForFront ( declaration , DeclarationMappings ) ;
397
368
return res . status ( HttpStatus . OK ) . json ( declaration ) ;
@@ -405,7 +376,7 @@ async function getDeclaration(req, res) {
405
376
async function submitApplication ( req , res ) {
406
377
let declaration = new MappableObjectForBack ( req . body , DeclarationMappings ) ;
407
378
declaration . data . statuscode = APPLICATION_STATUS_CODES . SUBMITTED ;
408
- let ccfriFacilitiesToLock = JSON . parse ( JSON . stringify ( declaration ) ) ;
379
+ const ccfriFacilitiesToLock = JSON . parse ( JSON . stringify ( declaration ) ) ;
409
380
declaration = declaration . toJSON ( ) ;
410
381
try {
411
382
delete declaration . facilities ;
0 commit comments