tango-app-api-trax 3.6.0-sec-2 → 3.6.0-sec-4

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.6.0-sec-2",
3
+ "version": "3.6.0-sec-4",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -79,14 +79,14 @@ export const downloadInsert = async ( req, res ) => {
79
79
  },
80
80
  } );
81
81
  }
82
- getChecklistQuery.push( { $count: 'totalCount' } );
82
+ // getChecklistQuery.push( { $count: 'totalCount' } );
83
83
 
84
84
  let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
85
85
  // console.log( getChecklistCount );
86
86
  if ( requestData.insertType === 'task' ) {
87
87
  getChecklistCount = await processedTaskService.aggregate( getChecklistQuery );
88
88
  }
89
- if ( getChecklistCount && getChecklistCount[0]?.totalCount && getChecklistCount[0].totalCount > 0 ) {
89
+ if ( getChecklistCount && getChecklistCount.length > 0 ) {
90
90
  // console.log( 'if' );
91
91
  // console.log( 'getChecklistCountgetChecklistCount[0].totalCount =>', getChecklistCount[0]?.totalCount );
92
92
  } else {
@@ -159,7 +159,11 @@ export async function startChecklist( req, res ) {
159
159
  currentDateTime = dayjs();
160
160
  }
161
161
  } else {
162
- currentDateTime = dayjs();
162
+ if ( requestData.currentTime && requestData.currentTime !='' ) {
163
+ currentDateTime = requestData?.currentTime ? dayjs( requestData.currentTime, 'HH:mm:ss' ) : dayjs();
164
+ } else {
165
+ currentDateTime = dayjs();
166
+ }
163
167
  }
164
168
  updateData.checklistStatus = 'inprogress';
165
169
  updateData.startMobileTime = requestData?.currentTime;
@@ -343,13 +347,29 @@ export async function startTask( req, res ) {
343
347
  }
344
348
  }
345
349
 
346
- const storeTimeZone = await storeService.findOne(
347
- { storeName: task.storeName },
348
- { 'storeProfile.timeZone': 1 },
349
- );
350
- const currentDateTime = storeTimeZone?.storeProfile?.timeZone ?
351
- dayjs().tz( storeTimeZone.storeProfile.timeZone ) :
352
- dayjs();
350
+ // const storeTimeZone = await storeService.findOne(
351
+ // { storeName: task.storeName },
352
+ // { 'storeProfile.timeZone': 1 },
353
+ // );
354
+ // const currentDateTime = storeTimeZone?.storeProfile?.timeZone ?
355
+ // dayjs().tz( storeTimeZone.storeProfile.timeZone ) :
356
+ // dayjs();
357
+
358
+ let currentDateTime;
359
+ if ( getBeforeTask[0].storeName && getBeforeTask[0].storeName!='' ) {
360
+ let storeTimeZone = await storeService.findOne( { storeName: { $regex: getBeforeTask[0].storeName, $options: 'i' }, clientId: getBeforeTask[0].client_id }, { 'storeProfile.timeZone': 1 } );
361
+ if ( storeTimeZone?.storeProfile?.timeZone ) {
362
+ currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
363
+ } else {
364
+ currentDateTime = dayjs();
365
+ }
366
+ } else {
367
+ if ( requestData.currentTime && requestData.currentTime !='' ) {
368
+ currentDateTime = requestData?.currentTime ? dayjs( requestData.currentTime, 'HH:mm:ss' ) : dayjs();
369
+ } else {
370
+ currentDateTime = dayjs();
371
+ }
372
+ }
353
373
 
354
374
  const updateData = {
355
375
  checklistStatus: 'inprogress',
@@ -140,6 +140,7 @@ export const mobileChecklistValidation = {
140
140
  export const startSchema = joi.object( {
141
141
  date: joi.string().required(),
142
142
  processedcheckListId: joi.string().required(),
143
+ currentTime: joi.string().optional().allow( '' ),
143
144
  } );
144
145
 
145
146
  export const startValidation = {