tango-app-api-store-builder 1.0.0-beta-212 → 1.0.0-beta-214

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-store-builder",
3
- "version": "1.0.0-beta-212",
3
+ "version": "1.0.0-beta-214",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -30,21 +30,25 @@ export async function getplanoFeedback( req, res ) {
30
30
  const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
31
31
 
32
32
  let data = await planoTaskService.aggregate( pipeline );
33
- if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
33
+ if ( filterByApprovalStatus && filterByApprovalStatus?.length ) {
34
34
  if ( type == 'fixture' ) {
35
- if ( filterByApprovalStatus == 'pending' ) {
36
- data = data.filter( ( element ) => {
35
+ let pendingData = [];
36
+ let agreeData = [];
37
+ let disAgreeData = [];
38
+ if ( filterByApprovalStatus.includes( 'pending' ) ) {
39
+ pendingData = data.filter( ( element ) => {
37
40
  return element?.approvalStatus == 'pending';
38
41
  } );
39
- } if ( filterByApprovalStatus == 'agree' ) {
40
- data = data.filter( ( element ) => {
42
+ } if ( filterByApprovalStatus.includes( 'agree' ) ) {
43
+ agreeData = data.filter( ( element ) => {
41
44
  return element?.answers?.[0]?.status == 'agree';
42
45
  } );
43
- } if ( filterByApprovalStatus == 'disagree' ) {
44
- data = data.filter( ( element ) => {
46
+ } if ( filterByApprovalStatus.includes( 'disagree' ) ) {
47
+ disAgreeData = data.filter( ( element ) => {
45
48
  return element?.answers?.[0]?.status == 'disagree';
46
49
  } );
47
50
  }
51
+ data = [ ...pendingData, ...agreeData, ...disAgreeData ];
48
52
  } else {
49
53
  data.forEach( ( element ) => {
50
54
  element.answers?.forEach( ( ans ) => {
@@ -370,7 +374,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
370
374
  ...vmStages,
371
375
  { $sort: { _id: -1 } },
372
376
  ];
373
- if ( filterByApprovalStatus && filterByApprovalStatus != '' ) {
377
+ if ( filterByApprovalStatus && filterByApprovalStatus != '' && type !== 'fixture' ) {
374
378
  pipeline = [];
375
379
  pipeline.push( matchStage );
376
380
  pipeline.push(
@@ -1460,6 +1464,9 @@ export async function updateStoreFixture( req, res ) {
1460
1464
  },
1461
1465
  );
1462
1466
  }
1467
+ if ( req.body?.editMode ) {
1468
+ await floorService.updateOne( { _id: new mongoose.Types.ObjectId( currentFixture.floorId ) }, { isEdited: true } );
1469
+ }
1463
1470
  res.sendSuccess( 'Updated Successfully' );
1464
1471
  } catch ( e ) {
1465
1472
  logger.error( { functionName: 'updateStoreFixture', error: e } );
@@ -9698,45 +9698,44 @@ function transformProducts( products, shelvesByZone, fixtureData ) {
9698
9698
 
9699
9699
  // ---------------------Plano Migrate-------------------------
9700
9700
 
9701
- export async function getAllPlanoIds(req, res){
9701
+ export async function getAllPlanoIds( req, res ) {
9702
9702
  try {
9703
-
9704
- if (!req.query?.clientId) {
9705
- return res.sendError('Client id is required', 400);
9703
+ if ( !req.query?.clientId ) {
9704
+ return res.sendError( 'Client id is required', 400 );
9706
9705
  }
9707
- const floorsData = await storeBuilderService.aggregate([
9706
+ const floorsData = await storeBuilderService.aggregate( [
9708
9707
  {
9709
- '$match': {
9710
- 'clientId': '11'
9711
- }
9708
+ '$match': {
9709
+ 'clientId': '11',
9710
+ },
9712
9711
  }, {
9713
- '$group': {
9714
- '_id': '$planoId',
9715
- 'storeName': {
9716
- '$first': '$storeName'
9712
+ '$group': {
9713
+ '_id': '$planoId',
9714
+ 'storeName': {
9715
+ '$first': '$storeName',
9716
+ },
9717
+ 'storeId': {
9718
+ '$first': '$storeId',
9719
+ },
9717
9720
  },
9718
- 'storeId': {
9719
- '$first': '$storeId'
9720
- }
9721
- }
9722
- }, {
9723
- '$project': {
9724
- 'planoId': '$_id',
9725
- 'storeName': 1,
9726
- 'storeId': 1
9727
- }
9728
9721
  }, {
9729
- '$sort': { storeName: 1 }
9730
- }
9731
- ]);
9722
+ '$project': {
9723
+ 'planoId': '$_id',
9724
+ 'storeName': 1,
9725
+ 'storeId': 1,
9726
+ },
9727
+ }, {
9728
+ '$sort': { storeName: 1 },
9729
+ },
9730
+ ] );
9732
9731
 
9733
- if (floorsData) {
9734
- return res.sendSuccess(floorsData);
9732
+ if ( floorsData ) {
9733
+ return res.sendSuccess( floorsData );
9735
9734
  } else {
9736
- return res.sendError("No floor data found", 204)
9735
+ return res.sendError( 'No floor data found', 204 );
9737
9736
  }
9738
- } catch (error) {
9739
- console.log("@@ ~ getAllPlanoIds [ERR]:", error);
9740
- return res.sendError(e, 500);
9737
+ } catch ( error ) {
9738
+ console.log( '@@ ~ getAllPlanoIds [ERR]:', error );
9739
+ return res.sendError( e, 500 );
9741
9740
  }
9742
- }
9741
+ }
@@ -25,8 +25,9 @@ import * as fixtureShelfDuplicateService from '../service/fixtureShelfDuplicate.
25
25
  import * as planoMappingDuplicateService from '../service/planoMappingDuplicate.service.js';
26
26
  import * as fixtureConfigDuplicateService from '../service/fixtureConfigDuplicate.service.js';
27
27
  import * as planoVmDuplicateService from '../service/planoVmDuplicate.service.js';
28
+ import advancedFormat from 'dayjs/plugin/advancedFormat.js';
28
29
 
29
-
30
+ dayjs.extend( advancedFormat );
30
31
  dayjs.extend( utc );
31
32
  dayjs.extend( customParseFormat );
32
33
 
@@ -2800,7 +2801,7 @@ export async function storeFixturesv2( req, res ) {
2800
2801
  planograms.map( async ( planogram ) => {
2801
2802
  const floors = await storeBuilderService.find(
2802
2803
  { planoId: planogram._id, ...( req.body?.floorId && { _id: req.body.floorId } ) },
2803
- { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1 },
2804
+ { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1, updatedAt: 1 },
2804
2805
  );
2805
2806
 
2806
2807
  const floorsWithFixtures = await Promise.all(
@@ -3020,6 +3021,7 @@ export async function storeFixturesv2( req, res ) {
3020
3021
 
3021
3022
  return {
3022
3023
  ...floor.toObject(),
3024
+ updatedAt: dayjs( floor?.updatedAt ).format( 'Do MMM YYYY' ),
3023
3025
  fixtureCount: fixtureCount,
3024
3026
  vmCount: totalVmCount,
3025
3027
  layoutPolygon: layoutPolygonWithFixtures,
@@ -3550,7 +3552,7 @@ export async function storeFixturesTaskv2( req, res ) {
3550
3552
  let disabled = true;
3551
3553
  if ( compliance?.status ) {
3552
3554
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3553
- answer?.status === 'disagree' ||
3555
+ answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3554
3556
  answer?.issues?.some( ( issue ) =>
3555
3557
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3556
3558
  ),
@@ -3653,7 +3655,7 @@ export async function storeFixturesTaskv2( req, res ) {
3653
3655
  let disabled = true;
3654
3656
  if ( compliance?.status ) {
3655
3657
  const hasDisagree = compliance?.answers?.some( ( answer ) =>
3656
- answer?.status === 'disagree' ||
3658
+ answer?.status === 'disagree' || ( req.body?.type == 'fixture' && req?.body?.redo && compliance.status == 'complete' && !answer?.status ) ||
3657
3659
  answer?.issues?.some( ( issue ) =>
3658
3660
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3659
3661
  ),
@@ -4604,7 +4606,7 @@ export async function planoList( req, res ) {
4604
4606
  } );
4605
4607
  }
4606
4608
  if ( inputData.filter.status.includes( 'completed' ) ) {
4607
- let taskType= [ 'layout', 'fixture', 'vm' ];
4609
+ let taskType= [ 'fixture' ];
4608
4610
  let andCondition = [];
4609
4611
  taskType.forEach( ( type ) => {
4610
4612
  andCondition.push(
@@ -4615,7 +4617,7 @@ export async function planoList( req, res ) {
4615
4617
  },
4616
4618
  } },
4617
4619
  {
4618
- [`taskDetails.${type}Status`]: '',
4620
+ [`taskDetails.${type}Status`]: 'complete',
4619
4621
  },
4620
4622
  );
4621
4623
  } );
@@ -4888,6 +4890,7 @@ export async function getTaskDetails( req, res ) {
4888
4890
  floorId: '$_id.floorId',
4889
4891
  redoStatus: '$redoStatus',
4890
4892
  endTime: '$scheduleEndTime_iso',
4893
+ taskId: '$taskId',
4891
4894
  breach: {
4892
4895
  $cond: {
4893
4896
  if: {
@@ -5272,6 +5275,7 @@ export async function getTaskDetails( req, res ) {
5272
5275
  redoStatus: '$$task.redoStatus',
5273
5276
  endTime: '$$task.endTime',
5274
5277
  breach: '$$task.breach',
5278
+ taskId: '$$task.taskId',
5275
5279
  feedbackStatus: {
5276
5280
  $switch: {
5277
5281
  branches: [
@@ -5302,7 +5306,13 @@ export async function getTaskDetails( req, res ) {
5302
5306
  let taskInfo = await planotaskService.aggregate( query );
5303
5307
  let disabledInfo = [];
5304
5308
  let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1, planoProgress: 1 } );
5305
- disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ele.status != 'submit' ) && !ele?.breach );
5309
+ disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ( ele.status != 'submit' && !ele?.breach ) );
5310
+ if ( floorDetails.isEdited ) {
5311
+ let findPending = taskInfo?.[0]?.taskStatus?.findIndex( ( ele ) => ele.type == 'fixture' && ele.feedbackStatus == 'pending' );
5312
+ if ( findPending != -1 ) {
5313
+ disabledInfo = [];
5314
+ }
5315
+ }
5306
5316
  return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false, planoProgress: floorDetails?.planoProgress ?? 25 } );
5307
5317
  } catch ( e ) {
5308
5318
  logger.error( { functionName: 'getTaskDetails', error: e } );
@@ -1113,7 +1113,7 @@ export async function revokeTask( req, res ) {
1113
1113
  if ( !req.body.floorId ) {
1114
1114
  return res.sendError( 'floor id is required', 400 );
1115
1115
  }
1116
- await processedService.deleteMany( { planoId: req.body.planoId, floorId: req.body.floorId, checklistStatus: { $ne: 'submit' }, ...( req.body?.type && { planoType: req.body?.type } ) } );
1116
+ await processedService.deleteMany( { planoId: req.body.planoId, floorId: req.body.floorId, ...( req.body?.type != 'fixture' && { checklistStatus: { $ne: 'submit' } } ), ...( req.body?.type && { planoType: req.body?.type } ) } );
1117
1117
  return res.sendSuccess( 'Task revoked successfully' );
1118
1118
  } catch ( e ) {
1119
1119
  logger.error( { functionName: 'revokeTask', error: e } );