tango-app-api-store-builder 1.0.0-beta-178 → 1.0.0-beta-180

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-178",
3
+ "version": "1.0.0-beta-180",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -72,7 +72,14 @@ export async function updateTemplate( req, res ) {
72
72
  if ( !templateDetails ) {
73
73
  return res.sendError( 'No data found', 204 );
74
74
  }
75
- inputData.isEdited = true;
75
+ let checkName = await fixtureConfigService.find( { _id: { $nin: req.params.templateId }, fixtureName: inputData.fixtureName } );
76
+ if ( checkName ) {
77
+ return res.sendError( 'Fixture name already exist', 400 );
78
+ }
79
+ let checkstoreMapped = await storeFixtureService.findOne( { fixtureConfigId: req.params.templateId } );
80
+ if ( checkstoreMapped ) {
81
+ inputData.isEdited = true;
82
+ }
76
83
  await fixtureConfigService.updateOne( { _id: req.params.templateId }, inputData );
77
84
  return res.sendSuccess( 'Fixture template details updated successfully' );
78
85
  } catch ( e ) {
@@ -1315,9 +1322,7 @@ export async function getTreeList( req, res ) {
1315
1322
  let storeFixtureCount = await storeFixtureService.count( { fixtureConfigId: fixt._id } );
1316
1323
  fixt.vmConfig = await Promise.all( fixt.vmConfig.map( async ( vm ) => {
1317
1324
  let vmDetails = await vmService.findOne( { _id: vm.vmId }, { _id: 0 } );
1318
- if ( vmDetails ) {
1319
- return { ...vm, ...vmDetails.toObject() };
1320
- }
1325
+ return { ...vm, ...vmDetails?.toObject() };
1321
1326
  } ) );
1322
1327
  return { ...fixt, storeCount: storeFixtureCount };
1323
1328
  } ) );
