tango-app-api-trax 3.8.31 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.8.31",
3
+ "version": "3.9.1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "nodemon": "^3.1.4",
30
30
  "path": "^0.12.7",
31
31
  "puppeteer": "^24.39.1",
32
- "tango-api-schema": "^2.5.96",
32
+ "tango-api-schema": "^2.5.98",
33
33
  "tango-app-api-middleware": "^3.5.2",
34
34
  "url": "^0.11.4",
35
35
  "winston": "^3.13.1",
@@ -53,31 +53,31 @@ async function getBrandInfo( clientId ) {
53
53
  return brandInfo;
54
54
  }
55
55
 
56
- async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
57
- const zipName = `${sanitizeFilenamePart( zipBaseName, 'visit-checklists' )}_${dayjs().format( 'YYYY-MM-DD_HH-mm' )}.zip`;
56
+ // async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
57
+ // const zipName = `${sanitizeFilenamePart( zipBaseName, 'visit-checklists' )}_${dayjs().format( 'YYYY-MM-DD_HH-mm' )}.zip`;
58
58
 
59
- res.status( 200 );
60
- res.setHeader( 'Content-Type', 'application/zip' );
61
- res.setHeader( 'Content-Disposition', `attachment; filename="${zipName.replace( /"/g, '\\"' )}"` );
62
- res.setHeader( 'Cache-Control', 'private, no-cache' );
59
+ // res.status( 200 );
60
+ // res.setHeader( 'Content-Type', 'application/zip' );
61
+ // res.setHeader( 'Content-Disposition', `attachment; filename="${zipName.replace( /"/g, '\\"' )}"` );
62
+ // res.setHeader( 'Cache-Control', 'private, no-cache' );
63
63
 
64
- const archive = archiver( 'zip', { zlib: { level: 9 } } );
64
+ // const archive = archiver( 'zip', { zlib: { level: 9 } } );
65
65
 
66
- archive.on( 'error', ( err ) => {
67
- throw err;
68
- } );
66
+ // archive.on( 'error', ( err ) => {
67
+ // throw err;
68
+ // } );
69
69
 
70
- archive.pipe( res );
70
+ // archive.pipe( res );
71
71
 
72
- for ( const checklistDetails of checklistList ) {
73
- const templateData = buildVisitChecklistTemplateData( checklistDetails, brandInfo );
74
- const pdfBuffer = await generateVisitChecklistPDF( templateData );
75
- const pdfName = `${sanitizeFilenamePart( checklistDetails.storeName || checklistDetails.store_id || checklistDetails._id, 'store' )}_${sanitizeFilenamePart( checklistDetails.checkListName || 'Visit Checklist' )}.pdf`;
76
- archive.append( Buffer.isBuffer( pdfBuffer ) ? pdfBuffer : Buffer.from( pdfBuffer ), { name: pdfName } );
77
- }
72
+ // for ( const checklistDetails of checklistList ) {
73
+ // const templateData = buildVisitChecklistTemplateData( checklistDetails, brandInfo );
74
+ // const pdfBuffer = await generateVisitChecklistPDF( templateData );
75
+ // const pdfName = `${sanitizeFilenamePart( checklistDetails.storeName || checklistDetails.store_id || checklistDetails._id, 'store' )}_${sanitizeFilenamePart( checklistDetails.checkListName || 'Visit Checklist' )}.pdf`;
76
+ // archive.append( Buffer.isBuffer( pdfBuffer ) ? pdfBuffer : Buffer.from( pdfBuffer ), { name: pdfName } );
77
+ // }
78
78
 
79
- await archive.finalize();
80
- }
79
+ // await archive.finalize();
80
+ // }
81
81
 
