tango-app-api-trax 3.2.0-beta.6 → 3.2.0-beta.8

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.2.0-beta.6",
3
+ "version": "3.2.0-beta.8",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -371,6 +371,13 @@ export async function redoChecklist( req, res ) {
371
371
 
372
372
  let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
373
373
  if ( response.modifiedCount || response.matchedCount ) {
374
+ let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
375
+ let currentDateTime;
376
+ if ( storeTimeZone?.storeProfile?.timeZone ) {
377
+ currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
378
+ } else {
379
+ currentDateTime = dayjs();
380
+ }
374
381
  data = {
375
382
  checklistId: checklistDetails.sourceCheckList_id,
376
383
  checkListName: checklistDetails.checkListName,
@@ -386,7 +393,7 @@ export async function redoChecklist( req, res ) {
386
393
  type: checklistDetails.checkListType,
387
394
  userAnswer: userAnswer,
388
395
  initiatedBy: req.user.userName,
389
- initiatedTime: dayjs().format(),
396
+ initiatedTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
390
397
  answerType: question[sectionIndex].questions[req.body.payload.qno - 1].answerType,
391
398
  submitedBy: checklistDetails.userName,
392
399
  submitTime: checklistDetails.submitTime,
@@ -442,6 +442,55 @@ export async function sopMobilechecklistValidater( req, res, next ) {
442
442
  };
443
443
 
444
444
  export async function sopMobilechecklistQuestionValidator( req, res, next ) {
445
+ try {
446
+ let requestData = req.body;
447
+
448
+ logger.error( { function: 'CheckEmptyQA', error: requestData } );
449
+
450
+ requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
451
+ let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
452
+ if ( !getChecklistQA ) {
453
+ return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
454
+ }
455
+
456
+ if ( !requestData.questionAnswers.length ) {
457
+ return res.sendError( 'Please Fill all Required Fields', 400 );
458
+ }
459
+
460
+ if ( requestData.submittype == 'submit' ) {
461
+ let reqAnswers = requestData.questionAnswers;
462
+ let CLQAnswers = getChecklistQA.questionAnswers;
463
+ let validationCount= 0;
464
+ CLQAnswers.forEach( ( section ) => {
465
+ let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.section_id == section.section_id );
466
+ section.questions.forEach( ( question ) => {
467
+ question.answers.forEach( ( answer ) => {
468
+ let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qno == question.qno );
469
+ if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
470
+ validationCount++;
471
+ } else {
472
+ if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
473
+ validationCount++;
474
+ }
475
+ }
476
+ } );
477
+ } );
478
+ } );
479
+ if ( validationCount ) {
480
+ return res.sendError( 'Please Fill all Required Fields', 400 );
481
+ } else {
482
+ next();
483
+ }
484
+ } else {
485
+ next();
486
+ }
487
+ } catch ( e ) {
488
+ logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
489
+ return res.sendError( e, 500 );
490
+ }
491
+ };
492
+
493
+ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
445
494
  try {
446
495
  let requestData = req.body;
447
496
 
@@ -553,6 +602,319 @@ export async function sopMobileTaskQuestionValidator( req, res, next ) {
553
602
  };
554
603
 
555
604
  export async function sopMobilechecklistMultiSectionFormatter( req, res, next ) {
605
+ try {
606
+ let requestData = req.body;
607
+ requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
608
+ let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
609
+ let reqAnswers = requestData.questionAnswers;
610
+ let CLQAnswers = getChecklistQA.questionAnswers;
611
+
612
+ if ( requestData.submittype == 'submit' ) {
613
+ reqAnswers.forEach( ( reqA ) => {
614
+ if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( reqA?.answerType ) ) {
615
+ if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
616
+ return res.sendError( 'Please Fill All Fields', 400 );
617
+ }
618
+ }
619
+ } );
620
+ }
621
+
622
+ let sectionFormat = [];
623
+ let uniqueSections = {};
624
+ reqAnswers.forEach( ( item ) => {
625
+ const key = `${item.section_id}-${item.sectionName}`;
626
+ if ( !uniqueSections[key] ) {
627
+ uniqueSections[key] = { id: item.section_id, name: item.sectionName };
628
+ }
629
+ } );
630
+ const uniqueArray = Object.values( uniqueSections );
631
+ for ( let section of uniqueArray ) {
632
+ let CLQSection = CLQAnswers.find( ( item ) => item.section_id == section.id );
633
+ if ( CLQSection ) {
634
+ let newArray = [];
635
+ let qaAnswers = CLQSection.questions;
636
+ let requestSection = reqAnswers.filter( ( item ) => item.section_id == section.id );
637
+ for ( let i = 0; i < requestSection.length; i++ ) {
638
+ for ( let j = 0; j < qaAnswers.length; j++ ) {
639
+ if ( requestSection[i].qno == qaAnswers[j].qno ) {
640
+ if ( qaAnswers[j].answerType == 'yes/no' ) {
641
+ let qaans = qaAnswers[j].answers;
642
+ let yn = [];
643
+ for ( let k = 0; k < qaans.length; k++ ) {
644
+ if ( requestSection[i].answer == qaans[k].answer ) {
645
+ if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
646
+ if ( requestSection[i].validationAnswer ) {
647
+ let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
648
+ if ( validateAns.length ) {
649
+ let splitImgUrl = validateAns.split( '/' );
650
+ if ( splitImgUrl.length > 1 ) {
651
+ splitImgUrl.splice( 0, 3 );
652
+ qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
653
+ }
654
+ }
655
+ }
656
+ } else {
657
+ qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
658
+ qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
659
+ }
660
+ yn.push( qaans[k] );
661
+ }
662
+ }
663
+ let structure = {};
664
+ structure.qno = qaAnswers[j].qno;
665
+ structure.qname = qaAnswers[j].qname;
666
+ structure.answerType = qaAnswers[j].answerType;
667
+ structure.runAI = qaAnswers[j].runAI;
668
+ structure.runAIDescription = qaAnswers[j].runAIDescription;
669
+ structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
670
+ structure.remarks = requestSection[i].remarks;
671
+ structure.answers = qaAnswers[j].answers;
672
+ structure.userAnswer = yn;
673
+ structure.linkType = qaAnswers[j].linkType;
674
+ structure.linkquestionenabled = requestSection[i].linkquestionenabled;
675
+ structure.parentanswer = requestSection[i].parentanswer;
676
+ structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
677
+ structure.descriptivetype = qaAnswers[j].descriptivetype;
678
+ if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
679
+ structure.redo = false;
680
+ } else if ( requestData.submittype === 'draft' ) {
681
+ structure.redo = qaAnswers[j]?.redo;
682
+ }
683
+ if ( qaAnswers[j]?.redoComment ) {
684
+ structure.redoComment = qaAnswers[j]?.redoComment;
685
+ };
686
+ newArray.push( structure );
687
+ } else if ( qaAnswers[j].answerType == 'multiplechoicesingle' ) {
688
+ let qaans = qaAnswers[j].answers;
689
+ let ms = [];
690
+ for ( let k = 0; k < qaans.length; k++ ) {
691
+ if ( requestSection[i].answer == qaans[k].answer ) {
692
+ if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
693
+ if ( requestSection[i].validationAnswer ) {
694
+ let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
695
+ if ( validationAnswer.length ) {
696
+ let splitImgUrl = validationAnswer.split( '/' );
697
+ if ( splitImgUrl.length > 1 ) {
698
+ splitImgUrl.splice( 0, 3 );
699
+ qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
700
+ }
701
+ }
702
+ }
703
+ } else {
704
+ qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
705
+ qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
706
+ }
707
+ ms.push( qaans[k] );
708
+ }
709
+ }
710
+ let structure = {};
711
+ structure.qno = qaAnswers[j].qno;
712
+ structure.qname = qaAnswers[j].qname;
713
+ structure.answerType = qaAnswers[j].answerType;
714
+ structure.runAI = qaAnswers[j].runAI;
715
+ structure.runAIDescription = qaAnswers[j].runAIDescription;
716
+ structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
717
+ structure.remarks = requestSection[i].remarks;
718
+ structure.answers = qaAnswers[j].answers;
719
+ structure.userAnswer = ms;
720
+ structure.linkType = qaAnswers[j].linkType;
721
+ structure.linkquestionenabled = requestSection[i].linkquestionenabled;
722
+ structure.parentanswer = requestSection[i].parentanswer;
723
+ structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
724
+ structure.descriptivetype = qaAnswers[j].descriptivetype;
725
+ if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
726
+ structure.redo = false;
727
+ } else if ( requestData.submittype === 'draft' ) {
728
+ structure.redo = qaAnswers[j]?.redo;
729
+ }
730
+ if ( qaAnswers[j]?.redoComment ) {
731
+ structure.redoComment = qaAnswers[j]?.redoComment;
732
+ };
733
+ newArray.push( structure );
734
+ } else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' ) {
735
+ let qaans = qaAnswers[j].answers;
736
+ let mcmo = [];
737
+ for ( let k = 0; k < qaans.length; k++ ) {
738
+ let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
739
+ for ( let s = 0; s < separatedArray.length; s++ ) {
740
+ if ( separatedArray[s].answer == qaans[k].answer ) {
741
+ if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
742
+ if ( separatedArray[s].validationAnswer ) {
743
+ let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
744
+ if ( validationAnswer.length ) {
745
+ let splitImgUrl = validationAnswer.split( '/' );
746
+ if ( splitImgUrl.length > 1 ) {
747
+ splitImgUrl.splice( 0, 3 );
748
+ qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
749
+ }
750
+ }
751
+ }
752
+ } else {
753
+ qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
754
+ qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
755
+ }
756
+
757
+ mcmo.push( qaans[k] );
758
+ }
759
+ }
760
+ }
761
+ let structure = {};
762
+ structure.qno = qaAnswers[j].qno;
763
+ structure.qname = qaAnswers[j].qname;
764
+ structure.answerType = qaAnswers[j].answerType;
765
+ structure.runAI = qaAnswers[j].runAI;
766
+ structure.runAIDescription = qaAnswers[j].runAIDescription;
767
+ structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
768
+ structure.remarks = requestSection[i].remarks;
769
+ structure.answers = qaAnswers[j].answers;
770
+ structure.userAnswer = mcmo;
771
+ structure.linkType = qaAnswers[j].linkType;
772
+ structure.linkquestionenabled = requestSection[i].linkquestionenabled;
773
+ structure.parentanswer = requestSection[i].parentanswer;
774
+ structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
775
+ structure.descriptivetype = qaAnswers[j].descriptivetype;
776
+ if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
777
+ structure.redo = false;
778
+ } else if ( requestData.submittype === 'draft' ) {
779
+ structure.redo = qaAnswers[j]?.redo;
780
+ }
781
+ if ( qaAnswers[j]?.redoComment ) {
782
+ structure.redoComment = qaAnswers[j]?.redoComment;
783
+ };
784
+ newArray.push( structure );
785
+ } else if ( qaAnswers[j].answerType == 'multipleImage' ) {
786
+ let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
787
+ let mcmi = [];
788
+ // for (let k = 0; k < qaans.length; k++) {
789
+ for ( let s = 0; s < separatedArray.length; s++ ) {
790
+ if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
791
+ let newAnswer = {};
792
+ let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
793
+ if ( validationAnswer.length ) {
794
+ let splitImgUrl = validationAnswer.split( '/' );
795
+ if ( splitImgUrl.length > 1 ) {
796
+ splitImgUrl.splice( 0, 3 );
797
+ newAnswer.answer = splitImgUrl.join( '/' ) || '';
798
+ }
799
+ }
800
+
801
+ newAnswer.answeroptionNumber = 0;
802
+ newAnswer.sopFlag = false;
803
+ newAnswer.validation = false;
804
+ newAnswer.validationType = '';
805
+ newAnswer.referenceImage = '';
806
+ newAnswer.allowUploadfromGallery = false;
807
+ newAnswer.runAI = false;
808
+ newAnswer.descriptivetype = '';
809
+ newAnswer.showLinked = false;
810
+ newAnswer.linkedQuestion = 0;
811
+ newAnswer.nestedQuestion = [];
812
+ newAnswer.index = s;
813
+ mcmi.push( newAnswer );
814
+ }
815
+ }
816
+ // }
817
+ let structure = {};
818
+ structure.qno = qaAnswers[j].qno;
819
+ structure.qname = qaAnswers[j].qname;
820
+ structure.answerType = qaAnswers[j].answerType;
821
+ structure.runAI = qaAnswers[j].runAI;
822
+ structure.runAIDescription = qaAnswers[j].runAIDescription;
823
+ structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
824
+ structure.remarks = requestSection[i].remarks;
825
+ structure.answers = qaAnswers[j].answers;
826
+ structure.userAnswer = mcmi;
827
+ structure.linkType = qaAnswers[j].linkType;
828
+ structure.linkquestionenabled = requestSection[i].linkquestionenabled;
829
+ structure.parentanswer = requestSection[i].parentanswer;
830
+ structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
831
+ structure.descriptivetype = qaAnswers[j].descriptivetype;
832
+ if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
833
+ structure.redo = false;
834
+ } else if ( requestData.submittype === 'draft' ) {
835
+ structure.redo = qaAnswers[j]?.redo;
836
+ }
837
+ if ( qaAnswers[j]?.redoComment ) {
838
+ structure.redoComment = qaAnswers[j]?.redoComment;
839
+ };
840
+ newArray.push( structure );
841
+ } else {
842
+ let des = [];
843
+ if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
844
+ let validationAnswer = '';
845
+ if ( requestSection[i].answer.split( '?' ).length > 1 ) {
846
+ validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
847
+ }
848
+ if ( validationAnswer.length ) {
849
+ let splitImgUrl = validationAnswer.split( '/' );
850
+ if ( splitImgUrl.length > 1 ) {
851
+ splitImgUrl.splice( 0, 3 );
852
+ requestSection[i].answer = splitImgUrl.join( '/' );
853
+ }
854
+ }
855
+ let ansstructure = {
856
+ answer: requestSection[i].answer,
857
+ answeroptionNumber: 1,
858
+ sopFlag: false,
859
+ validation: false,
860
+ validationType: '',
861
+ validationAnswer: '',
862
+ referenceImage: qaAnswers[j].answers[0].referenceImage,
863
+ showLinked: qaAnswers[j].answers[0].showLinked,
864
+ linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
865
+ };
866
+ if ( qaAnswers[j].answerType == 'date' ) {
867
+ ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
868
+ }
869
+ des.push( ansstructure );
870
+ }
871
+ let structure = {};
872
+ structure.qno = qaAnswers[j].qno;
873
+ structure.qname = qaAnswers[j].qname;
874
+ structure.answerType = qaAnswers[j].answerType;
875
+ structure.runAI = qaAnswers[j].runAI;
876
+ structure.runAIDescription = qaAnswers[j].runAIDescription;
877
+ structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
878
+ structure.remarks = requestSection[i].remarks;
879
+ structure.answers = qaAnswers[j].answers;
880
+ structure.userAnswer = des;
881
+ structure.linkType = qaAnswers[j].linkType;
882
+ structure.linkquestionenabled = requestSection[i].linkquestionenabled;
883
+ structure.parentanswer = requestSection[i].parentanswer;
884
+ structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
885
+ structure.descriptivetype = qaAnswers[j].descriptivetype;
886
+ if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
887
+ structure.redo = false;
888
+ } else if ( requestData.submittype === 'draft' ) {
889
+ structure.redo = qaAnswers[j]?.redo;
890
+ }
891
+ if ( qaAnswers[j]?.redoComment ) {
892
+ structure.redoComment = qaAnswers[j]?.redoComment;
893
+ };
894
+ newArray.push( structure );
895
+ }
896
+ }
897
+ }
898
+ }
899
+ let sectionData = {
900
+ 'section_id': section.id,
901
+ 'sectionName': section.name,
902
+ 'questions': newArray,
903
+ };
904
+ sectionFormat.push( sectionData );
905
+ }
906
+ }
907
+
908
+
909
+ requestData.questionAnswers = sectionFormat;
910
+ next();
911
+ } catch ( error ) {
912
+ logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
913
+ return res.sendError( error, 500 );
914
+ }
915
+ };
916
+
917
+ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next ) {
556
918
  try {
557
919
  let requestData = req.body;
558
920
  requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
@@ -581,7 +943,6 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
581
943
  section.questions.forEach( ( question ) => {
582
944
  let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
583
945
  if ( !sectionQuestion.length ) {
584
- console.log( question, 'question', question.answerType );
585
946
  let data = { ...requestSection[0] };
586
947
  data.answerType = question.answerType;
587
948
  data.qno = question.qno;
@@ -2502,15 +2863,6 @@ export async function uploadAnswerImage( req, res ) {
2502
2863
  return res.sensError( 'Invalid Request: Please include questionNo!', 400 );
2503
2864
  }
2504
2865
 
2505
- let getChecklistQA = await processedchecklist.findOne( { _id: input.checklistId }, { sourceCheckList_id: 1 } );
2506
-
2507
- if ( getChecklistQA ) {
2508
- let checkChecklistStatus = await checklistService.findOne( { _id: getChecklistQA.sourceCheckList_id }, { publish: 1 } );
2509
- if ( !checkChecklistStatus.publish ) {
2510
- return res.sendError( 'Checklist got edited.please contact admin', 400 );
2511
- }
2512
- }
2513
-
2514
2866
  let date = dayjs().format( 'YYYY-MM-DD' );
2515
2867
  let folder;
2516
2868
 
@@ -609,7 +609,14 @@ export const flagCardsV1 = async ( req, res ) => {
609
609
  if ( data.questionFlag ) flagCards.questionFlag.count = data.questionFlag;
610
610
  if ( data.delayInSubmission ) flagCards.delayInSubmission.count = data.delayInSubmission;
611
611
 
612
- const publishedAiChecklists = await checklistconfigService.find( { client_id: clientId, publish: true, checkListType: { $ne: 'custom' } }, { checkListType: 1 } );
612
+ const publishedAiChecklists = await checklistconfigService.find(
613
+ {
614
+ client_id: clientId,
615
+ publish: true,
616
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] },
617
+ },
618
+ { checkListType: 1 },
619
+ );
613
620
 
614
621
  if ( !publishedAiChecklists?.length ) {
615
622
  return res.sendError( { error: 'No Data Found' }, 204 );
@@ -623,7 +630,9 @@ export const flagCardsV1 = async ( req, res ) => {
623
630
 
624
631
  if ( resultData && resultData.status_code === '200' ) {
625
632
  published.forEach( ( item ) => {
626
- flagCards.detectionFlag.count += resultData[item];
633
+ if ( resultData[item] ) {
634
+ flagCards.detectionFlag.count += resultData[item];
635
+ }
627
636
  } );
628
637
  flagCards.totalFlag = flagCards.detectionFlag.count;
629
638
  }
@@ -737,8 +746,14 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
737
746
 
738
747
  console.log( dayjs( toDate ).startOf( 'day' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'new start of' );
739
748
 
740
- const publishedAiChecklists = await checklistconfigService.find( { client_id: requestData.clientId, publish: true, checkListType: { $ne: 'custom' } }, { checkListType: 1 } );
741
-
749
+ const publishedAiChecklists = await checklistconfigService.find(
750
+ {
751
+ client_id: requestData.clientId,
752
+ publish: true,
753
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] },
754
+ },
755
+ { checkListType: 1 },
756
+ );
742
757
  if ( !publishedAiChecklists?.length ) {
743
758
  return 0;
744
759
  }
@@ -750,7 +765,11 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
750
765
 
751
766
  if ( resultData?.status_code === '200' ) {
752
767
  let result = 0;
753
- published.forEach( ( item ) => result += resultData[item] );
768
+ published.forEach( ( item ) => {
769
+ if ( resultData[item] ) {
770
+ result += resultData[item];
771
+ }
772
+ } );
754
773
  return result;
755
774
  }
756
775
  return 0;
@@ -804,7 +823,7 @@ export const flagTablesV1 = async ( req, res ) => {
804
823
  );
805
824
 
806
825
  if ( requestData?.filter === 'all' ) {
807
- findAndQuery.push( { $or: [ { questionFlag: { $gte: 1 } }, { timeFlag: { $gte: 1 } }, { checkListType: { $ne: 'custom' } } ] } );
826
+ findAndQuery.push( { $or: [ { questionFlag: { $gte: 1 } }, { timeFlag: { $gte: 1 } }, { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } } ] } );
808
827
  } else if ( requestData?.filter === 'question' ) {
809
828
  findAndQuery.push( { checkListType: 'custom' } );
810
829
  findAndQuery.push( { questionFlag: { $gte: 1 } } );
@@ -812,7 +831,7 @@ export const flagTablesV1 = async ( req, res ) => {
812
831
  findAndQuery.push( { checkListType: 'custom' } );
813
832
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
814
833
  } else if ( requestData?.filter === 'detection' ) {
815
- findAndQuery.push( { checkListType: { $ne: 'custom' } } );
834
+ findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } } );
816
835
  }
817
836
 
818
837
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -2629,7 +2648,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
2629
2648
  $or: [
2630
2649
  { questionFlag: { $gte: 1 } },
2631
2650
  { timeFlag: { $gte: 1 } },
2632
- { checkListType: { $ne: 'custom' } },
2651
+ { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } },
2633
2652
  ],
2634
2653
  },
