tango-app-api-infra 3.0.60-dev → 3.0.61-dev
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-infra",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.61-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"mongodb": "^6.4.0",
|
|
26
26
|
"nodemon": "^3.1.0",
|
|
27
27
|
"tango-api-schema": "^2.0.94",
|
|
28
|
-
"tango-app-api-middleware": "^
|
|
28
|
+
"tango-app-api-middleware": "^1.0.58-dev",
|
|
29
29
|
"winston": "^3.12.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
31
|
},
|
|
@@ -1,13 +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
|
}
|
|
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
|
+
}
|
|
11
19
|
} catch ( error ) {
|
|
12
20
|
logger.error( { error: error, function: 'createTicket Data Mismatch' } );
|
|
13
21
|
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
|
-
|
|
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(
|