tango-app-api-store-builder 1.0.0-beta-224 → 1.0.0-beta-225

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-224",
3
+ "version": "1.0.0-beta-225",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3322,7 +3322,7 @@ export async function storeFixturesv3( req, res ) {
3322
3322
  export async function fixtureShelfProductv2( req, res ) {
3323
3323
  try {
3324
3324
  const { planoId, fixtureId } = req.body;
3325
- let shelfMapping = [];
3325
+ let shelfMapping = {};
3326
3326
 
3327
3327
  const [ planogram, fixture ] = await Promise.all( [
3328
3328
  planoService.findOne(
@@ -3335,27 +3335,28 @@ export async function fixtureShelfProductv2( req, res ) {
3335
3335
  if ( !planogram ) return res.sendError( 'Planogram not found', 204 );
3336
3336
  if ( !fixture ) return res.sendError( 'Fixture not found', 204 );
3337
3337
 
3338
+ if ( req.body?.compliance ) {
3339
+ let getAllFixtures = await fixtureShelfService.find( { planoId: fixture.planoId, floorId: fixture.floorId, fixtureId: { $ne: fixtureId } } );
3338
3340
 
3339
- let getAllFixtures = await fixtureShelfService.find( { planoId: fixture.planoId, floorId: fixture.floorId, fixtureId: { $ne: fixtureId } } );
3340
-
3341
- shelfMapping = getAllFixtures.reduce( ( acc, ele ) => {
3342
- let productList = ele.productBrandName?.toString()?.toLowerCase();
3343
- if ( !acc?.[productList] ) {
3344
- let findZone = acc?.[productList]?.find( ( prod ) => prod.zone == ele.zone && prod.shelfId.toString() == ele._id.toString() );
3345
- if ( !findZone ) {
3346
- acc[productList] = [
3347
- {
3348
- zone: ele.zone,
3349
- shelfId: ele._id,
3350
- fixtureId: ele.fixtureId,
3351
- fixtureName: fixture.fixtureName,
3352
- brandName: ele.productBrandName,
3353
- },
3354
- ];
3341
+ shelfMapping = getAllFixtures.reduce( ( acc, ele ) => {
3342
+ let productList = ele.productBrandName?.toString()?.toLowerCase();
3343
+ if ( !acc?.[productList] ) {
3344
+ let findZone = acc?.[productList]?.find( ( prod ) => prod.zone == ele.zone && prod.shelfId.toString() == ele._id.toString() );
3345
+ if ( !findZone ) {
3346
+ acc[productList] = [
3347
+ {
3348
+ zone: ele.zone,
3349
+ shelfId: ele._id,
3350
+ fixtureId: ele.fixtureId,
3351
+ fixtureName: fixture.fixtureName,
3352
+ brandName: ele.productBrandName,
3353
+ },
3354
+ ];
3355
+ }
3355
3356
  }
3356
- }
3357
- return acc;
3358
- }, {} );
3357
+ return acc;
3358
+ }, {} );
3359
+ }
3359
3360
 
3360
3361
 
3361
3362
  const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
@@ -3408,13 +3409,15 @@ export async function fixtureShelfProductv2( req, res ) {
3408
3409
  fixtureShelves.map( async ( shelf ) => {
3409
3410
  const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
3410
3411
  const productDetails = await getProducts( productMappings );
3411
- let count = shelf.shelfType == 'tray' ? ( shelf.productPerShelf * shelf.trayRows ) : shelf.productPerShelf;
3412
- if ( count > productMappings.length ) {
3413
- let extraProduct = count- productMappings.length;
3414
- for ( let i=0; i<extraProduct; i++ ) {
3415
- productDetails.unshift( {
3416
- status: 'missing',
3417
- } );
3412
+ if ( req.body?.compliance ) {
3413
+ let count = shelf.shelfType == 'tray' ? ( shelf.productPerShelf * shelf.trayRows ) : shelf.productPerShelf;
3414
+ if ( count > productMappings.length ) {
3415
+ let extraProduct = count- productMappings.length;
3416
+ for ( let i=0; i<extraProduct; i++ ) {
3417
+ productDetails.unshift( {
3418
+ status: 'missing',
3419
+ } );
3420
+ }
3418
3421
  }
3419
3422
  }
3420
3423
  return { ...shelf.toObject(), products: productDetails };
@@ -3576,14 +3579,14 @@ export async function storeFixturesTaskv2( req, res ) {
3576
3579
  let productIdList = productDetails.map( ( ele ) => ele._id );
3577
3580
  let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
3578
3581
  status = status.map( ( ele ) => ele?.compliance );
3579
- const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
3582
+ const productCompliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
3580
3583
  const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
3581
3584
 
3582
3585
  return {
3583
3586
  ...shelf.toObject(),
3584
3587
  productCount: productDetails.length,
3585
3588
  vmCount: vmCount,
3586
- compliance,
3589
+ compliance: productCompliance,
3587
3590
  };
3588
3591
  } ),
3589
3592
  );
@@ -3625,6 +3628,7 @@ export async function storeFixturesTaskv2( req, res ) {
3625
3628
  shelfConfig: shelfDetails,
3626
3629
  vmConfig: vmDetails,
3627
3630
  ...( req.body.type == 'fixtureMeasurement' && { fixtureMeasurement: compliance.answers?.[0]?.fixtureWidth } ),
3631
+ ...( ( compliance?.answers?.[0]?.status && req.body.type == 'fixture' && req.body.redo ) && { ansStatus: true } ),
3628
3632
  };
3629
3633
  } ),
3630
3634
  );
@@ -3685,12 +3689,12 @@ export async function storeFixturesTaskv2( req, res ) {
3685
3689
  let productIdList = productDetails.map( ( ele ) => ele._id );
3686
3690
  let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
3687
3691
  status = status.map( ( ele ) => ele?.compliance );
3688
- const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
3692
+ let productCompliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
3689
3693
  return {
3690
3694
  ...shelf.toObject(),
3691
3695
  productCount: productDetails.length,
3692
3696
  vmCount: vmCount,
3693
- compliance,
3697
+ compliance: productCompliance,
3694
3698
  };
3695
3699
  } ),
3696
3700
  );
@@ -3732,6 +3736,7 @@ export async function storeFixturesTaskv2( req, res ) {
3732
3736
  shelfConfig: shelfDetails,
3733
3737
  vmConfig: vmDetails,
3734
3738
  ...( req.body.type == 'fixtureMeasurement' && { fixtureMeasurement: compliance.answers?.[0]?.fixtureWidth } ),
3739
+ ...( ( compliance?.answers?.[0]?.status && req.body.type == 'fixture' && req.body.redo ) && { ansStatus: true } ),
3735
3740
  };
3736
3741
  } ),
3737
3742
  );
@@ -5254,7 +5259,15 @@ export async function planoList( req, res ) {
5254
5259
 
5255
5260
  if ( inputData.filter.status.length ) {
5256
5261
  if ( inputData.filter.status.includes( 'taskAssigned' ) ) {
5257
- orQuery.push( { 'planoTask.taskStatus.status': { $in: [ 'open', 'inprogress' ] } } );
5262
+ // orQuery.push( { 'planoTask.taskStatus.status': { $in: [ 'open', 'inprogress' ] } } );
5263
+ orQuery.push( {
5264
+ 'planoTask.taskStatus': {
5265
+ $elemMatch: {
5266
+ status: { $ne: 'submit' },
5267
+ breach: false,
5268
+ },
5269
+ },
5270
+ } );
5258
5271
  }
5259
5272
  if ( inputData.filter.status.includes( 'reviewPending' ) ) {
5260
5273
  orQuery.push( {
@@ -59,6 +59,7 @@ export const fixtureShelfProductSchema = joi.object( {
59
59
  fixtureId: joi.string().required(),
60
60
  floorId: joi.string().required(),
61
61
  planoId: joi.string().required(),
62
+ compliance: joi.boolean().optional(),
62
63
  } );
63
64
 
64
65
  export const fixtureShelfProduct = {
@@ -45,10 +45,10 @@ storeBuilderRouter
45
45
  .post( '/storeLayoutElements', isAllowedSessionHandler, storeBuilderController.storeLayoutElements )
46
46
  .post( '/qrScan', isAllowedSessionHandler, storeBuilderController.qrScan )
47
47
  .post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
48
- .post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
49
- .post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 )
48
+ // .post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
49
+ // .post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 )
50
50
  .post( '/qrScan1', isAllowedSessionHandler, storeBuilderController.qrScan1 )
51
- .post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
51
+ // .post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
52
52
  .post( '/storeFixturesV3', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv3 )
53
53
  .post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
54
54
  .post( '/fixtureShelfDetailsv3', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv3 )