82
82
  async function createChecklistZipBuffer( checklistList, brandInfo ) {
83
83
  const output = new PassThrough();
@@ -139,6 +139,7 @@ export async function getcustomerunattendedlist( req, res ) {
139
139
  }
140
140
  let url = JSON.parse( process.env.LAMBDAURL );
141
141
  let resultData = await LamdaServiceCall( url.customerUnattended, req.body );
142
+ console.log( '🚀 ~ getcustomerunattendedlist ~ url.customerUnattended:', url.customerUnattended );
142
143
  if ( resultData ) {
143
144
  if ( resultData.status_code == '200' ) {
144
145
  return res.sendSuccess( resultData );
@@ -436,14 +437,12 @@ export async function redoChecklist( req, res ) {
436
437
  }
437
438
 
438
439
 
439
- let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, coverage: 1, userEmail: 1, scheduleEndTime_iso: 1, redoEdit: 1 } );
440
-
440
+ let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, coverage: 1, userEmail: 1 } );
441
441
  if ( !checklistDetails ) {
442
442
  return res.sendError( 'No data found', 204 );
443
443
  }
444
444
  let question = checklistDetails.questionAnswers;
445
445
 
446
- let checklistConfigDetails = await checklistService.findOne( { _id: checklistDetails.sourceCheckList_id }, { redoValidity: 1 } );
447
446
 
448
447
  let sectionIndex = question.findIndex( ( sec ) => sec.sectionName == req.body.payload.sectionName );
