tango-app-api-audit 3.4.29 → 3.4.31

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-audit",
3
- "version": "3.4.29",
3
+ "version": "3.4.31",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3954,7 +3954,7 @@ export async function getUserAuditCount( req, res ) {
3954
3954
  const userWallet = JSON.parse( process.env.USER_WALLET );
3955
3955
  const previousDate = dayjs( new Date() ).subtract( i, 'days' );
3956
3956
  const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
3957
- const configTimeSpentSec = userWallet.minTimeSpentSec; // 21600 seconds / 6 hours;
3957
+ // const configTimeSpentSec = userWallet.minTimeSpentSec; // 21600 seconds / 6 hours;
3958
3958
  // const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
3959
3959
  // const afterCountY = userWallet.afterCountCreditPerc; // 0.0035;
3960
3960
  const reduce = userWallet.reductionPerc; // 0.05;
@@ -4110,7 +4110,7 @@ export async function getUserAuditCount( req, res ) {
4110
4110
  singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
4111
4111
  totalReducedAmount: { $ifNull: [ 0, 0 ] },
4112
4112
  totalCredit: { $ifNull: [ 0, 0 ] },
4113
- deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
4113
+ // deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
4114
4114
  deductionByMinimumTarget: { $ifNull: [ 0, 0 ] },
4115
4115
  deductionByLateLogin: { $ifNull: [ 0, 0 ] },
4116
4116
  startTime: 1,
@@ -4136,7 +4136,7 @@ export async function getUserAuditCount( req, res ) {
4136
4136
  totalReducedAmount: { $first: '$totalReducedAmount' },
4137
4137
  totalCredit: { $first: '$totalCredit' },
4138
4138
  deductionByMinimumTarget: { $first: '$deductionByMinimumTarget' },
4139
- deductionBytimeSpent: { $first: '$deductionBytimeSpent' },
4139
+ // deductionBytimeSpent: { $first: '$deductionBytimeSpent' },
4140
4140
  singleImageAmount: { $first: '$singleImageAmount' },
4141
4141
  startTime: { $first: '$startTime' },
4142
4142
  deductionByLateLogin: { $first: '$deductionByLateLogin' },
@@ -4167,7 +4167,7 @@ export async function getUserAuditCount( req, res ) {
4167
4167
  // ] },
4168
4168
  afterCountCredit: afterCountCredit,
4169
4169
  totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
4170
- deductionBytimeSpent: 1,
4170
+ // deductionBytimeSpent: 1,
4171
4171
  deductionByMinimumTarget: 1,
4172
4172
  mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
4173
4173
  deductionByMapping: { $cond: [ { $and: [
@@ -4210,10 +4210,10 @@ export async function getUserAuditCount( req, res ) {
4210
4210
  beforeCountCredit: 1,
4211
4211
  afterCountCredit: 1,
4212
4212
  totalEarn: 1,
4213
- deductionBytimeSpent: { $cond: [
4214
- { $lt: [ '$totalTimeSpent', configTimeSpentSec ] },
4215
- { $multiply: [ reduce, '$totalEarn' ] }, '$deductionBytimeSpent',
4216
- ] },
4213
+ // deductionBytimeSpent: { $cond: [
4214
+ // { $lt: [ '$totalTimeSpent', configTimeSpentSec ] },
4215
+ // { $multiply: [ reduce, '$totalEarn' ] }, '$deductionBytimeSpent',
4216
+ // ] },
4217
4217
 
4218
4218
  deductionByMinimumTarget:
4219
4219
  { $cond: [
@@ -4269,11 +4269,11 @@ export async function getUserAuditCount( req, res ) {
4269
4269
  totalEarn: 1,
4270
4270
  deductionByMinimumTarget: 1,
4271
4271
  singleImageAmount: 1,
4272
- deductionBytimeSpent: 1,
4272
+ // deductionBytimeSpent: 1,
4273
4273
  mappingperc: 1,
4274
4274
  deductionByMapping: 1,
4275
4275
  totalCredit: { $subtract: [ '$totalEarn', '$totalReducedAmount' ] },
4276
- totalReducedAmount: { $round: [ { $add: [ '$deductionBytimeSpent', '$deductionByMinimumTarget', '$deductionByMapping', '$deductionByLateLogin' ] }, 2 ] },
4276
+ totalReducedAmount: { $round: [ { $add: [ '$deductionByMinimumTarget', '$deductionByMapping', '$deductionByLateLogin' ] }, 2 ] },
4277
4277
  deductionByLateLogin: 1,
4278
4278
  startTime: {
4279
4279
  $dateToString: {
@@ -4324,7 +4324,7 @@ export async function getUserAuditCount( req, res ) {
4324
4324
  minimumTarget: 1,
4325
4325
  singleImageAmount: 1,
4326
4326
  deductionByMinimumTarget: { $round: [ '$deductionByMinimumTarget', 2 ] },
4327
- deductionBytimeSpent: { $round: [ '$deductionBytimeSpent', 2 ] },
4327
+ // deductionBytimeSpent: { $round: [ '$deductionBytimeSpent', 2 ] },
4328
4328
  mappingperc: 1,
4329
4329
  deductionByMapping: 1,
4330
4330
  totalReducedAmount: 1,
@@ -355,7 +355,7 @@ export async function auditWalletSummary( req, res ) {
355
355
  'Total BC': '$totalBeforeCount',
356
356
  'Total AC': '$totalAfterCount',
357
357
  'Total Earn': '$totalEarn',
358
- 'Deduction By MinimumTarget': '$deductionByMinimumTarget',
358
+ 'Deduction By Minimum Target': '$deductionByMinimumTarget',
359
359
  // 'Mapping Percentage': '$mappingperc',
360
360
  'Deduction By Mapping': '$deductionByMapping',
361
361
  'Deduction By Late Login': '$deductionByLateLogin',
@@ -420,4 +420,16 @@ export async function auditWalletSummary( req, res ) {
420
420
  }
421
421
  }
422
422
 
423
+ export async function generateReport( req, res ) {
424
+ try {
425
+ const inputData = req.query;
426
+ logger.info( { inputData: inputData } );
427
+ return res.sendSuccess( { result: 'Generate Reort SuccessFully' } );
428
+ } catch ( error ) {
429
+ const err = error.message || 'Internal Server Error';
430
+ logger.error( { error: error, message: req.query, function: 'generateReport' } );
431
+ return res.sendError( err, 500 );
432
+ }
433
+ }
434
+
423
435
 
@@ -193,4 +193,32 @@ export const auditWalletDocs = {
193
193
  },
194
194
  },
195
195
  },
196
+ '/v3/audit-wallet/generate-report': {
197
+ get: {
198
+ tags: [ 'Audit Wallet' ],
199
+ description: 'Generate user wallet report ',
200
+ operationId: 'generate-report',
201
+ parameters: [
202
+ {
203
+ in: 'query',
204
+ name: 'fromDate',
205
+ scema: j2s( consolidatedCardSASchema ).swagger,
206
+ require: false,
207
+ },
208
+ {
209
+ in: 'query',
210
+ name: 'toDate',
211
+ scema: j2s( consolidatedCardSASchema ).swagger,
212
+ require: false,
213
+ },
214
+ ],
215
+ responses: {
216
+ 200: { description: 'Successful' },
217
+ 401: { description: 'Unauthorized User' },
218
+ 422: { description: 'Field Error' },
219
+ 500: { description: 'Server Error' },
220
+ 204: { description: 'Not Found' },
221
+ },
222
+ },
223
+ },
196
224
  };
@@ -49,3 +49,13 @@ export const auditWalletSummarySchema = joi.object( {
49
49
  export const auditWalletSummaryValid = {
50
50
  query: auditWalletSummarySchema,
51
51
  };
52
+
53
+
54
+ export const generateReportSchema = joi.object( {
55
+ fromDate: joi.string().required(),
56
+ toDate: joi.string().required(),
57
+ } );
58
+
59
+ export const generateReportValid = {
60
+ query: generateReportSchema,
61
+ };
@@ -1,8 +1,8 @@
1
1
  import { Router } from 'express';
2
- import { auditUserDetailsValid, auditUserSummaryValid, auditWalletSummaryValid, consolidatedCardSAValid } from '../dtos/auditWallet.dtos.js';
2
+ import { auditUserDetailsValid, auditUserSummaryValid, auditWalletSummaryValid, consolidatedCardSAValid, generateReportValid } from '../dtos/auditWallet.dtos.js';
3
3
  import { dateValidation, ValidateConsolidatedCard, roleVerification, ValidateWalletSummary } from '../validation/auditWallet.validation.js';
4
4
  import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
5
- import { auditUserSummary, auditWalletSummary, consolidatedCard, getAuditUserDetails } from '../controllers/auditWallet.controllers.js';
5
+ import { auditUserSummary, auditWalletSummary, consolidatedCard, generateReport, getAuditUserDetails } from '../controllers/auditWallet.controllers.js';
6
6
 
7
7
  export const auditWalletRouter = Router();
8
8
 
@@ -13,6 +13,7 @@ auditWalletRouter.get( '/audit-user-summary', isAllowedSessionHandler, accessVer
13
13
  auditWalletRouter.get( '/get-audit-user-details', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), roleVerification, validate( auditUserDetailsValid ), getAuditUserDetails );
14
14
  auditWalletRouter.get( '/consolidated-card', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), ValidateConsolidatedCard, validate( consolidatedCardSAValid ), consolidatedCard );
15
15
  auditWalletRouter.get( '/audit-wallet-summary', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), ValidateWalletSummary, validate( auditWalletSummaryValid ), auditWalletSummary );
16
+ auditWalletRouter.get( '/generate-report', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), roleVerification, validate( generateReportValid ), generateReport );
16
17
 
17
18
  export default auditWalletRouter;
18
19