tango-app-api-store-builder 1.1.15 → 1.1.16

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.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -8022,8 +8022,17 @@ export async function searchProduct( req, res ) {
8022
8022
  if ( !req.body.pid ) {
8023
8023
  return res.sendError( 'Pid is required', 400 );
8024
8024
  }
8025
- let getProductDetails = await planoMappingService.find( { $or: [ { pid: { $regex: req.body.pid, $options: 'i' } }, { rfId: { $regex: req.body.pid, $options: 'i' } }, { barCode: { $regex: req.body.pid, $options: 'i' } } ], planoId: req.body.planoId, floorId: req.body.floorId } );
8026
- console.log( getProductDetails );
8025
+ let query = [
8026
+ {
8027
+ $match: {
8028
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
8029
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
8030
+ $or: [ { pid: { $regex: req.body.pid, $options: 'i' } }, { rfId: { $regex: req.body.pid, $options: 'i' } }, { barCode: { $regex: req.body.pid, $options: 'i' } } ],
8031
+ },
8032
+ },
8033
+ ];
8034
+
8035
+ let getProductDetails = await planoMappingService.aggregate( query );
8027
8036
  if ( !getProductDetails.length ) {
8028
8037
  return res.sendError( 'No data found', 204 );
8029
8038
  }
@@ -8033,10 +8042,11 @@ export async function searchProduct( req, res ) {
8033
8042
  let shelfDetails = await fixtureShelfService.findOne( { _id: ele.shelfId }, { _id: 0, shelfNumber: 1 } );
8034
8043
 
8035
8044
  return {
8036
- ...ele.toObject(),
8045
+ ...ele,
8037
8046
  ...productDetails?.toObject(),
8038
8047
  ...fixtureDetails?.toObject(),
8039
- ...shelfDetails?.toObject(), shelfNumber: shelfDetails.shelfNumber-1,
8048
+ ...shelfDetails?.toObject(),
8049
+ ...( fixtureDetails?.fixtureType == 'wall' && { shelfNumber: shelfDetails?.shelfNumber-1 } ),
8040
8050
  };
8041
8051
  } ) );
8042
8052
  return res.sendSuccess( result );