449
448
  if ( sectionIndex == -1 ) {
@@ -452,98 +451,40 @@ export async function redoChecklist( req, res ) {
452
451
 
453
452
  let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
454
453
 
455
- let data = { ...question[sectionIndex].questions[findQuestion], redo: true, ...( !req.body.payload?.answerIndex && { redoComment: req.body.payload?.checklistDescription || '' } ) };
456
- let answerIndex = req.body.payload?.answerIndex;
457
- let isSingleAnswerRedo = answerIndex != null;
458
-
459
- if ( !isSingleAnswerRedo ) {
460
- // if ( checklistDetails.client_id == '458' ) {
461
- data.answers.forEach( ( item ) => {
462
- if ( item.showLinked ) {
463
- item.nestedQuestion.forEach( ( ele ) => {
464
- let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
465
- let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
466
- question[sectionIndex].questions[eleIndex] = element;
467
- question[sectionIndex].questions[eleIndex].answers.forEach( ( ans ) => {
468
- ans.validationAnswer = '';
469
- delete ans.redoComment;
470
- delete ans.redo;
471
- } );
472
- question[sectionIndex].questions[eleIndex].userAnswer = [];
473
- question[sectionIndex].questions[eleIndex].remarks = '';
474
- } );
475
- }
476
- } );
477
- // data.answers.forEach( ( item ) => {
478
- // if ( item.showLinked ) {
479
- // item.nestedQuestion = [];
480
- // item.showLinked = false;
481
- // item.linkedQuestion = 0;
482
- // }
483
- // } );
484
- // }
485
- }
486
- let userAnswer = Array.isArray( data.userAnswer ) ? [ ...data.userAnswer ] : [];
487
-
488
- question[sectionIndex].questions[findQuestion] = data;
489
- if ( isSingleAnswerRedo ) {
490
- let targetQuestion = question[sectionIndex].questions[findQuestion];
491
- let targetUserAnswerIndex = targetQuestion.userAnswer?.findIndex( ( ele ) => ele.answer == req.body.payload.answerName );
492
- let targetUserAnswer = targetQuestion.userAnswer[targetUserAnswerIndex];
493
- if ( targetUserAnswer && Array.isArray( targetQuestion.answers ) ) {
494
- let matchedAnsIdx = targetQuestion.answers.findIndex( ( ans ) => {
495
- // if ( targetUserAnswer.no !== undefined && ans.index === targetUserAnswer.no ) return true;
496
- // if ( targetUserAnswer.index !== undefined && ans.index === targetUserAnswer.index ) return true;
497
- // if ( targetUserAnswer.answeroptionNumber !== undefined && ans.answeroptionNumber === targetUserAnswer.answeroptionNumber ) return true;
498
- return ans.answer === targetUserAnswer.answer;
454
+ let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
455
+ // if ( checklistDetails.client_id == '458' ) {
456
+ data.answers.forEach( ( item ) => {
457
+ if ( item.showLinked ) {
458
+ item.nestedQuestion.forEach( ( ele ) => {
459
+ let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
460
+ let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
461
+ question[sectionIndex].questions[eleIndex] = element;
462
+ question[sectionIndex].questions[eleIndex].userAnswer = [];
463
+ question[sectionIndex].questions[eleIndex].remarks = '';
499
464
  } );
500
- if ( matchedAnsIdx !== -1 ) {
501
- targetQuestion.answers[matchedAnsIdx].redo = true;
502
- targetQuestion.answers[matchedAnsIdx].validationAnswer = '';
503
- targetQuestion.answers[matchedAnsIdx].redoComment = req.body.payload?.checklistDescription || '';
504
- targetQuestion.remarks = '';
505
- }
506
- targetQuestion.userAnswer.splice( targetUserAnswerIndex, 1 );
507
465
  }
466
+ } );
467
+ // data.answers.forEach( ( item ) => {
468
+ // if ( item.showLinked ) {
469
+ // item.nestedQuestion = [];
470
+ // item.showLinked = false;
471
+ // item.linkedQuestion = 0;
472
+ // }
473
+ // } );
474
+ // }
475
+ let userAnswer = data.userAnswer;
508
476
 
509
- let currentQno = req.body.payload.qno;
510
- let parentQIndex = -1;
511
- // let parentAnsIndex = -1;
512
- for ( let i = 0; i < question[sectionIndex].questions.length; i++ ) {
513
- let parentAnswers = question[sectionIndex].questions[i].answers || [];
514
- let foundAnsIdx = parentAnswers.findIndex( ( ans ) => Array.isArray( ans?.nestedQuestion ) && ans.nestedQuestion.some( ( ele ) => parseInt( ele ) == currentQno ) );
515
- if ( foundAnsIdx !== -1 ) {
516
- parentQIndex = i;
517
- // parentAnsIndex = foundAnsIdx;
518
- break;
519
- }
520
- }
521
- if ( parentQIndex !== -1 ) {
522
- let parentQno = question[sectionIndex].questions[parentQIndex].qno;
523
- question[sectionIndex].questions[findQuestion].parentQno = parentQno;
524
- // question[sectionIndex].questions[findQuestion].remarks = '';
525
- // question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].redo = true;
526
- // question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].validationAnswer = '';
527
- }
528
- } else {
529
- question[sectionIndex].questions[findQuestion].userAnswer = [];
530
- if ( Array.isArray( question[sectionIndex].questions[findQuestion].answers ) ) {
531
- question[sectionIndex].questions[findQuestion].answers.forEach( ( ans ) => {
532
- ans.validationAnswer = '';
533
- delete ans.redoComment;
534
- delete ans.redo;
535
- } );
536
- }
537
- question[sectionIndex].questions[findQuestion].remarks = '';
538
- }
477
+ question[sectionIndex].questions[findQuestion] = data;
478
+ question[sectionIndex].questions[findQuestion].userAnswer = [];
479
+ question[sectionIndex].questions[findQuestion].remarks = '';
539
480
  checklistDetails.questionAnswers = question;
540
481
  let updateData = {
541
- checklistStatus: checklistDetails.checklistStatus != 'submit' ? checklistDetails.checklistStatus : 'open',
482
+ checklistStatus: 'open',
542
483
  redoStatus: true,
543
484
  reinitiateStatus: true,
544
485
  questionAnswers: question,
545
486
  ...( checklistDetails.checklistStatus != 'submit' && checklistDetails.redoStatus ) ? { redoEdit: true } : {},
546
- ...( ( checklistDetails.redoEdit === undefined && checklistConfigDetails.redoValidity ) && { scheduleEndTime_iso: dayjs( checklistDetails.scheduleEndTime_iso ).add( checklistConfigDetails.redoValidity, 'day' ).format() } ),
487
+ ...( ( checklistDetails.redoEdit === undefined && checklistConfigDetails.redoValidity ) ) ? { scheduleEndTime_iso: dayjs( checklistDetails.scheduleEndTime_iso ).add( checklistConfigDetails.redoValidity, 'day' ).format() } :{},
547
488
  };
548
489
 
549
490
  let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
@@ -556,6 +497,9 @@ export async function redoChecklist( req, res ) {
556
497
  // } else {
557
498
  // currentDateTime = dayjs();
558
499
  // }
500
+ if ( req.body?.payload?.answerName ) {
501
+ userAnswer = userAnswer?.filter( ( ele ) => ele.answer == req.body.payload.answerName );
502
+ }
559
503
  data = {
560
504
  checklistId: checklistDetails.sourceCheckList_id,
561
505
  checkListName: checklistDetails.checkListName,
@@ -802,9 +746,8 @@ export async function getLogs( req, res ) {
802
746
  let initiatedstatus = {
803
747
  actionType: 'initation',
804
748
  userName: data.initiatedBy,
805
- Timestamp: data.initiatedTime,
749
+ Timestamp: dayjs.utc( data.initiatedTime ),
806
750
  description: data.checklistDescription,
807
-
808
751
  };
809
752
  response.push( initiatedstatus );
810
753
  response.push( userAnswer );
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-invalid-this */
1
2
  import Handlebars from 'handlebars';
2
3
  import fs from 'fs';
3
4
 
@@ -325,7 +325,7 @@ export async function PCLconfigCreation( req, res ) {
325
325
  },
326
326
  } );
327
327
  let getSections = await CLquestions.aggregate( sectionQuery );
328
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'storehygienemonitoring' ].includes( getCLconfig.checkListType ) ) {
328
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'storehygienemonitoring', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
329
329
  if ( getSections.length ) {
330
330
  for ( let element3 of getSections ) {
331
331
  let collectQuestions = {};
@@ -650,11 +650,11 @@ export async function PCLconfigCreation( req, res ) {
650
650
  // }
651
651
  }
652
652
  } else {
653
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
653
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert' ].includes( getCLconfig.checkListType ) ) {
654
654
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
655
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
655
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
656
656
  let storeList = storeDetails.map( ( store ) => store.storeId );
657
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
657
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
658
658
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
659
659
  } else {
660
660
  allQuestion = storeDetails.map( ( item ) => {
@@ -688,7 +688,7 @@ export async function PCLconfigCreation( req, res ) {
688
688
  client_id: getCLconfig.client_id,
689
689
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
690
690
  };
691
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
691
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
692
692
  let processData = {
693
693
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
694
694
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -929,7 +929,7 @@ async function insertData( requestData ) {
929
929
  },
930
930
  } );
931
931
  let getSections = await CLquestions.aggregate( sectionQuery );
932
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
932
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
933
933
  if ( getSections.length ) {
934
934
  for ( let element3 of getSections ) {
935
935
  let collectQuestions = {};
@@ -1224,11 +1224,11 @@ async function insertData( requestData ) {
1224
1224
  // }
1225
1225
  }
1226
1226
  } else {
1227
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1227
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
1228
1228
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
1229
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1229
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1230
1230
  let storeList = storeDetails.map( ( store ) => store.storeId );
1231
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1231
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
1232
1232
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
1233
1233
  } else {
1234
1234
  allQuestion = storeDetails.map( ( item ) => {
@@ -1262,7 +1262,7 @@ async function insertData( requestData ) {
1262
1262
  client_id: getCLconfig.client_id,
1263
1263
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
1264
1264
  };
1265
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1265
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
1266
1266
  let processData = {
1267
1267
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
1268
1268
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -3734,7 +3734,7 @@ export const downloadInsertPdf = async ( req, res ) => {
3734
3734
  Buffer.from( pdfBuffer );
3735
3735
 
3736
3736
  let pdfName;
3737
- if ( doc.store_id ) {
3737
+ if ( doc?.store_id ) {
3738
3738
  pdfName = `${safeName(
3739
3739
  doc.store_id + '_' + ( doc.storeName || 'store' ),
3740
3740
  )}.pdf`;