tango-app-api-store-builder 1.0.0-beta-132 → 1.0.0-beta-134

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.
@@ -3013,7 +3013,7 @@ export async function storeFixturesTaskv2( req, res ) {
3013
3013
  const compliance = await planoTaskComplianceService.findOne( {
3014
3014
  fixtureId: fixture._id,
3015
3015
  type: req.body?.type ? req.body.type : 'fixture',
3016
- }, { status: 1, answers: 1 } );
3016
+ }, { status: 1, answers: 1, taskType: 1 } );
3017
3017
 
3018
3018
  const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
3019
3019
 
@@ -3048,8 +3048,7 @@ export async function storeFixturesTaskv2( req, res ) {
3048
3048
  issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3049
3049
  ),
3050
3050
  );
3051
-
3052
- if ( hasDisagree ) {
3051
+ if ( hasDisagree || compliance?.taskType == 'redo' ) {
3053
3052
  redoCount++;
3054
3053
  disabled = false;
3055
3054
  }
@@ -3108,7 +3107,7 @@ export async function storeFixturesTaskv2( req, res ) {
3108
3107
  const compliance = await planoTaskComplianceService.findOne( {
3109
3108
  fixtureId: fixture._id,
3110
3109
  type: req.body?.type ? req.body.type : 'fixture',
3111
- }, { status: 1 } );
3110
+ }, { status: 1, answers: 1, taskType: 1 } );
3112
3111
 
3113
3112
  const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
3114
3113
 
@@ -3143,7 +3142,7 @@ export async function storeFixturesTaskv2( req, res ) {
3143
3142
  ),
3144
3143
  );
3145
3144
 
3146
- if ( hasDisagree ) {
3145
+ if ( hasDisagree || compliance.taskType == 'redo' ) {
3147
3146
  redoCount++;
3148
3147
  disabled = false;
3149
3148
  }
@@ -3192,6 +3191,7 @@ export async function storeFixturesTaskv2( req, res ) {
3192
3191
  } ),
3193
3192
  );
3194
3193
 
3194
+
3195
3195
  return res.sendSuccess( storeLayout );