2635
2654
  ] } },
@@ -562,6 +562,7 @@ export const duplicateChecklist = async ( req, res ) => {
562
562
  let userDetails = { ...userList[i]._doc };
563
563
  userDetails.checkListId = data._id;
564
564
  userDetails.checkListName = data.checkListName;
565
+ userDetails.sendNotification = false;
565
566
  delete userDetails['_id'];
566
567
  users.push( userDetails );
567
568
  }
@@ -935,7 +936,11 @@ export const updateConfigure =async ( req, res ) => {
935
936
  return res.sendError( 'no data found', 204 );
936
937
  }
937
938
 
938
- if ( inputBody.submitType == 'publish' && inputBody?.showEdit && typeof inputBody?.editSubmit == 'undefined' ) {
939
+ let currentDate = dayjs.utc().format();
940
+ let updatedscheduleEndTimeISO = dayjs.utc( inputBody?.checkListDetails?.scheduleStartTime, 'hh:mm A' ).format( 'HH:mm:ss' );
941
+ let newUpdatedDate = dayjs.utc( updatedscheduleEndTimeISO, 'HH:mm:ss' ).format();
942
+
943
+ if ( inputBody.submitType == 'publish' && inputBody?.showEdit && typeof inputBody?.editSubmit == 'undefined' && newUpdatedDate > currentDate ) {
939
944
  let checkSubmitDetails = await processedchecklist.findOne( { sourceCheckList_id: inputBody.checkListDetails._id, date_string: dayjs().format( 'YYYY-MM-DD' ), checklistStatus: 'submit' } );
940
945
  if ( checkSubmitDetails ) {
941
946
  return res.sendError( 'Checklist got submitted', 400 );
@@ -2096,6 +2101,8 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
2096
2101
  getsubmitDetails[0].questionAnswers = sectionList;
2097
2102
  if ( modifiedCount ) {
2098
2103
  getsubmitDetails[0].checklistStatus = 'inprogress';
2104
+ getsubmitDetails[0].date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
2105
+ getsubmitDetails[0].date_iso = new Date( date );
2099
2106
  }
2100
2107
  let data = { ...getsubmitDetails[0]._doc };
2101
2108
  await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
@@ -11,6 +11,7 @@ mobileRouter
11
11
  .post( '/startCheckList', isAllowedSessionHandler, validate( startValidation ), mobileController.startChecklist )
12
12
  .post( '/startTask', isAllowedSessionHandler, validate( startValidation ), mobileController.startTask )
13
13
  .post( '/submitCheckList', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobilechecklistQuestionValidator, mobileController.sopMobilechecklistMultiSectionFormatter, mobileController.submitChecklist )
14
+ .post( '/submitCheckListv5', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobilechecklistQuestionValidatorv1, mobileController.sopMobilechecklistMultiSectionFormatterv1, mobileController.submitChecklist )
14
15
  .post( '/submitTask', isAllowedSessionHandler, mobileController.sopMobilechecklistValidater, mobileController.sopMobileTaskQuestionValidator, mobileController.sopMobileTaskMultiSectionFormatter, mobileController.submitTask )
15
16
  .get( '/dashboard', isAllowedSessionHandler, validate( dashboardValidation ), mobileController.dashboard )
16
17
  .get( '/dashboardv1', isAllowedSessionHandler, validate( dashboardValidation ), mobileController.dashboardv1 )