tango-app-api-audit 1.0.36 → 1.0.38
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,4 +1,4 @@
|
|
|
1
|
-
import { getJsonFileData, getUTC, insertOpenSearchData, listFileByPath, sendMessageToQueue, signedUrl, sqsReceive } from 'tango-app-api-middleware';
|
|
1
|
+
import { download, fileUpload, getJsonFileData, getUTC, insertOpenSearchData, listFileByPath, sendMessageToQueue, signedUrl, sqsReceive } from 'tango-app-api-middleware';
|
|
2
2
|
import { aggregateZoneUserAudit, createZoneUserAudit, findOneZoneUserAudit } from '../service/zoneUserAudit.service.js';
|
|
3
3
|
import { logger } from 'tango-app-api-middleware';
|
|
4
4
|
import { aggregateAssignZoneAudit } from '../service/assignZoneAudit.service.js';
|
|
@@ -10,6 +10,10 @@ import { aggregateUserAudit, findOneUserAudit, updateOneUserAudit } from '../ser
|
|
|
10
10
|
import { aggregateAssignAudit } from '../service/assignAudit.service.js';
|
|
11
11
|
import { createAuditLog, findOneAuditLog } from '../service/auditLog.service.js';
|
|
12
12
|
import { mapCustomer, mapEmployee, mapJunk, splitB20000, splitE0, splitG20000 } from '../validation/audit.validation.js';
|
|
13
|
+
import { aggregateClient, findClient } from '../service/client.service.js';
|
|
14
|
+
import { aggregateAuditClientData } from '../service/auditClientData.service.js';
|
|
15
|
+
import _ from 'lodash';
|
|
16
|
+
import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
13
17
|
|
|
14
18
|
export async function getZoneAuditFile( req, res ) {
|
|
15
19
|
try {
|
|
@@ -353,8 +357,8 @@ export async function getDraftedData( req, res ) {
|
|
|
353
357
|
};
|
|
354
358
|
const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
|
|
355
359
|
|
|
356
|
-
if ( result
|
|
357
|
-
return res.sendError( 'No Data Found',
|
|
360
|
+
if ( !result ) {
|
|
361
|
+
return res.sendError( 'No Data Found', 204 );
|
|
358
362
|
}
|
|
359
363
|
return res.sendSuccess( { result: result } );
|
|
360
364
|
} catch ( error ) {
|
|
@@ -422,14 +426,14 @@ export async function save( req, res ) {
|
|
|
422
426
|
|
|
423
427
|
if ( mappingUpload?.statusCode ) {
|
|
424
428
|
logger.error( {
|
|
425
|
-
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
429
|
+
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.zoneName}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
426
430
|
type: 'UPLOAD_ERROR',
|
|
427
431
|
} );
|
|
428
432
|
return res.sendError( mappingUpload, 500 );
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
let getUserAuditData = await findOneUserAudit( {
|
|
432
|
-
_id:
|
|
436
|
+
_id: inputData.auditId,
|
|
433
437
|
} );
|
|
434
438
|
const isoDate = getUserAuditData.startTime;
|
|
435
439
|
const currentTime = dayjs();
|
|
@@ -437,7 +441,7 @@ export async function save( req, res ) {
|
|
|
437
441
|
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
438
442
|
|
|
439
443
|
await updateOneUserAudit(
|
|
440
|
-
{ _id:
|
|
444
|
+
{ _id: inputData.auditId },
|
|
441
445
|
{
|
|
442
446
|
auditStatus: 'completed',
|
|
443
447
|
endTime: Date.now(),
|
|
@@ -477,7 +481,7 @@ export async function save( req, res ) {
|
|
|
477
481
|
storeConfig.auditConfigs.ratio
|
|
478
482
|
) && inputData.auditType == 'Audit' ) {
|
|
479
483
|
logger.info(
|
|
480
|
-
`Hit in Reaudit pushing queue Store Id=${inputData.storeId},File Date=${inputData.fileDate}, /n \nQueue Name = ${clientData[0].auditConfigs.queueName}`,
|
|
484
|
+
`Hit in Reaudit pushing queue Store Id=${inputData.storeId},zone Name = ${inputData.zoneName}File Date=${inputData.fileDate}, /n \nQueue Name = ${clientData[0].auditConfigs.queueName}`,
|
|
481
485
|
'Reaudit',
|
|
482
486
|
);
|
|
483
487
|
|
|
@@ -497,7 +501,7 @@ export async function save( req, res ) {
|
|
|
497
501
|
|
|
498
502
|
if ( sqsQueue.statusCode ) {
|
|
499
503
|
logger.error( {
|
|
500
|
-
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
504
|
+
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.zoneName}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
501
505
|
type: 'UPLOAD_ERROR',
|
|
502
506
|
} );
|
|
503
507
|
return res.sendError( mappingUpload, 500 );
|
|
@@ -539,7 +543,7 @@ export async function save( req, res ) {
|
|
|
539
543
|
} catch ( error ) {
|
|
540
544
|
const err = error.message || 'Internal Server Error';
|
|
541
545
|
logger.error( { error: error, message: req.body, function: 'save' } );
|
|
542
|
-
return res.sendError( err );
|
|
546
|
+
return res.sendError( err, 500 );
|
|
543
547
|
}
|
|
544
548
|
}
|
|
545
549
|
|
|
@@ -74,7 +74,13 @@ export const zoneAuditDocs = {
|
|
|
74
74
|
in: 'query',
|
|
75
75
|
name: 'storeId',
|
|
76
76
|
scema: j2s( getDraftedDataSchema ).swagger,
|
|
77
|
-
require:
|
|
77
|
+
require: true,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
in: 'query',
|
|
81
|
+
name: 'zoneName',
|
|
82
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
83
|
+
require: true,
|
|
78
84
|
},
|
|
79
85
|
],
|
|
80
86
|
responses: {
|