tango-app-api-infra 3.1.11 → 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/package.json
CHANGED
|
@@ -156,7 +156,8 @@ export async function installationCard( req, res ) {
|
|
|
156
156
|
} );
|
|
157
157
|
let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
|
|
158
158
|
'edge.firstFile': true, 'status': 'active' } );
|
|
159
|
-
|
|
159
|
+
let deactiveCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
|
|
160
|
+
'status': 'deactive' } );
|
|
160
161
|
let yettoInstallCount = await aggregateTangoTicket( [
|
|
161
162
|
{
|
|
162
163
|
$match: {
|
|
@@ -250,6 +251,7 @@ export async function installationCard( req, res ) {
|
|
|
250
251
|
}
|
|
251
252
|
res.sendSuccess( {
|
|
252
253
|
onboardedStoresCount: onboardedCount,
|
|
254
|
+
inactiveStoresCount: deactiveCount,
|
|
253
255
|
installedStoresCount: installedCount,
|
|
254
256
|
yettoInstallCount: yettoInstallCount.length,
|
|
255
257
|
installFailedCount: installFailedCount.length,
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { findOneTangoTicket, createTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
|
+
import { logger } from 'tango-app-api-middleware';
|
|
4
|
+
export async function createTicket( req, res ) {
|
|
4
5
|
try {
|
|
5
|
-
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
|
|
6
|
+
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
|
|
6
7
|
|
|
7
8
|
if ( ticketExist ) {
|
|
8
9
|
return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
|
|
9
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
|
+
}
|
|
10
19
|
} catch ( error ) {
|
|
11
20
|
logger.error( { error: error, function: 'createTicket Data Mismatch' } );
|
|
12
21
|
return res.sendError( error, 500 );
|
|
@@ -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 );
|
|
@@ -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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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(
|