tango-app-api-store-builder 1.0.0-beta-8 → 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-8",
3
+ "version": "1.0.0-beta-9",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -560,41 +560,35 @@ 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
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
  }
@@ -614,6 +608,7 @@ export async function fixtureShelfProduct( req, res ) {
614
608
 
615
609
  export async function scan( req, res ) {
616
610
  try {
611
+ let shelfId;
617
612
  if ( !req.body.planoId ) {
618
613
  return res.sendError( 'Plano id is required', 400 );
619
614
  }
@@ -638,7 +633,11 @@ export async function scan( req, res ) {
638
633
  if ( !shelfDetails ) {
639
634
  return res.sendError( 'No data found', 204 );
640
635
  }
636
+ if ( shelfDetails.shelfCapacity < req.body.shelfPosition ) {
637
+ return res.sendError( 'Shelf capacity exceeded', 400 );
638
+ }
641
639
  shelfDetails = await fixtureShelfService.find( { sectionName: shelfDetails?.sectionName } );
640
+ shelfId = req.body.shelfId;
642
641
  req.body.shelfId = shelfDetails.map( ( ele ) => ele._id );
643
642
  }
644
643
  let productCheck= await planoMappingService.findOne( { rfId: req.body.rfId } );
@@ -706,16 +705,17 @@ export async function scan( req, res ) {
706
705
  break;
707
706
  }
708
707
  query = { ...query, rfId: req.body.rfId };
708
+ console.log( query );
709
709
 
710
710
  let planoProductDetails = await planoMappingService.findOne( query );
711
711
  let data = {
712
- ...( 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 },
713
713
  rfId: req.body.rfId,
714
714
  compliance: !planoProductDetails ? 'misplaced' : 'proper',
715
715
  date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
716
716
  };
717
717
  delete data._id;
718
- 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 };
719
719
  await planoComplianceService.updateOne( query, data );
720
720
  if ( !planoProductDetails ) {
721
721
  return res.sendSuccess( false );