tango-app-api-trax 3.9.3 → 3.9.5

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.9.3",
3
+ "version": "3.9.5",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -118,7 +118,7 @@ export async function startChecklist( req, res ) {
118
118
  $and: [
119
119
  { _id: new ObjectId( requestData.processedcheckListId ) },
120
120
  { userId: req.user._id },
121
- { date_string: requestData.date },
121
+ { $or: [ { date_string: requestData.date }, { redoStatus: true } ] },
122
122
  ],
123
123
  },
124
124
  } );
@@ -137,7 +137,9 @@ export async function startChecklist( req, res ) {
137
137
  let updateQuery = {};
138
138
  updateQuery._id = new ObjectId( requestData.processedcheckListId );
139
139
  updateQuery.userId = req.user._id;
140
- updateQuery.date_string = requestData.date;
140
+ if ( getBeforeChecklist?.[0]?.date_string == dayjs().format( 'YYYY-MM-DD' ) ) {
141
+ updateQuery.date_string = requestData.date;
142
+ }
141
143
 
142
144
  if ( PCLQusestion && PCLQusestion?.questionAnswers && PCLQusestion?.questionAnswers.length > 0 ) {
143
145
  await PCLQusestion.questionAnswers.forEach( ( section ) => {
@@ -317,7 +319,7 @@ export async function startChecklist( req, res ) {
317
319
  return res.sendError( 'something went wrong please try again', 500 );
318
320
  }
319
321
  } catch ( e ) {
320
- // console.log( 'e =>', e );
322
+ console.log( 'e =>', e );
321
323
  logger.error( { function: 'startChecklist', error: e, body: req.body } );
322
324
  return res.sendError( e, 500 );
323
325
  }
@@ -661,12 +663,12 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
661
663
  let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
662
664
  if ( sectionQuestion.length ) {
663
665
  if ( requestData.submittype == 'submit' ) {
664
- if ( ( [ 'multipleImage', 'multiplechoicemultiple' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
666
+ if ( ( [ 'multipleImage', 'multiplechoicemultiple', 'image/video' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
665
667
  if ( ( !sectionQuestion[0].linkType || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled ) ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
666
668
  validationCount++;
667
669
  }
668
670
  } else {
669
- if ( ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( question.answerType =='dropdown' && !question.allowMultiple ) ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
671
+ if ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) {
670
672
  validationCount++;
671
673
  }
672
674
  }
@@ -1819,7 +1821,6 @@ export async function sopMobilechecklistMultiSectionFormatterv2( req, res, next
1819
1821
  let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
1820
1822
  for ( let s = 0; s < separatedArray.length; s++ ) {
1821
1823
  if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
1822
- console.log( qaans[k].redo, separatedArray[s].redo, qaans[k].redo == separatedArray[s].redo, qaans[k].answer );
1823
1824
  if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
1824
1825
  if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
1825
1826
  if ( separatedArray[s].validationAnswer ) {
@@ -2685,7 +2686,7 @@ export async function submitChecklist( req, res ) {
2685
2686
  $and: [
2686
2687
  { _id: new ObjectId( requestData.processedcheckListId ) },
2687
2688
  { userId: req.user._id },
2688
- { date_string: requestData.date },
2689
+ { $or: [ { date_string: requestData.date }, { redoStatus: true } ] },
2689
2690
  ],
2690
2691
  },
2691
2692
  } );
@@ -2705,7 +2706,9 @@ export async function submitChecklist( req, res ) {
2705
2706
  let updateQuery = {};
2706
2707
  updateQuery._id = new ObjectId( requestData.processedcheckListId );
2707
2708
  updateQuery.userId = req.user._id;
2708
- updateQuery.date_string = requestData.date;
2709
+ if ( !getchecklist?.[0]?.redoStatus ) {
2710
+ updateQuery.date_string = requestData.date;
2711
+ }
2709
2712
 
2710
2713
  let currentDateTime;
2711
2714
  let storeTimeZone;
@@ -2723,6 +2726,9 @@ export async function submitChecklist( req, res ) {
2723
2726
  let flagCount = QuestionFlag( req, res );
2724
2727
  updateData.questionFlag = flagCount;
2725
2728
  updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
2729
+ if ( getchecklist?.[0]?.redoEdit != undefined ) {
2730
+ updateData.redoEdit = false;
2731
+ }
2726
2732
  if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
2727
2733
  updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
2728
2734
  }
@@ -3503,6 +3509,9 @@ export async function dashboardv1( req, res ) {
3503
3509
  // const { store_id, date } = req.query;
3504
3510
  const { date } = req.query;
3505
3511
  const userId = req.user._id;
3512
+ let fromDate = new Date( req.query.date );
3513
+ let toDate = new Date( req.query.date );
3514
+ toDate.setDate( toDate.getDate() + 1 );
3506
3515
 
3507
3516
  // //Get User Based Checklist //
3508
3517
  const clientId = { client_id: req.user.clientId };
@@ -3519,7 +3528,7 @@ export async function dashboardv1( req, res ) {
3519
3528
  ...storeMatch,
3520
3529
  };
3521
3530
  const buildPipeline = ( matchExtraConditions = {} ) => [
3522
- { $match: { ...baseMatch, ...matchExtraConditions } },
3531
+ { $match: { $or: [ { ...baseMatch, ...matchExtraConditions }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } }, { userId }, { ...storeMatch } ] } ] } },
3523
3532
  {
3524
3533
  $facet: {
3525
3534
  total: [ { $count: 'total' } ],
@@ -3539,9 +3548,7 @@ export async function dashboardv1( req, res ) {
3539
3548
  },
3540
3549
  ];
3541
3550
 
3542
- let fromDate = new Date( req.query.date );
3543
- let toDate = new Date( req.query.date );
3544
- toDate.setDate( toDate.getDate() + 1 );
3551
+
3545
3552
  const taskBaseMatch = {
3546
3553
  // eslint-disable-next-line camelcase
3547
3554
  // store_id,
@@ -3719,6 +3726,9 @@ export async function checklistv1( req, res ) {
3719
3726
  // const { store_id, date, checklistStatus, searchValue } = req.query;
3720
3727
  const { date, checklistStatus, searchValue } = req.query;
3721
3728
  const userId = req.user._id;
3729
+ let fromDate = new Date( req.query.date );
3730
+ let toDate = new Date( req.query.date );
3731
+ toDate.setDate( toDate.getDate() + 1 );
3722
3732
 
3723
3733
  // Get User Based Checklist //
3724
3734
  const clientId = { client_id: req.user.clientId };
@@ -3730,7 +3740,7 @@ export async function checklistv1( req, res ) {
3730
3740
  // eslint-disable-next-line camelcase
3731
3741
  // { store_id },
3732
3742
  { userId },
3733
- { date_string: date },
3743
+ { $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] },
3734
3744
  { timeFlagStatus: true },
3735
3745
  ...matchExtraConditions,
3736
3746
  clientId,
@@ -3792,9 +3802,7 @@ export async function checklistv1( req, res ) {
3792
3802
  return pipeline;
3793
3803
  };
3794
3804
 
3795
- let fromDate = new Date( req.query.date );
3796
- let toDate = new Date( req.query.date );
3797
- toDate.setDate( toDate.getDate() + 1 );
3805
+
3798
3806
  const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
3799
3807
  const matchConditions = [
3800
3808
  // eslint-disable-next-line camelcase
@@ -4174,7 +4182,7 @@ export async function questionList( req, res ) {
4174
4182
  checkvalidation = answer.validationAnswer;
4175
4183
  }
4176
4184
  }
4177
- Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
4185
+ Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation, ...( answer.redo && { redo: answer.redo } ) } );
4178
4186
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
4179
4187
  }
4180
4188