tango-app-api-infra 3.1.10 → 3.1.12

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/index.js CHANGED
@@ -6,7 +6,9 @@ import { userInfraRouter } from './src/routes/userInfra.routes.js';
6
6
  import { storeInfraRouter } from './src/routes/storeInfra.routes.js';
7
7
  import { clientInfraRouter } from './src/routes/clientInfra.routes.js';
8
8
  import { employeeTrainigRouter } from './src/routes/employeetrainig.routes.js';
9
+ import { dataMismatchRouter } from './src/routes/dataMismatch.routes.js';
9
10
 
10
- export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter, employeeTrainigRouter };
11
+
12
+ export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, dataMismatchRouter, clientInfraRouter, employeeTrainigRouter };
11
13
 
12
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.1.10",
3
+ "version": "3.1.12",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,6 +16,7 @@ export async function infraCard( req, res ) {
16
16
  $match: {
17
17
  $and: [
18
18
  { issueType: 'infra' },
19
+ { status: { $ne: 'closed' } },
19
20
  { 'basicDetails.clientId': { $in: req.body.clientId } },
20
21
  { createdAt: { $gte: date.start } },
21
22
  { createdAt: { $lte: date.end } },
@@ -50,6 +51,7 @@ export async function infraCard( req, res ) {
50
51
  $match: {
51
52
  $and: [
52
53
  { issueType: 'infra' },
54
+ { status: { $ne: 'closed' } },
53
55
  { 'ticketDetails.issueStatus': 'identified' },
54
56
  { 'basicDetails.clientId': { $in: req.body.clientId } },
55
57
  { createdAt: { $gte: date.start } },
@@ -154,7 +156,8 @@ export async function installationCard( req, res ) {
154
156
  } );
155
157
  let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
156
158
  'edge.firstFile': true, 'status': 'active' } );
157
-
159
+ let deactiveCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
160
+ 'status': 'deactive' } );
158
161
  let yettoInstallCount = await aggregateTangoTicket( [
159
162
  {
160
163
  $match: {
@@ -248,6 +251,7 @@ export async function installationCard( req, res ) {
248
251
  }
249
252
  res.sendSuccess( {
250
253
  onboardedStoresCount: onboardedCount,
254
+ inactiveStoresCount: deactiveCount,
251
255
  installedStoresCount: installedCount,
252
256
  yettoInstallCount: yettoInstallCount.length,
253
257
  installFailedCount: installFailedCount.length,
@@ -265,6 +269,7 @@ export async function infraIssuesTable( req, res ) {
265
269
  $match: {
266
270
  $and: [
267
271
  { issueType: 'infra' },
272
+ { status: { $ne: 'closed' } },
268
273
  { 'basicDetails.clientId': { $in: req.body.clientId } },
269
274
  { 'ticketDetails.issueStatus': 'identified' },
270
275
  { createdAt: { $gte: date.start } },
@@ -0,0 +1,23 @@
1
+
2
+ import { findOneTangoTicket, createTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { logger } from 'tango-app-api-middleware';
4
+ export async function createTicket( req, res ) {
5
+ try {
6
+ let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
7
+
8
+ if ( ticketExist ) {
9
+ return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
10
+ }
11
+ req.body.ticketDetails = {};
12
+ req.body.ticketDetails.dataMismatch = req.body.dataMismatch;
13
+ req.body.issueDate = new Date( req.body.Date );
14
+ req.body.ticketId = 'TE_DM_' + new Date().valueOf();
15
+ let create = await createTangoTicket( req.body );
16
+ if ( create ) {
17
+ res.sendSuccess( 'Ticket Created Successfully' );
18
+ }
19
+ } catch ( error ) {
20
+ logger.error( { error: error, function: 'createTicket Data Mismatch' } );
21
+ return res.sendError( error, 500 );
22
+ }
23
+ }
@@ -125,6 +125,7 @@ export async function bulkcreateTicket( req, res ) {
125
125
 
126
126
  export async function updateStatus( req, res ) {
127
127
  try {
128
+ console.log( req.user.userType );
128
129
  if ( req.user.userType == 'tango' ) {
129
130
  if ( req.body.status == 'inprogress' ) {
130
131
  req.body.ticketActivity.push( {
@@ -133,8 +134,10 @@ export async function updateStatus( req, res ) {
133
134
  actionBy: 'Tango',
134
135
  IdentifiedBy: req.user.userName,
135
136
  } );
137
+ req.body.status ='inprogress';
136
138
  }
137
139
  req.body.ticketDetails.addressingUser = req.user._id;
140
+ console.log( req.body );
138
141
  let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, req.body );
139
142
  if ( updateTicket ) {
140
143
  res.sendSuccess( 'Ticket Updated Successfully' );
@@ -147,6 +150,7 @@ export async function updateStatus( req, res ) {
147
150
  actionBy: 'User',
148
151
  IdentifiedBy: req.user.userName,
149
152
  } );
153
+ req.body.status ='inprogress';
150
154
  }
151
155
  req.body.ticketDetails.addressingClient = req.user._id;
152
156
  let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, req.body );
@@ -725,7 +729,7 @@ export async function infraTable( req, res ) {
725
729
  },
726
730
  {
727
731
  $group: {
728
- _id: '$storeId',
732
+ _id: '$ticketId',
729
733
  storeId: { $first: '$storeId' },
730
734
  clientId: { $first: '$clientId' },
731
735
  ticketId: { $first: '$ticketId' },
@@ -847,15 +851,11 @@ export async function infraTable( req, res ) {
847
851
  await download( exportdata, res );
848
852
  return;
849
853
  }
850
- if ( result.length > 0 ) {
851
- res.sendSuccess( {
852
- response: response,
853
- count: count.length,
854
- result: result,
855
- } );
856
- } else {
857
- res.sendError( 'no data', 204 );
858
- }
854
+ res.sendSuccess( {
855
+ response: response,
856
+ count: count.length,
857
+ result: result,
858
+ } );
859
859
  } catch ( error ) {
860
860
  logger.error( { error: error, function: 'infraTable' } );
861
861
  return res.sendError( error, 500 );
@@ -1088,15 +1088,11 @@ export async function installationTable( req, res ) {
1088
1088
  await download( exportdata, res );
1089
1089
  return;
1090
1090
  }
1091
- if ( result.length > 0 ) {
1092
- res.sendSuccess( {
1093
- response: response,
1094
- count: count.length,
1095
- result: result,
1096
- } );
1097
- } else {
1098
- res.sendError( 'no data', 204 );
1099
- }
1091
+ res.sendSuccess( {
1092
+ response: response,
1093
+ count: count.length,
1094
+ result: result,
1095
+ } );
1100
1096
  } catch ( error ) {
1101
1097
  logger.error( { error: error, function: 'installationTable' } );
1102
1098
  return res.sendError( error, 500 );
@@ -75,6 +75,17 @@ export async function userTakeTicket( req, res ) {
75
75
  let query = {
76
76
  'status': { $ne: 'closed' },
77
77
  'issueType': 'mat',
78
+ 'ticketDetails.addressingUser': { $exists: false },
79
+ };
80
+ if ( assignedClients.length > 0 ) {
81
+ query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
82
+ }
83
+ userTicket = await findOneTangoTicket( query );
84
+ } else if ( req.body.issueType == 'dataMismatch' ) {
85
+ let query = {
86
+ 'status': { $ne: 'closed' },
87
+ 'issueType': { $in: [ 'highcount', 'lowcount' ] },
88
+ 'ticketDetails.addressingUser': { $exists: false },
78
89
  };
79
90
  if ( assignedClients.length > 0 ) {
80
91
  query =( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
@@ -97,15 +108,26 @@ export async function userTakeTicket( req, res ) {
97
108
  export async function userTicketList( req, res ) {
98
109
  try {
99
110
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
100
- let query = [ {
101
- $match: {
102
- $and: [
103
-
104
- { issueType: req.body.issueType },
105
- { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
106
- ],
107
- },
108
- } ];
111
+ let query = [];
112
+ if ( req.body.issueType!='dataMismatch' ) {
113
+ query.push( {
114
+ $match: {
115
+ $and: [
116
+ { issueType: req.body.issueType },
117
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
118
+ ],
119
+ },
120
+ } );
121
+ } else {
122
+ query.push( {
123
+ $match: {
124
+ $and: [
125
+ { issueType: { $in: [ 'highcount', 'lowcount' ] } },
126
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
127
+ ],
128
+ },
129
+ } );
130
+ }
109
131
  if ( req.body.status != 'closed' || req.body.export ) {
110
132
  query.push( {
111
133
  $match: {
@@ -132,6 +154,7 @@ export async function userTicketList( req, res ) {
132
154
  query.push( {
133
155
  $project: {
134
156
  storeId: '$basicDetails.storeId',
157
+ storeName: '$basicDetails.storeName',
135
158
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
136
159
  updatedAt: 1,
137
160
  ticketId: 1,
@@ -162,6 +185,7 @@ export async function userTicketList( req, res ) {
162
185
  {
163
186
  $project: {
164
187
  storeId: 1,
188
+ storeName: 1,
165
189
  updatedAt: 1,
166
190
  Date: 1,
167
191
  ticketId: 1,
@@ -177,6 +201,7 @@ export async function userTicketList( req, res ) {
177
201
  $group: {
178
202
  _id: '$ticketId',
179
203
  storeId: { $first: '$storeId' },
204
+ storeName: { $first: '$storeName' },
180
205
  updatedAt: { $first: '$updatedAt' },
181
206
  Date: { $first: '$Date' },
182
207
  ticketId: { $first: '$ticketId' },
@@ -196,6 +221,7 @@ export async function userTicketList( req, res ) {
196
221
  $or: [
197
222
  { storeId: { $regex: req.body.searchValue, $options: 'i' } },
198
223
  { infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
224
+ { storeName: { $regex: req.body.searchValue, $options: 'i' } },
199
225
  ],
200
226
  },
201
227
  } );
@@ -303,16 +329,28 @@ export async function basicDetails( req, res ) {
303
329
  export async function workHistory( req, res ) {
304
330
  try {
305
331
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
306
- let query = [ {
307
- $match: {
308
- $and: [
309
- { 'status': 'closed' },
310
- { issueType: req.body.issueType },
311
- { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
312
- ],
313
- },
314
- } ];
315
-
332
+ let query = [ ];
333
+ if ( req.body.issueType!='dataMismatch' ) {
334
+ query.push( {
335
+ $match: {
336
+ $and: [
337
+ { 'status': 'closed' },
338
+ { issueType: req.body.issueType },
339
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
340
+ ],
341
+ },
342
+ } );
343
+ } else {
344
+ query.push( {
345
+ $match: {
346
+ $and: [
347
+ { 'status': 'closed' },
348
+ { issueType: { $in: [ 'highcount', 'lowcount' ] } },
349
+ { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
350
+ ],
351
+ },
352
+ } );
353
+ }
316
354
  if ( req.body.dateFilter && req.body.dateFilter != '' ) {
317
355
  if ( req.body.dateFilter === 'issueIdentifiedDate' ) {
318
356
  query.push(
@@ -373,6 +411,7 @@ export async function workHistory( req, res ) {
373
411
  issueClosedDate: { $dateToString: { format: '%Y-%m-%d', date: '$issueClosedDate' } },
374
412
  issueIdentifiedDate: { $dateToString: { format: '%Y-%m-%d', date: '$ticketDetails.issueIdentifiedDate' } },
375
413
  ticketId: 1,
414
+ status: 1,
376
415
  issueStatus: '$ticketDetails.issueStatus',
377
416
  ticketType: '$ticketDetails.ticketType',
378
417
  primaryIssue: {
@@ -455,7 +494,7 @@ export async function workHistory( req, res ) {
455
494
  'ISSUE IDENTIFIED DATE': element.issueIdentifiedDate,
456
495
  'CLOSED ON': element.issueClosedDate,
457
496
  'ISSUE': element.infraIssue?element.infraIssue:'-',
458
-
497
+ 'STATUS': element.status,
459
498
  } );
460
499
  } );
461
500
  await download( exportdata, res );
@@ -0,0 +1,10 @@
1
+ import express from 'express';
2
+ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
3
+ import { createTicket } from '../controllers/dataMismatch.controller.js';
4
+ import { validateDetails } from '../validations/infra.validation.js';
5
+ export const dataMismatchRouter = express.Router();
6
+
7
+ dataMismatchRouter.post( '/createTicket', isAllowedSessionHandler, authorize( {
8
+ userType: [ 'client', 'tango' ], access: [
9
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView', 'isEdit' ] } ],
10
+ } ), validateDetails, createTicket );
@@ -185,6 +185,8 @@ export async function ticketExists( req, res, next ) {
185
185
  req.body.ticketDetails = Ticket.ticketDetails;
186
186
  req.body.ticketActivity = Ticket.ticketActivity;
187
187
  req.body.status = Ticket.status;
188
+ req.body.issueDate = Ticket.issueDate;
189
+
188
190
 
189
191
  next();
190
192
  } catch ( error ) {