@@ -1367,6 +1372,7 @@ export async function duplicateTemplate( req, res ) {
1367
1372
  delete templateDetails.templateGroupName;
1368
1373
  templateDetails.fixtureName = newFixtureName;
1369
1374
  templateDetails.status = 'complete';
1375
+ templateDetails.isEdited = false;
1370
1376
  let duplicateDetails = await fixtureConfigService.create( templateDetails );
1371
1377
  return res.sendSuccess( { message: type == 'sub' ? 'Fixture template duplicated successfully' : 'Variant created successfully', id: duplicateDetails?._id } );
1372
1378
  } catch ( e ) {
@@ -8,7 +8,7 @@ import * as fixtureShelfService from '../service/fixtureShelf.service.js';
8
8
  import * as planoVmService from '../service/planoVm.service.js';
9
9
  // import * as planoMappingService from '../service/planoMapping.service.js';
10
10
  // import * as planoTaskService from '../service/planoTask.service.js';
11
- // import * as processedTaskService from '../service/processedTaskservice.js';
11
+ import * as processedTaskService from '../service/processedTaskservice.js';
12
12
  import * as planoproductCategoryService from '../service/planoproductCategory.service.js';
13
13
  import * as fixtureConfigService from '../service/fixtureConfig.service.js';
14
14
  import * as fixtureLibraryService from '../service/planoLibrary.service.js';
@@ -23,14 +23,12 @@ export async function getplanoFeedback( req, res ) {
23
23
  const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
24
24
  const resultMap = {};
25
25
  const commentMap = {};
26
- console.log( taskTypes );
27
26
  await Promise.all(
28
27
  taskTypes.map( async ( type, index ) => {
29
28
  const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
30
29
 
31
30
  let data = await planoTaskService.aggregate( pipeline );
32
31
  if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
33
- console.log( '-------------1', filterByApprovalStatus );
34
32
  data.forEach( ( element ) => {
35
33
  element.answers?.forEach( ( ans ) => {
36
34
  ans.issues = ans.issues?.filter(
@@ -73,7 +71,7 @@ export async function getplanoFeedback( req, res ) {
73
71
  return res.sendError( e, 500 );
74
72
  }
75
73
  }
76
- function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByApprovalStatus, showtask, taskId=0 ) {
74
+ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByApprovalStatus, showtask, taskId = 0 ) {
77
75
  console.log( type, planoId, floorId, filterByStatus );
78
76
  const matchStage = {
79
77
  $match: {
@@ -312,7 +310,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
312
310
  pipeline.push( { $sort: { _id: -1 } } );
313
311
  }
314
312
 
315
- console.log( pipeline );
313
+
316
314
  return pipeline;
317
315
  }
318
316
 
@@ -380,7 +378,6 @@ export async function getStoreFixturesfeedback( req, res ) {
380
378
 
381
379
 
382
380
  let findPlanoCompliance = await planoTaskService.aggregate( query );
383
- console.log( findPlanoCompliance.length );
384
381
  res.sendSuccess( { count: findPlanoCompliance.length, data: findPlanoCompliance } );
385
382
  } catch ( e ) {
386
383
  logger.error( { functionName: 'getplanoFeedbackFixture', error: e, message: req.body } );
@@ -541,8 +538,6 @@ export async function fixtureVMList( req, res ) {
541
538
  }
542
539
  export async function updateFixtureStatus( req, res ) {
543
540
  try {
544
- console.log( req.body );
545
-
546
541
  let comments = {
547
542
  userId: req.user._id,
548
543
  userName: req.user.userName,
@@ -550,7 +545,7 @@ export async function updateFixtureStatus( req, res ) {
550
545
  responsetype: req.body.type,
551
546
  comment: req.body.comments,
552
547
  };
553
- console.log( comments );
548
+
554
549
 
555
550
  let updateResponse = await planoTaskService.updateOnefilters(
556
551
  { _id: new mongoose.Types.ObjectId( req.body._id ) },
@@ -564,11 +559,8 @@ export async function updateFixtureStatus( req, res ) {
564
559
 
565
560
  ] );
566
561
  if ( updateResponse && updateResponse.answers.length > 0 ) {
567
- console.log( updateResponse.answers[0] );
568
562
  let findissuse = updateResponse.answers[0].issues.filter( ( data ) => data._id == req.body.issueId );
569
- console.log( findissuse );
570
563
  let findDetails = findissuse[0].Details.filter( ( det ) => det.status === 'agree' );
571
- console.log( '======', findDetails.length );
572
564
  if ( findissuse[0].Details.length === findDetails.length ) {
573
565
  await planoTaskService.updateOnefilters(
574
566
  { _id: new mongoose.Types.ObjectId( req.body._id ) },
@@ -581,9 +573,7 @@ export async function updateFixtureStatus( req, res ) {
581
573
  ] );
582
574
  }
583
575
  let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
584
- console.log( '************', findoneplanoData.answers[0].issues );
585
576
  let totalApproved = findoneplanoData.answers[0].issues.filter( ( data ) => data.status === 'pending' );
586
- console.log( '---------->', totalApproved.length );
587
577
  if ( totalApproved.length === 0 ) {
588
578
  await planoTaskService.updateOne(
589
579
  {
@@ -652,6 +642,17 @@ export async function updateFixtureStatus( req, res ) {
652
642
  }
653
643
  }
654
644
 
645
+ export async function updateApprovalStatus( req, res ) {
646
+ try {
647
+ await planoTaskService.updateOnefilters(
648
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
649
+ { $set: { approvalStatus: 'approved' } } );
650
+ res.sendSuccess( 'updated successfully' );
651
+ } catch ( e ) {
652
+ logger.error( { functionName: 'updateApprovalStatus', error: e } );
653
+ return res.sendError( e, 500 );
654
+ }
655
+ }
655
656
  export async function updateRolloutStatus( req, res ) {
656
657
  try {
657
658
  let comments = {
@@ -662,40 +663,95 @@ export async function updateRolloutStatus( req, res ) {
662
663
  comment: req.body.comments,
663
664
  };
664
665
 
665
- let updateResponse = await planoTaskService.updateOnefilters(
666
- { _id: new mongoose.Types.ObjectId( req.body._id ) },
667
- {
668
- $set: { 'answers.$[ans].issues.$[iss].Details.$[det].status': req.body.type },
669
- },
670
- [
671
- { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
672
- { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
673
- { 'det._id': new mongoose.Types.ObjectId( req.body.DetailsId ) },
674
-
675
- ] );
676
- if ( updateResponse && updateResponse.answers.length > 0 ) {
677
- let findissuse = updateResponse.answers[0].issues.filter( ( data ) => data._id == req.body.issueId );
678
- let findDetails = findissuse[0].Details.filter( ( det ) => det.status === 'agree' );
679
- if ( findissuse[0].Details.length === findDetails.length ) {
680
- await planoTaskService.updateOnefilters(
681
- { _id: new mongoose.Types.ObjectId( req.body._id ) },
682
- {
683
- $set: { 'answers.$[ans].issues.$[iss].status': 'completed' },
666
+ if ( req.body.issueId && req.body.DetailsId ) {
667
+ let updateResponse = await planoTaskService.updateOnefilters(
668
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
669
+ {
670
+ $set: {
671
+ 'answers.$[ans].issues.$[iss].Details.$[det].status': req.body.type,
672
+ 'answers.$[ans].issues.$[iss].Details.$[det].adminStatus': req.body.type === 'agree' ? 'approved' : 'Unapproved',
684
673
  },
685
- [
686
- { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
687
- { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
688
- ] );
674
+ },
675
+ [
676
+ { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
677
+ { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
678
+ { 'det._id': new mongoose.Types.ObjectId( req.body.DetailsId ) },
679
+
680
+ ],
681
+ );
682
+ if ( updateResponse && updateResponse.answers.length > 0 ) {
683
+ let findissuse = updateResponse.answers[0].issues.filter( ( data ) => data._id == req.body.issueId );
684
+ let findDetails = findissuse[0].Details.filter( ( det ) => det.status === 'agree' );
685
+ if ( findissuse[0].Details.length === findDetails.length ) {
686
+ await planoTaskService.updateOnefilters(
687
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
688
+ {
689
+ $set: { 'answers.$[ans].issues.$[iss].status': 'completed' },
690
+ },
691
+ [
692
+ { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
693
+ { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
694
+ ] );
695
+ }
696
+ let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
697
+ let totalApproved = findoneplanoData.answers[0].issues.filter( ( data ) => data.status === 'pending' );
698
+ if ( totalApproved.length === 0 ) {
699
+ await planoTaskService.updateOne(
700
+ {
701
+ _id: new mongoose.Types.ObjectId( req.body._id ),
702
+ },
703
+ {
704
+ 'status': 'complete',
705
+ 'approvalStatus': 'approved',
706
+ },
707
+ );
708
+ let data = {};
709
+ if ( req.body.taskType == 'vmRollout' ) {
710
+ data['isVmEdited'] = false;
711
+ } else {
712
+ data['isMerchEdited'] = false;
713
+ }
714
+ await storeFixtureService.updateOne( { _id: updateResponse.fixtureId }, data );
715
+ }
689
716
  }
690
- let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
691
- let totalApproved = findoneplanoData.answers[0].issues.filter( ( data ) => data.status === 'pending' );
692
- if ( totalApproved.length === 0 ) {
717
+ await planoTaskService.updateOnefilters(
718
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
719
+ {
720
+ $push: { 'answers.$[ans].issues.$[iss].comments': comments },
721
+ },
722
+ [
723
+ { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
724
+ { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
725
+ ],
726
+ );
727
+ } else {
728
+ let updateResponse = await planoTaskService.updateOnefilters(
729
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
730
+ {
731
+ $set: {
732
+ 'answers.$[ans].status': req.body.type,
733
+ },
734
+ },
735
+ [
736
+ { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
737
+ ],
738
+ );
739
+ await planoTaskService.updateOnefilters(
740
+ { _id: new mongoose.Types.ObjectId( req.body._id ) },
741
+ {
742
+ $push: { 'answers.$[ans].comments': comments },
743
+ },
744
+ [
745
+ { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
746
+ ],
747
+ );
748
+ if ( req.body.type == 'agree' ) {
693
749
  await planoTaskService.updateOne(
694
750
  {
695
751
  _id: new mongoose.Types.ObjectId( req.body._id ),
696
752
  },
697
753
  {
698
- 'status': 'complete',
754
+ 'approvalStatus': 'approved',
699
755
  },
700
756
  );
701
757
  let data = {};
@@ -707,15 +763,7 @@ export async function updateRolloutStatus( req, res ) {
707
763
  await storeFixtureService.updateOne( { _id: updateResponse.fixtureId }, data );
708
764
  }
709
765
  }
710
- await planoTaskService.updateOnefilters(
711
- { _id: new mongoose.Types.ObjectId( req.body._id ) },
712
- {
713
- $push: { 'answers.$[ans].issues.$[iss].comments': comments },
714
- },
715
- [
716
- { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
717
- { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
718
- ] );
766
+
719
767
  res.sendSuccess( 'updated successfully' );
720
768
  } catch ( e ) {
721
769
  logger.error( { functionName: 'updateFixtureStatus', error: e } );
@@ -742,11 +790,11 @@ export async function updateStoreFixture( req, res ) {
742
790
 
743
791
  if ( typeof shelf?.productPerShelf === 'number' ) {
744
792
  if ( shelf?.shelfType === 'shelf' ) {
745
- fixtureCapacity+=shelf.productPerShelf;
793
+ fixtureCapacity += shelf.productPerShelf;
746
794
  }
747
795
 
748
796
  if ( shelf?.shelfType === 'tray' ) {
749
- fixtureCapacity+=( shelf?.productPerShelf * shelf?.trayRows );
797
+ fixtureCapacity += ( shelf?.productPerShelf * shelf?.trayRows );
750
798
  }
751
799
  }
752
800
 
@@ -827,7 +875,6 @@ export async function updateStoreFixture( req, res ) {
827
875
 
828
876
  export async function updateredostatus( req, res ) {
829
877
  try {
830
- console.log( '------->', req.body );
831
878
  if ( req.body.type === 'layout' ) {
832
879
  await planoTaskService.updateOne(
833
880
  {
@@ -976,13 +1023,10 @@ export async function getRolloutFeedback( req, res ) {
976
1023
  const commentMap = {};
977
1024
  await Promise.all(
978
1025
  taskTypes.map( async ( type, index ) => {
979
- console.log( type );
980
1026
  const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask, req.body.taskId );
981
1027
 
982
1028
  let data = await planoTaskService.aggregate( pipeline );
983
- console.log( data );
984
1029
  if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
985
- console.log( '-------------1', filterByApprovalStatus );
986
1030
  data.forEach( ( element ) => {
987
1031
  element.answers?.forEach( ( ans ) => {
988
1032
  ans.issues = ans.issues?.filter(
@@ -1024,3 +1068,238 @@ export async function getRolloutFeedback( req, res ) {
1024
1068
  }
1025
1069
 
1026
1070
 
1071
+ export async function getRolloutFeedbackv2( req, res ) {
1072
+ try {
1073
+ const taskTypes = req.body.filterByTask && req.body.filterByTask.length > 0 ? req.body.filterByTask : [ 'merchRollout', 'vmRollout' ];
1074
+ const filterByStatus = req.body.filterByStatus || [];
1075
+ const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
1076
+ const resultMap = {};
1077
+ const commentMap = {};
1078
+ await Promise.all(
1079
+ taskTypes.map( async ( type, index ) => {
1080
+ const pipeline = pipelineStage( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
1081
+ const data = await processedTaskService.aggregate( pipeline );
1082
+ resultMap[type] = data;
1083
+ } ) );
1084
+ const response = {
1085
+ merchRolloutData: resultMap['merchRollout'] || [],
1086
+ vmRolloutData: resultMap['vmRollout'] || [],
1087
+ merchRolloutComment: commentMap['merchRollout'] || [],
1088
+ vmRolloutComment: commentMap['vmRollout'] || [],
1089
+ };
1090
+ res.sendSuccess( response );
1091
+ } catch ( e ) {
1092
+ logger.error( { functionName: 'getRolloutFeedbackv2', error: e } );
1093
+ return res.sendError( e, 500 );
1094
+ }
1095
+ }
1096
+
1097
+
1098
+ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApprovalStatus, showtask, taskId = 0 ) {
1099
+ let matchStage = [ {
1100
+ $match: {
1101
+ 'planoType': type,
1102
+ 'planoId': new mongoose.Types.ObjectId( planoId ),
1103
+ 'floorId': new mongoose.Types.ObjectId( floorId ),
1104
+ },
1105
+ },
1106
+
1107
+ {
1108
+ $project: {
1109
+ 'planoId': 1,
1110
+ 'floorId': 1,
1111
+ 'planoType': 1,
1112
+ 'userName': 1,
1113
+ 'date_string': 1,
1114
+ 'createdByName': 1,
1115
+ 'createdAt': 1,
1116
+ 'submitTime_string': 1,
1117
+ 'redoStatus': 1,
1118
+ 'checklistStatus': 1,
1119
+ },
1120
+ },
1121
+ ];
1122
+ let taskLookup = {
1123
+ $lookup: {
1124
+ from: 'planotaskcompliances',
1125
+ let: { taskId: '$_id' },
1126
+ pipeline: [
1127
+ {
1128
+ $match: {
1129
+ $expr: {
1130
+ $eq: [ '$taskId', '$$taskId' ],
1131
+ },
1132
+ },
1133
+ },
1134
+
1135
+ ],
1136
+ as: 'planoData',
1137
+ },
1138
+ };
1139
+ let unwindTask = {
1140
+ $unwind: {
1141
+ path: '$planoData',
1142
+ preserveNullAndEmptyArrays: true,
1143
+ },
1144
+ };
1145
+
1146
+
1147
+ const commonLookups = type === 'layout' ? [] : [
1148
+ {
1149
+ $lookup: {
1150
+ from: 'storefixtures',
1151
+ let: { fixtureId: '$planoData.fixtureId' },
1152
+ pipeline: [
1153
+ {
1154
+ $match: { $expr: { $eq: [ '$_id', '$$fixtureId' ] } },
1155
+ },
1156
+ ],
1157
+ as: 'FixtureData',
1158
+ },
1159
+ },
1160
+ {
1161
+ $unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
1162
+ },
1163
+ {
1164
+ $lookup: {
1165
+ from: 'fixtureshelves',
1166
+ let: { fixtureId: '$FixtureData._id' },
1167
+ pipeline: [
1168
+ {
1169
+ $match: { $expr: { $eq: [ '$fixtureId', '$$fixtureId' ] } },
1170
+ },
1171
+ ],
1172
+ as: 'Fixtureshelves',
1173
+ },
1174
+ },
1175
+
1176
+ {
1177
+ $set: {
1178
+ 'FixtureData.shelfConfig': '$Fixtureshelves',
1179
+ },
1180
+ },
1181
+ ];
1182
+
1183
+ const vmStages = [ 'vm', 'vmRollout' ].includes( type ) ? [
1184
+ {
1185
+ $unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
1186
+ },
1187
+ {
1188
+ $lookup: {
1189
+ from: 'planovmdetails',
1190
+ let: { vmId: '$FixtureData.vmConfig.vmId' },
1191
+ pipeline: [
1192
+ {
1193
+ $match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
1194
+ },
1195
+ {
1196
+ $project: { vmName: 1, vmType: 1 },
1197
+ },
1198
+ ],
1199
+ as: 'vmDetails',
1200
+ },
1201
+ },
1202
+ {
1203
+ $unwind: { path: '$vmDetails', preserveNullAndEmptyArrays: true },
1204
+ },
1205
+ {
1206
+ $set: {
1207
+ 'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
1208
+ 'FixtureData.vmConfig.vmType': '$vmDetails.vmType',
1209
+ },
1210
+ },
1211
+ {
1212
+ $group: {
1213
+ _id: {
1214
+ taskId: '$taskId',
1215
+ fixtureId: '$FixtureData._id',
1216
+ },
1217
+ rootDoc: { $first: '$$ROOT' },
1218
+ vmConfigs: { $push: '$FixtureData.vmConfig' },
1219
+ },
1220
+ },
1221
+ {
1222
+ $addFields: {
1223
+ 'rootDoc.FixtureData.vmConfig': '$vmConfigs',
1224
+ },
1225
+ },
1226
+ {
1227
+ $replaceRoot: { newRoot: '$rootDoc' },
1228
+ },
1229
+
1230
+
1231
+ ] : [];
1232
+ let finalGrouping = [
1233
+ {
1234
+ $group: {
1235
+ '_id': '$_id',
1236
+ 'planoId': { $first: '$planoId' },
1237
+ 'floorId': { $first: '$floorId' },
1238
+ 'planoType': { $first: '$planoType' },
1239
+ 'userName': { $first: '$userName' },
1240
+ 'date_string': { $first: '$date_string' },
1241
+ 'createdByName': { $first: '$createdByName' },
1242
+ 'createdAt': { $first: '$createdAt' },
1243
+ 'submitTime_string': { $first: '$submitTime_string' },
1244
+ 'redoStatus': { $first: '$redoStatus' },
1245
+ 'checklistStatus': { $first: '$checklistStatus' },
1246
+ 'storeFixtureList': {
1247
+ $push: {
1248
+ $cond: [
1249
+ {
1250
+ $and: [
1251
+ {
1252
+ $or: [
1253
+ { $eq: [ '$redoStatus', true ] },
1254
+ {
1255
+ $and: [
1256
+ { $eq: [ '$redoStatus', false ] },
1257
+ { $eq: [ '$checklistStatus', 'submit' ] },
1258
+ ],
1259
+ },
1260
+ ],
1261
+ },
1262
+ { $gt: [ { $size: { $ifNull: [ '$Fixtureshelves', [] ] } }, 0 ] },
1263
+ { $gt: [ { $size: { $ifNull: [ '$FixtureData.shelfConfig', [] ] } }, 0 ] },
1264
+ ],
1265
+ },
1266
+ {
1267
+ FixtureData: '$FixtureData',
1268
+ Fixtureshelves: '$Fixtureshelves',
1269
+ approvalStatus: '$planoData.approvalStatus',
1270
+ answers: '$planoData.answers',
1271
+ createdAt: '$planoData.createdAt',
1272
+ date_iso: '$planoData.date_iso',
1273
+ date_string: '$planoData.date_string',
1274
+ fixtureId: '$planoData.fixtureId',
1275
+ floorId: '$planoData.floorId',
1276
+ planoId: '$planoData.planoId',
1277
+ status: '$planoData.status',
1278
+ storeId: '$planoData.storeId',
1279
+ storeName: '$planoData.storeName',
1280
+ taskId: '$planoData.taskId',
1281
+ taskType: '$planoData.taskType',
1282
+ type: '$planoData.type',
1283
+ updatedAt: '$planoData.updatedAt',
1284
+ _id: '$planoData._id',
1285
+ },
1286
+ '$$REMOVE',
1287
+ ],
1288
+ },
1289
+ },
1290
+ },
1291
+ },
1292
+ ];
1293
+ let pipeline = [
1294
+ ...matchStage,
1295
+ taskLookup,
1296
+ unwindTask,
1297
+ ...commonLookups,
1298
+ ...vmStages,
1299
+ ...finalGrouping,
1300
+ { $sort: { _id: 1 } },
1301
+ ];
1302
+
1303
+ console.log( JSON.stringify( pipeline, 'pipeline' ) );
1304
+ return pipeline;
1305
+ }