3196
3196
  } catch ( e ) {
3197
3197
  logger.error( { functionName: 'storeFixturesTask', error: e, message: req.body } );
@@ -3205,47 +3205,15 @@ export async function planoList( req, res ) {
3205
3205
  let limit = inputData?.limit || 10;
3206
3206
  let page = inputData?.offset - 1 || 0;
3207
3207
  let skip = limit * page;
3208
- let planoList = await planoService.find( { clientId: req.body.clientId }, { _id: 1 } );
3209
- let idList = planoList?.map( ( ele ) => new mongoose.Types.ObjectId( ele._id ) );
3210
- let taskQuery = [
3211
- {
3212
- $match: {
3213
- planoId: { $in: idList },
3214
- isPlano: true,
3215
- date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
3216
- },
3217
- },
3218
- {
3219
- $group: {
3220
- _id: { store: '$storeName', floorId: '$floorId', type: '$planoType' },
3221
- planoId: { $last: '$planoId' },
3222
- checklistStatus: { $last: '$checklistStatus' },
3223
- taskId: { $last: '$_id' },
3224
- },
3225
- },
3226
- {
3227
- $match: {
3228
- checklistStatus: 'submit',
3229
- },
3230
- },
3231
- {
3232
- $project: {
3233
- _id: 0,
3234
- type: '$_id.type',
3235
- planoId: 1,
3236
- checklistStatus: 1,
3237
- taskId: 1,
3238
- floorId: '$_id.floorId',
3239
- },
3240
- },
3241
- ];
3242
3208
 
3243
- let pendingDetails = await planotaskService.aggregate( taskQuery );
3244
- console.log( pendingDetails );
3209
+ let storeDetails = await storeService.find( { clientId: inputData.clientId, status: 'active' }, { storeId: 1 } );
3210
+ storeDetails = storeDetails.map( ( ele ) => ele.storeId );
3211
+
3245
3212
  let query = [
3246
3213
  {
3247
3214
  $match: {
3248
3215
  clientId: inputData.clientId,
3216
+ storeId: { $in: storeDetails },
3249
3217
  },
3250
3218
  },
3251
3219
  {
@@ -3353,7 +3321,7 @@ export async function planoList( req, res ) {
3353
3321
  $expr: {
3354
3322
  $and: [
3355
3323
  { $eq: [ '$planoId', '$$plano' ] },
3356
- { $in: [ '$taskId', pendingDetails.map( ( ele ) => ele.taskId ) ] },
3324
+ // { $in: [ '$taskId', pendingDetails.map( ( ele ) => ele.taskId ) ] },
3357
3325
  { $eq: [ '$taskType', 'initial' ] },
3358
3326
  ],
3359
3327
  },
@@ -3361,182 +3329,66 @@ export async function planoList( req, res ) {
3361
3329
  },
3362
3330
  { $sort: { _id: -1 } },
3363
3331
  {
3364
- $group: {
3365
- _id: '$floorId',
3366
- layoutCount: {
3367
- $sum: {
3368
- $cond: {
3369
- if: {
3370
- $and: [
3371
- { $eq: [ '$type', 'layout' ] },
3372
- ],
3332
+ $set: {
3333
+ hasPendingIssues: {
3334
+ $anyElementTrue: {
3335
+ $map: {
3336
+ input: {
3337
+ $reduce: {
3338
+ input: '$answers',
3339
+ initialValue: [],
3340
+ in: {
3341
+ $concatArrays: [
3342
+ '$$value',
3343
+ { $ifNull: [ '$$this.issues', [] ] },
3344
+ ],
3345
+ },
3346
+ },
3373
3347
  },
3374
- then: 1,
3375
- else: 0,
3348
+ as: 'issue',
3349
+ in: { $eq: [ '$$issue.status', 'pending' ] },
3376
3350
  },
3377
3351
  },
3378
3352
  },
3353
+ },
3354
+ },
3355
+ {
3356
+ $group: {
3357
+ _id: '$floorId',
3358
+ layoutCount: {
3359
+ $sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
3360
+ },
3379
3361
  fixtureCount: {
3380
- $sum: {
3381
- $cond: {
3382
- if: {
3383
- $and: [
3384
- {
3385
- $eq: [ '$type', 'fixture' ],
3386
- },
3387
- ],
3388
- },
3389
- then: 1,
3390
- else: 0,
3391
- },
3392
- },
3362
+ $sum: { $cond: [ { $eq: [ '$type', 'fixture' ] }, 1, 0 ] },
3393
3363
  },
3394
3364
  vmCount: {
3395
- $sum: {
3396
- $cond: {
3397
- if: {
3398
- $and: [
3399
- { $eq: [ '$type', 'vm' ] },
3400
- ],
3401
- },
3402
- then: 1,
3403
- else: 0,
3404
- },
3405
- },
3365
+ $sum: { $cond: [ { $eq: [ '$type', 'vm' ] }, 1, 0 ] },
3406
3366
  },
3407
3367
  layoutPending: {
3408
3368
  $sum: {
3409
- $cond: {
3410
- if: {
3411
- $and: [
3412
- {
3413
- $eq: [ '$type', 'layout' ],
3414
- },
3415
- {
3416
- $anyElementTrue: {
3417
- $map: {
3418
- input: {
3419
- $reduce: {
3420
- input: '$answers',
3421
- initialValue: [],
3422
- in: {
3423
- $concatArrays: [
3424
- '$$value',
3425
- {
3426
- $ifNull: [
3427
- '$$this.issues',
3428
- [],
3429
- ],
3430
- },
3431
- ],
3432
- },
3433
- },
3434
- },
3435
- as: 'issue',
3436
- in: {
3437
- $eq: [
3438
- '$$issue.status',
3439
- 'pending',
3440
- ],
3441
- },
3442
- },
3443
- },
3444
- },
3445
- ],
3446
- },
3447
- then: 1,
3448
- else: 0,
3449
- },
3369
+ $cond: [
3370
+ { $and: [ { $eq: [ '$type', 'layout' ] }, '$hasPendingIssues' ] },
3371
+ 1,
3372
+ 0,
3373
+ ],
3450
3374
  },
3451
3375
  },
3452
3376
  fixturePending: {
3453
3377
  $sum: {
3454
- $cond: {
3455
- if: {
3456
- $and: [
3457
- {
3458
- $eq: [ '$type', 'fixture' ],
3459
- },
3460
- {
3461
- $anyElementTrue: {
3462
- $map: {
3463
- input: {
3464
- $reduce: {
3465
- input: '$answers',
3466
- initialValue: [],
3467
- in: {
3468
- $concatArrays: [
3469
- '$$value',
3470
- {
3471
- $ifNull: [
3472
- '$$this.issues',
3473
- [],
3474
- ],
3475
- },
3476
- ],
3477
- },
3478
- },
3479
- },
3480
- as: 'issue',
3481
- in: {
3482
- $eq: [
3483
- '$$issue.status',
3484
- 'pending',
3485
- ],
3486
- },
3487
- },
3488
- },
3489
- },
3490
- ],
3491
- },
3492
- then: 1,
3493
- else: 0,
3494
- },
3378
+ $cond: [
3379
+ { $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasPendingIssues' ] },
3380
+ 1,
3381
+ 0,
3382
+ ],
3495
3383
  },
3496
3384
  },
3497
3385
  vmPending: {
3498
3386
  $sum: {
3499
- $cond: {
3500
- if: {
3501
- $and: [
3502
- {
3503
- $eq: [ '$type', 'vm' ],
3504
- },
3505
- {
3506
- $anyElementTrue: {
3507
- $map: {
3508
- input: {
3509
- $reduce: {
3510
- input: '$answers',
3511
- initialValue: [],
3512
- in: {
3513
- $concatArrays: [
3514
- '$$value',
3515
- {
3516
- $ifNull: [
3517
- '$$this.issues',
3518
- [],
3519
- ],
3520
- },
3521
- ],
3522
- },
3523
- },
3524
- },
3525
- as: 'issue',
3526
- in: {
3527
- $eq: [
3528
- '$$issue.status',
3529
- 'pending',
3530
- ],
3531
- },
3532
- },
3533
- },
3534
- },
3535
- ],
3536
- },
3537
- then: 1,
3538
- else: 0,
3539
- },
3387
+ $cond: [
3388
+ { $and: [ { $eq: [ '$type', 'vm' ] }, '$hasPendingIssues' ] },
3389
+ 1,
3390
+ 0,
3391
+ ],
3540
3392
  },
3541
3393
  },
3542
3394
  },
@@ -3764,6 +3616,7 @@ export async function planoList( req, res ) {
3764
3616
  } );
3765
3617
  }
3766
3618
 
3619
+
3767
3620
  query.push( {
3768
3621
  $facet: {
3769
3622
  data: [
@@ -3773,6 +3626,20 @@ export async function planoList( req, res ) {
3773
3626
  count: [
3774
3627
  { $count: 'total' },
3775
3628
  ],
3629
+ planoList: [
3630
+ {
3631
+ $group: {
3632
+ _id: '',
3633
+ idList: { $addToSet: '$_id' },
3634
+ },
3635
+ },
3636
+ {
3637
+ $project: {
3638
+ _id: 0,
3639
+ idList: 1,
3640
+ },
3641
+ },
3642
+ ],
3776
3643
  },
3777
3644
  } );
3778
3645
 
@@ -3782,149 +3649,100 @@ export async function planoList( req, res ) {
3782
3649
  return res.sendError( 'No data found', 204 );
3783
3650
  }
3784
3651
 
3785
- query = [
3652
+ let taskQuery = [
3653
+ {
3654
+ $match: {
3655
+ planoId: { $in: planoDetails?.[0]?.planoList?.[0]?.idList },
3656
+ isPlano: true,
3657
+ date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
3658
+ },
3659
+ },
3660
+ {
3661
+ $group: {
3662
+ _id: { store: '$storeName', floorId: '$floorId', type: '$planoType' },
3663
+ planoId: { $last: '$planoId' },
3664
+ checklistStatus: { $last: '$checklistStatus' },
3665
+ taskId: { $last: '$_id' },
3666
+ },
3667
+ },
3668
+ {
3669
+ $match: {
3670
+ checklistStatus: 'submit',
3671
+ },
3672
+ },
3673
+ {
3674
+ $project: {
3675
+ _id: 0,
3676
+ type: '$_id.type',
3677
+ planoId: 1,
3678
+ checklistStatus: 1,
3679
+ taskId: 1,
3680
+ floorId: '$_id.floorId',
3681
+ },
3682
+ },
3683
+ ];
3684
+
3685
+ let pendingDetails = await planotaskService.aggregate( taskQuery );
3686
+
3687
+ taskQuery = [
3786
3688
  {
3787
3689
  $match: {
3788
3690
  taskId: { $in: pendingDetails.map( ( ele ) => ele.taskId ) },
3789
3691
  taskType: 'initial',
3790
3692
  },
3791
3693
  },
3694
+ {
3695
+ $set: {
3696
+ hasPendingIssues: {
3697
+ $anyElementTrue: {
3698
+ $map: {
3699
+ input: {
3700
+ $reduce: {
3701
+ input: '$answers',
3702
+ initialValue: [],
3703
+ in: {
3704
+ $concatArrays: [
3705
+ '$$value',
3706
+ { $ifNull: [ '$$this.issues', [] ] },
3707
+ ],
3708
+ },
3709
+ },
3710
+ },
3711
+ as: 'issue',
3712
+ in: { $eq: [ '$$issue.status', 'pending' ] },
3713
+ },
3714
+ },
3715
+ },
3716
+ },
3717
+ },
3792
3718
  {
3793
3719
  $group: {
3794
3720
  _id: { type: '$type', planoId: '$planoId' },
3795
3721
  layoutPending: {
3796
3722
  $sum: {
3797
- $cond: {
3798
- if: {
3799
- $and: [
3800
- {
3801
- $eq: [ '$type', 'layout' ],
3802
- },
3803
- {
3804
- $anyElementTrue: {
3805
- $map: {
3806
- input: {
3807
- $reduce: {
3808
- input: '$answers',
3809
- initialValue: [],
3810
- in: {
3811
- $concatArrays: [
3812
- '$$value',
3813
- {
3814
- $ifNull: [
3815
- '$$this.issues',
3816
- [],
3817
- ],
3818
- },
3819
- ],
3820
- },
3821
- },
3822
- },
3823
- as: 'issue',
3824
- in: {
3825
- $eq: [
3826
- '$$issue.status',
3827
- 'pending',
3828
- ],
3829
- },
3830
- },
3831
- },
3832
- },
3833
- ],
3834
- },
3835
- then: 1,
3836
- else: 0,
3837
- },
3723
+ $cond: [
3724
+ { $and: [ { $eq: [ '$type', 'layout' ] }, '$hasPendingIssues' ] },
3725
+ 1,
3726
+ 0,
3727
+ ],
3838
3728
  },
3839
3729
  },
3840
3730
  fixturePending: {
3841
3731
  $sum: {
3842
- $cond: {
3843
- if: {
3844
- $and: [
3845
- {
3846
- $eq: [ '$type', 'fixture' ],
3847
- },
3848
- {
3849
- $anyElementTrue: {
3850
- $map: {
3851
- input: {
3852
- $reduce: {
3853
- input: '$answers',
3854
- initialValue: [],
3855
- in: {
3856
- $concatArrays: [
3857
- '$$value',
3858
- {
3859
- $ifNull: [
3860
- '$$this.issues',
3861
- [],
3862
- ],
3863
- },
3864
- ],
3865
- },
3866
- },
3867
- },
3868
- as: 'issue',
3869
- in: {
3870
- $eq: [
3871
- '$$issue.status',
3872
- 'pending',
3873
- ],
3874
- },
3875
- },
3876
- },
3877
- },
3878
- ],
3879
- },
3880
- then: 1,
3881
- else: 0,
3882
- },
3732
+ $cond: [
3733
+ { $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasPendingIssues' ] },
3734
+ 1,
3735
+ 0,
3736
+ ],
3883
3737
  },
3884
3738
  },
3885
3739
  vmPending: {
3886
3740
  $sum: {
3887
- $cond: {
3888
- if: {
3889
- $and: [
3890
- {
3891
- $eq: [ '$type', 'vm' ],
3892
- },
3893
- {
3894
- $anyElementTrue: {
3895
- $map: {
3896
- input: {
3897
- $reduce: {
3898
- input: '$answers',
3899
- initialValue: [],
3900
- in: {
3901
- $concatArrays: [
3902
- '$$value',
3903
- {
3904
- $ifNull: [
3905
- '$$this.issues',
3906
- [],
3907
- ],
3908
- },
3909
- ],
3910
- },
3911
- },
3912
- },
3913
- as: 'issue',
3914
- in: {
3915
- $eq: [
3916
- '$$issue.status',
3917
- 'pending',
3918
- ],
3919
- },
3920
- },
3921
- },
3922
- },
3923
- ],
3924
- },
3925
- then: 1,
3926
- else: 0,
3927
- },
3741
+ $cond: [
3742
+ { $and: [ { $eq: [ '$type', 'vm' ] }, '$hasPendingIssues' ] },
3743
+ 1,
3744
+ 0,
3745
+ ],
3928
3746
  },
3929
3747
  },
3930
3748
  },
@@ -3975,11 +3793,10 @@ export async function planoList( req, res ) {
3975
3793
  let result = {
3976
3794
  data: planoDetails[0].data,
3977
3795
  count: planoDetails?.[0]?.count?.[0]?.total || 0,
3978
- pendingDetails: [ { ...pendingDetails?.[0], allStores: planoList?.length || 0 } ],
3796
+ pendingDetails: [ { ...pendingDetails?.[0], allStores: planoDetails?.[0]?.count?.[0]?.total || 0 } ],
3979
3797
  };
3980
3798
  return res.sendSuccess( result );
3981
3799
  } catch ( e ) {
3982
- console.log( e );
3983
3800
  logger.error( { functionName: 'planoList', error: e } );
3984
3801
  return res.sendError( e, 500 );
3985
3802
  }
@@ -13,5 +13,6 @@ fixtureTemplateRouter
13
13
  .post( '/duplicateTemplate', validate( validateDtos.templateId ), fixtureTemplateController.duplicateTemplate )
14
14
  .post( '/getTemplateList', validate( validateDtos.fixtureVMListSchema ), fixtureTemplateController.getTemplateList )
15
15
  .get( '/getTemplateDetails', validate( validateDtos.queryTemplateId ), fixtureTemplateController.getTemplateDetails )
16
- .post( '/updateFixtureTask', validate( validateDtos.updateFixtureTask ), fixtureTemplateController.updateFixtureTask );
16
+ .post( '/updateFixtureTask', validate( validateDtos.updateFixtureTask ), fixtureTemplateController.updateFixtureTask )
17
+ .post( '/getAllTemplates', fixtureTemplateController.getAllTemplates );
17
18
 
@@ -15,4 +15,9 @@ managePlanoRouter
15
15
  .get( '/fixtureVMList', managePlanoController.fixtureVMList )
16
16
  .post( '/updateFixtureStatus', isAllowedSessionHandler, managePlanoController.updateFixtureStatus )
17
17
  .post( '/updateStoreFixture', managePlanoController.updateStoreFixture )
18
- .post( '/updateredostatus', managePlanoController.updateredostatus );
18
+ .post( '/updateredostatus', managePlanoController.updateredostatus )
19
+ .post( '/updateGlobalComment', isAllowedSessionHandler, managePlanoController.updateGlobalComment )
20
+ .post( '/getGlobalComment', isAllowedSessionHandler, managePlanoController.getGlobalComment )
21
+ .post( '/createRevision', managePlanoController.createPlanoRevision )
22
+ .post( '/getRevisions', managePlanoController.getAllPlanoRevisions )
23
+ .post( '/getRevisionData', managePlanoController.getPlanoRevisionById );
@@ -0,0 +1,25 @@
1
+ import model from 'tango-api-schema';
2
+
3
+ export async function create( data ) {
4
+ return model.planoGlobalComment.create( data );
5
+ }
6
+
7
+ export async function findOne( query = {}, field = {} ) {
8
+ return model.planoGlobalComment.findOne( query, field );
9
+ }
10
+
11
+ export async function updateOne( query = {}, record = {} ) {
12
+ return model.planoGlobalComment.updateOne( query, { $set: record }, { upsert: true } );
13
+ }
14
+
15
+ export async function deleteMany( query = {} ) {
16
+ return model.planoGlobalComment.deleteMany( query );
17
+ }
18
+
19
+ export async function aggregate( query = {} ) {
20
+ return model.planoGlobalComment.aggregate( query );
21
+ }
22
+
23
+ export async function find( query = {}, field = {} ) {
24
+ return model.planoGlobalComment.find( query, field );
25
+ }
@@ -35,3 +35,11 @@ export const create = async ( data = {} ) => {
35
35
  export const aggregate = async ( query=[] ) => {
36
36
  return await model.fixtureLibraryModel.aggregate( query );
37
37
  };
38
+
39
+ export async function upsertOne( query, record ) {
40
+ return model.fixtureLibraryModel.findOneAndUpdate(
41
+ query,
42
+ record,
43
+ { upsert: true, new: true },
44
+ );
45
+ }
@@ -0,0 +1,15 @@
1
+ import model from 'tango-api-schema';
2
+
3
+ const planoRevisionModel = model.planoRevisionModel;
4
+
5
+ export const findOne = async ( query = {}, field = {} ) => {
6
+ return await planoRevisionModel.findOne( query, field );
7
+ };
8
+
9
+ export const find = async ( query = {}, field = {} ) => {
10
+ return await planoRevisionModel.find( query, field );
11
+ };
12
+
13
+ export const create = async ( data = {} ) => {
14
+ return await planoRevisionModel.create( data );
15
+ };
@@ -20,6 +20,11 @@ export async function updateOne( query, record ) {
20
20
  return model.storeFixtureModel.updateOne( query, { $set: record } );
21
21
  }
22
22
 
23
+ export async function updateMany( query, record ) {
24
+ console.log( record, 'record' );
25
+ return model.storeFixtureModel.updateMany( query, { $set: record } );
26
+ }
27
+
23
28
  export async function findOneAndUpdate( query={}, field={} ) {
24
29
  return model.storeFixtureModel.findOneAndUpdate( query, field );
25
30
  }