tango-app-api-store-builder 1.0.0-beta-7 → 1.0.0-beta-9

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-7",
3
+ "version": "1.0.0-beta-9",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -374,7 +374,7 @@ export async function getStoreDetails( req, res ) {
374
374
  }
375
375
  }
376
376
 
377
- export async function storeList( req, res ) {
377
+ export async function storeLayout( req, res ) {
378
378
  try {
379
379
  let idList = req.body.id.map( ( item ) => new mongoose.Types.ObjectId( item ) );
380
380
  let query = { _id: { $in: req.body.id } };
@@ -560,44 +560,39 @@ export async function fixtureShelfProduct( req, res ) {
560
560
  if ( !fixtureDetails ) {
561
561
  return res.sendError( 'Fixture not found', 204 );
562
562
  }
563
- let planoDetails = await planoService.findOne( { _id: fixtureDetails.planoId } );
563
+ // let planoDetails = await planoService.findOne( { _id: fixtureDetails.planoId } );
564
564
  let shelfDetails = await fixtureShelfService.find( { fixtureId: req.body.fixtureId } );
565
- let query;
566
- switch ( planoDetails.productResolutionLevel ) {
567
- case 'L1':
568
- query = { floorId: fixtureDetails.floorId };
569
- break;
570
- default:
571
- query = { floorId: fixtureDetails.floorId, fixtureId: req.body.fixtureId };
572
- break;
573
- }
565
+ // let query;
566
+ // switch ( planoDetails.productResolutionLevel ) {
567
+ // case 'L1':
568
+ // query = { floorId: fixtureDetails.floorId };
569
+ // break;
570
+ // default:
571
+ // query = { floorId: fixtureDetails.floorId, fixtureId: req.body.fixtureId };
572
+ // break;
573
+ // }
574
+ // query = {
575
+ // ...query,
576
+ // ...( [ 'L3', 'L4' ].includes( planoDetails.productResolutionLevel ) ) ? { shelfId: shelf._id } : {},
577
+ // productId: { $in: productIdList },
578
+ // date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
579
+ // };
574
580
  let shelfList = [];
575
581
  for ( let shelf of shelfDetails ) {
576
582
  let data = { ...shelf._doc, products: [] };
577
583
  let productMappingDetails = await planoMappingService.find( { shelfId: shelf._id } );
578
584
  let productIdList = productMappingDetails.map( ( item ) => item.productId );
579
585
  let productDetails = await planoProductService.find( { _id: productIdList } );
580
- query = {
581
- ...query,
582
- ...( [ 'L3', 'L4' ].includes( planoDetails.productResolutionLevel ) ) ? { shelfId: shelf._id } : {},
583
- productId: { $in: productIdList },
584
- date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
585
- };
586
- let productComplianceDetails = await planoComplianceService.find( query );
586
+ let productComplianceDetails = await planoComplianceService.find( { date: new Date( dayjs().format( 'YYYY-MM-DD' ) ), shelfId: shelf._id } );
587
587
  let product = [];
588
588
  productDetails.forEach( ( item ) => {
589
- let data = { ...item._doc, status: 'missing' };
589
+ let data = { ...item._doc, status: 'missing', rfId: '' };
590
590
  let getPosition = productMappingDetails.find( ( ele ) => ele.productId.toString() == item._id.toString() );
591
- let findCompliance = productComplianceDetails.find( ( ele ) => {
592
- if ( planoDetails.productResolutionLevel == 'L4' && getPosition ) {
593
- return ( item._id.toString() == ele.productId.toString() && ele.shelfPosition == getPosition.shelfPosition );
594
- } else {
595
- return ( item._id.toString() == ele.productId.toString() );
596
- }
597
- } );
591
+ let findCompliance = productComplianceDetails.find( ( ele ) => ele.shelfPosition == getPosition.shelfPosition );
598
592
  if ( findCompliance ) {
599
593
  data.status = findCompliance.compliance;
600
594
  }
595
+ data.rfId = getPosition.rfId;
601
596
  product.push( data );
602
597
  } );
603
598
  data.products = product;
@@ -613,6 +608,7 @@ export async function fixtureShelfProduct( req, res ) {
613
608
 
614
609
  export async function scan( req, res ) {
615
610
  try {
611
+ let shelfId;
616
612
  if ( !req.body.planoId ) {
617
613
  return res.sendError( 'Plano id is required', 400 );
618
614
  }
@@ -637,7 +633,11 @@ export async function scan( req, res ) {
637
633
  if ( !shelfDetails ) {
638
634
  return res.sendError( 'No data found', 204 );
639
635
  }
636
+ if ( shelfDetails.shelfCapacity < req.body.shelfPosition ) {
637
+ return res.sendError( 'Shelf capacity exceeded', 400 );
638
+ }
640
639
  shelfDetails = await fixtureShelfService.find( { sectionName: shelfDetails?.sectionName } );
640
+ shelfId = req.body.shelfId;
641
641
  req.body.shelfId = shelfDetails.map( ( ele ) => ele._id );
642
642
  }
643
643
  let productCheck= await planoMappingService.findOne( { rfId: req.body.rfId } );
@@ -705,16 +705,17 @@ export async function scan( req, res ) {
705
705
  break;
706
706
  }
707
707
  query = { ...query, rfId: req.body.rfId };
708
+ console.log( query );
708
709
 
709
710
  let planoProductDetails = await planoMappingService.findOne( query );
710
711
  let data = {
711
- ...( planoProductDetails ) ? { ...planoProductDetails._doc } : { planoId: req.body?.planoId, floorId: req.body?.floorId, fixtureId: req.body?.fixtureId, shelfId: req.body?.shelfId, clientId: planoDetails.clientId, storeName: planoDetails.storeName, storeId: planoDetails.storeId, shelfPosition: req.body?.shelfPosition },
712
+ ...( planoProductDetails ) ? { ...planoProductDetails._doc } : { planoId: req.body?.planoId, floorId: req.body?.floorId, fixtureId: req.body?.fixtureId, shelfId: shelfId, clientId: planoDetails.clientId, storeName: planoDetails.storeName, storeId: planoDetails.storeId, shelfPosition: req.body?.shelfPosition },
712
713
  rfId: req.body.rfId,
713
714
  compliance: !planoProductDetails ? 'misplaced' : 'proper',
714
715
  date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
715
716
  };
716
717
  delete data._id;
717
- query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ) };
718
+ query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ), shelfPosition: planoProductDetails?.shelfPosition || req.body.shelfPosition };
718
719
  await planoComplianceService.updateOne( query, data );
719
720
  if ( !planoProductDetails ) {
720
721
  return res.sendSuccess( false );
@@ -12,7 +12,7 @@ storeBuilderRouter
12
12
  .post( '/updateFloor', isAllowedSessionHandler, validate( validateDtos.updateFloor ), storeBuilderController.updateFloor )
13
13
  .post( '/uploadBulkStore', isAllowedSessionHandler, storeBuilderController.uploadBulkStore )
14
14
  .post( '/uploadFile', isAllowedSessionHandler, storeBuilderController.uploadFile )
15
- .post( '/storeList', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeList )
15
+ .post( '/storeLayout', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeLayout )
16
16
  .post( '/storeDetails', isAllowedSessionHandler, validate( validateDtos.storeDetails ), storeBuilderController.getStoreDetails )
17
17
  .delete( '/deleteStoreLayout/:id', isAllowedSessionHandler, validate( validateDtos.deleteStoreLayout ), storeBuilderController.deleteStoreLayout )
18
18
  .post( '/removeFile', isAllowedSessionHandler, storeBuilderController.deleteFile )