tango-app-api-audit 3.4.26 → 3.4.27
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/app.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { auditRouter } from './index.js';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import { logger } from 'tango-app-api-middleware';
|
|
5
|
+
import { connectdb } from './config/database/database.js';
|
|
6
|
+
import responseMiddleware from './config/response/response.js';
|
|
7
|
+
import errorMiddleware from './config/response/error.js';
|
|
8
|
+
import pkg from 'body-parser';
|
|
9
|
+
import { swaggerConfig } from './config/swagger/swagger.js';
|
|
10
|
+
import swagger from 'swagger-ui-express';
|
|
11
|
+
import { traxAuditRouter } from './src/routes/traxAudit.routes.js';
|
|
12
|
+
import { auditWalletRouter } from './src/routes/auditWallet.routes.js';
|
|
13
|
+
// import externalParameterModel from 'tango-api-schema/schema/externalParameter.model.js';
|
|
14
|
+
|
|
15
|
+
const { json, urlencoded } = pkg;
|
|
16
|
+
const env=dotenv.config();
|
|
17
|
+
|
|
18
|
+
const app = express();
|
|
19
|
+
const PORT = process.env.PORT || 3000;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
app.use( json( { limit: '500mb' } ) );
|
|
23
|
+
app.use(
|
|
24
|
+
urlencoded( {
|
|
25
|
+
extended: true,
|
|
26
|
+
} ),
|
|
27
|
+
);
|
|
28
|
+
app.use( responseMiddleware );
|
|
29
|
+
app.use( errorMiddleware );
|
|
30
|
+
if ( env.error ) {
|
|
31
|
+
logger.error( '.env not found' );
|
|
32
|
+
process.exit( 1 );
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
|
|
37
|
+
app.use( '/v3/audit', auditRouter );
|
|
38
|
+
app.use( '/v3/trax-audit', traxAuditRouter );
|
|
39
|
+
app.use( '/v3/audit-wallet', auditWalletRouter );
|
|
40
|
+
|
|
41
|
+
app.listen( PORT, async () => {
|
|
42
|
+
connectdb();
|
|
43
|
+
logger.info( `server is running on port= ${PORT} ` );
|
|
44
|
+
} );
|
|
45
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.27",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "app.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node app.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -50,52 +50,27 @@ export async function auditUserSummary( req, res ) {
|
|
|
50
50
|
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
-
// {
|
|
54
|
-
// $project: {
|
|
55
|
-
// '_id': 0,
|
|
56
|
-
// 'Username': '$userName',
|
|
57
|
-
// 'User Email': '$userEmail',
|
|
58
|
-
// 'File Date From': '$fileDateFrom',
|
|
59
|
-
// 'File Date To': '$fileDateTo',
|
|
60
|
-
// 'Total Files': '$totalFilesCount',
|
|
61
|
-
// // 'Product Type': '$moduleType',
|
|
62
|
-
// // 'Time Spent': '$timeSpent',
|
|
63
|
-
// // 'Minimum Target': '$minimumTarget',
|
|
64
|
-
// // 'No Of Days': { $size: '$noOfDays' },
|
|
65
|
-
// 'Total BC': '$totalBeforeCount',
|
|
66
|
-
// 'Total AC': '$totalAfterCount',
|
|
67
|
-
// 'Total Earnings(Rs)': { $round: [ '$totalEarn', 2 ] },
|
|
68
|
-
// 'BC Credit': '$beforeCountCredit',
|
|
69
|
-
// 'AC Credit': '$afterCountCredit',
|
|
70
|
-
// // 'Deduction By TimeSpent': { $round: [ '$deductionBytimeSpent', 2 ] },
|
|
71
|
-
// 'Deduction by Minimum Target': { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
72
|
-
// 'Deduction by Mapping': { $round: [ '$deductionByMapping' ] },
|
|
73
|
-
// 'Deduction by Late Login': { $round: [ '$deductionByLateLogin', 2 ] },
|
|
74
|
-
// 'Total Reduced Amount': { $round: [ '$totalReducedAmount', 2 ] },
|
|
75
|
-
// 'Total Credit': { $round: [ '$totalCredit', 2 ] },
|
|
76
|
-
// },
|
|
77
|
-
// },
|
|
78
53
|
];
|
|
79
54
|
|
|
80
55
|
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
81
56
|
query.push( {
|
|
82
57
|
$match: {
|
|
83
58
|
$or: [
|
|
84
|
-
{ '
|
|
85
|
-
{ '
|
|
86
|
-
{ '
|
|
87
|
-
{ '
|
|
88
|
-
{ '
|
|
89
|
-
{ '
|
|
90
|
-
{ '
|
|
91
|
-
{ '
|
|
92
|
-
{ '
|
|
93
|
-
{ '
|
|
94
|
-
{ '
|
|
95
|
-
{ '
|
|
96
|
-
{ '
|
|
97
|
-
{ '
|
|
98
|
-
{ '
|
|
59
|
+
{ 'userName': { $regex: inputData.searchValue, $options: 'i' } },
|
|
60
|
+
{ 'userEmail': { $regex: inputData.searchValue, $options: 'i' } },
|
|
61
|
+
{ 'fileDateFrom': { $regex: inputData.searchValue, $options: 'i' } },
|
|
62
|
+
{ 'FileDateTo': { $regex: inputData.searchValue, $options: 'i' } },
|
|
63
|
+
{ 'totalFilesCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
64
|
+
{ 'totalBeforeCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
65
|
+
{ 'totalAfterCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
66
|
+
{ 'totalEarn': { $regex: inputData.searchValue, $options: 'i' } },
|
|
67
|
+
{ 'beforeCountCredit': { $regex: inputData.searchValue, $options: 'i' } },
|
|
68
|
+
{ 'afterCountCredit': { $regex: inputData.searchValue, $options: 'i' } },
|
|
69
|
+
{ 'deductionByMinimumTarget': { $regex: inputData.searchValue, $options: 'i' } },
|
|
70
|
+
{ 'deductionByMapping': { $regex: inputData.searchValue, $options: 'i' } },
|
|
71
|
+
{ 'deductionByLateLogin': { $regex: inputData.searchValue, $options: 'i' } },
|
|
72
|
+
{ 'totalReducedAmount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
73
|
+
{ 'totalCredit': { $regex: inputData.searchValue, $options: 'i' } },
|
|
99
74
|
],
|
|
100
75
|
},
|
|
101
76
|
} );
|
|
@@ -117,16 +92,11 @@ export async function auditUserSummary( req, res ) {
|
|
|
117
92
|
'File Date From': '$fileDateFrom',
|
|
118
93
|
'File Date To': '$fileDateTo',
|
|
119
94
|
'Total Files': '$totalFilesCount',
|
|
120
|
-
// 'Product Type': '$moduleType',
|
|
121
|
-
// 'Time Spent': '$timeSpent',
|
|
122
|
-
// 'Minimum Target': '$minimumTarget',
|
|
123
|
-
// 'No Of Days': { $size: '$noOfDays' },
|
|
124
95
|
'Total BC': '$totalBeforeCount',
|
|
125
96
|
'Total AC': '$totalAfterCount',
|
|
126
97
|
'Total Earnings(Rs)': { $round: [ '$totalEarn', 2 ] },
|
|
127
98
|
'BC Credit': '$beforeCountCredit',
|
|
128
99
|
'AC Credit': '$afterCountCredit',
|
|
129
|
-
// 'Deduction By TimeSpent': { $round: [ '$deductionBytimeSpent', 2 ] },
|
|
130
100
|
'Deduction by Minimum Target': { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
131
101
|
'Deduction by Mapping': { $round: [ '$deductionByMapping' ] },
|
|
132
102
|
'Deduction by Late Login': { $round: [ '$deductionByLateLogin', 2 ] },
|
|
@@ -138,26 +108,21 @@ export async function auditUserSummary( req, res ) {
|
|
|
138
108
|
query.push( {
|
|
139
109
|
$project: {
|
|
140
110
|
'_id': 0,
|
|
141
|
-
'
|
|
142
|
-
'
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
'
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
'
|
|
155
|
-
|
|
156
|
-
'DeductionbyMinimum Target': { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
157
|
-
'DeductionbyMapping': { $round: [ '$deductionByMapping' ] },
|
|
158
|
-
'DeductionbyLateLogin': { $round: [ '$deductionByLateLogin', 2 ] },
|
|
159
|
-
'TotalReducedAmount': { $round: [ '$totalReducedAmount', 2 ] },
|
|
160
|
-
'TotalCredit': { $round: [ '$totalCredit', 2 ] },
|
|
111
|
+
'userName': '$userName',
|
|
112
|
+
'userEmail': '$userEmail',
|
|
113
|
+
'fileDateFrom': '$fileDateFrom',
|
|
114
|
+
'fileDateTo': '$fileDateTo',
|
|
115
|
+
'totalFiles': '$totalFilesCount',
|
|
116
|
+
'totalBC': '$totalBeforeCount',
|
|
117
|
+
'totalAC': '$totalAfterCount',
|
|
118
|
+
'totalEarnings': { $round: [ '$totalEarn', 2 ] },
|
|
119
|
+
'bcCredit': '$beforeCountCredit',
|
|
120
|
+
'acCredit': '$afterCountCredit',
|
|
121
|
+
'deductionbyMinimumTarget': { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
122
|
+
'deductionbyMapping': { $round: [ '$deductionByMapping' ] },
|
|
123
|
+
'deductionbyLateLogin': { $round: [ '$deductionByLateLogin', 2 ] },
|
|
124
|
+
'totalReducedAmount': { $round: [ '$totalReducedAmount', 2 ] },
|
|
125
|
+
'totalCredit': { $round: [ '$totalCredit', 2 ] },
|
|
161
126
|
},
|
|
162
127
|
} );
|
|
163
128
|
}
|
|
@@ -368,21 +333,16 @@ export async function auditWalletSummary( req, res ) {
|
|
|
368
333
|
query.push( {
|
|
369
334
|
$match: {
|
|
370
335
|
$or: [
|
|
371
|
-
{ '
|
|
372
|
-
{ '
|
|
373
|
-
{ '
|
|
374
|
-
{ '
|
|
375
|
-
{ '
|
|
376
|
-
{ '
|
|
377
|
-
{ '
|
|
378
|
-
{ '
|
|
379
|
-
{ '
|
|
380
|
-
{ '
|
|
381
|
-
{ 'Deduction by Minimum Target': { $regex: inputData.searchValue, $options: 'i' } },
|
|
382
|
-
{ 'Deduction by Mapping': { $regex: inputData.searchValue, $options: 'i' } },
|
|
383
|
-
{ 'Deduction by Late Login': { $regex: inputData.searchValue, $options: 'i' } },
|
|
384
|
-
{ 'Total Reduced Amount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
385
|
-
{ 'Total Credit': { $regex: inputData.searchValue, $options: 'i' } },
|
|
336
|
+
{ 'fileDate': { $regex: inputData.searchValue, $options: 'i' } },
|
|
337
|
+
{ 'tolFilesCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
338
|
+
{ 'totalBeforeCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
339
|
+
{ 'totalAfterCount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
340
|
+
{ 'totalEarn': { $regex: inputData.searchValue, $options: 'i' } },
|
|
341
|
+
{ 'deductionByMinimumTarget': { $regex: inputData.searchValue, $options: 'i' } },
|
|
342
|
+
{ 'deductionByMapping': { $regex: inputData.searchValue, $options: 'i' } },
|
|
343
|
+
{ 'deductionByLateLogin': { $regex: inputData.searchValue, $options: 'i' } },
|
|
344
|
+
{ 'totalReducedAmount': { $regex: inputData.searchValue, $options: 'i' } },
|
|
345
|
+
{ 'totalCredit': { $regex: inputData.searchValue, $options: 'i' } },
|
|
386
346
|
],
|
|
387
347
|
},
|
|
388
348
|
} );
|
|
@@ -399,24 +359,13 @@ export async function auditWalletSummary( req, res ) {
|
|
|
399
359
|
query.push( {
|
|
400
360
|
$project: {
|
|
401
361
|
'_id': 0,
|
|
402
|
-
// "User Email":"$userEmail",
|
|
403
|
-
'User Name': '$userName',
|
|
404
362
|
'File Date': '$fileDate',
|
|
405
|
-
'
|
|
406
|
-
'
|
|
407
|
-
'
|
|
408
|
-
'Minimum Target': '$minimumTarget',
|
|
409
|
-
'Single Image Amount': '$singleImageAmount',
|
|
410
|
-
'Total Files Count': '$totalFilesCount',
|
|
411
|
-
|
|
412
|
-
'Total Before Count': '$totalBeforeCount',
|
|
413
|
-
'Total After Count': '$totalAfterCount',
|
|
414
|
-
'Before Count Credits': '$beforeCountCredit',
|
|
415
|
-
'After Count Credits': '$afterCountCredit',
|
|
363
|
+
'Total Files': '$tolFilesCount',
|
|
364
|
+
'Total BC': '$totalBeforeCount',
|
|
365
|
+
'Total AC': '$totalAfterCount',
|
|
416
366
|
'Total Earn': '$totalEarn',
|
|
417
|
-
'Deduction By TimeSpent': '$deductionBytimeSpent',
|
|
418
367
|
'Deduction By MinimumTarget': '$deductionByMinimumTarget',
|
|
419
|
-
'Mapping Percentage': '$mappingperc',
|
|
368
|
+
// 'Mapping Percentage': '$mappingperc',
|
|
420
369
|
'Deduction By Mapping': '$deductionByMapping',
|
|
421
370
|
'Deduction By Late Login': '$deductionByLateLogin',
|
|
422
371
|
'Total Reduced Amount': '$totalReducedAmount',
|
|
@@ -430,20 +379,11 @@ export async function auditWalletSummary( req, res ) {
|
|
|
430
379
|
query.push( {
|
|
431
380
|
$project: {
|
|
432
381
|
'_id': 0,
|
|
433
|
-
// "User Email":"$userEmail",
|
|
434
|
-
// 'userName': '$userName',
|
|
435
382
|
'fileDate': '$fileDate',
|
|
436
383
|
'totalFilesCount': '$totalFilesCount',
|
|
437
|
-
// 'productType': '$moduleType',
|
|
438
|
-
// 'timeSpent': '$timeSpent',
|
|
439
|
-
// 'startTime': '$startTime',
|
|
440
|
-
// 'minimumTarget': '$minimumTarget',
|
|
441
|
-
// 'singleImageAmount': '$singleImageAmount',
|
|
442
384
|
'totalBeforeCount': '$totalBeforeCount',
|
|
443
385
|
'totalAfterCount': '$totalAfterCount',
|
|
444
386
|
'totalEarn': '$totalEarn',
|
|
445
|
-
// 'beforeCountCredits': '$beforeCountCredit',
|
|
446
|
-
// 'afterCountCredits': '$afterCountCredit',
|
|
447
387
|
'deductionByMinimumTarget': '$deductionByMinimumTarget',
|
|
448
388
|
'mappingPercentage': '$mappingperc',
|
|
449
389
|
'deductionByMapping': '$deductionByMapping',
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
|
|
1
4
|
export async function roleVerification( req, res, next ) {
|
|
2
5
|
try {
|
|
3
6
|
if ( [ 'superadmin' ].includes( req?.user?.role ) ) {
|
|
@@ -15,16 +18,16 @@ export async function roleVerification( req, res, next ) {
|
|
|
15
18
|
export async function ValidateConsolidatedCard( req, res, next ) {
|
|
16
19
|
try {
|
|
17
20
|
if ( [ 'superadmin' ].includes( req?.user?.role ) ) {
|
|
18
|
-
|
|
21
|
+
const message = req.query.fromDate == req.query.toDate ? dayjs( req.query.fromDate ).format( 'DD MMM, YYYY' ) : `${ dayjs( req.query.fromDate ).format( 'DD MMM, YYYY' ) } - ${ dayjs( req.query.toDate ).format( 'DD MMM, YYYY' )}`;
|
|
22
|
+
req.message = `Total Credits for ${message}`;
|
|
19
23
|
return next();
|
|
20
24
|
} else {
|
|
21
|
-
const message = req.query.fromDate == req.query.toDate ? new Date( dayjs( req.query.fromDate ).format( 'DD MMM, YYYY' ) ): `${new Date( dayjs( req.query.fromDate ).format( 'DD MMM, YYYY' ) )}-${new Date( dayjs( req.query.toDate ).format( 'DD MMM, YYYY' ) )}`;
|
|
22
25
|
const yesterday = dayjs( new Date() ).subtract( 1, 'days' );
|
|
23
26
|
const yesterdayFT = new Date( dayjs( yesterday ).format( 'YYYY-MM-DD' ) );
|
|
24
27
|
req.query.userEmail = req.user.email;
|
|
25
28
|
req.query.fromDate = yesterdayFT;
|
|
26
29
|
req.query.toDate = yesterdayFT;
|
|
27
|
-
req.message =
|
|
30
|
+
req.message = 'Total Credits for yesterday';
|
|
28
31
|
return next();
|
|
29
32
|
}
|
|
30
33
|
} catch ( error ) {
|