tango-app-api-audit 3.4.3-alpha.3 → 3.4.3-alpha.5

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.3-alpha.3",
3
+ "version": "3.4.3-alpha.5",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,7 +16,7 @@ import { findOneAuditLog, createAuditLog,
16
16
  import {
17
17
  findOneUserEmpDetection,
18
18
  } from '../service/userEmpDetection.service.js';
19
- import { createempDetectionOutput } from '../service/auditUserWallet.service.js';
19
+ import { updateOneEmpDetectionOutput } from '../service/empDetectionOutput.service.js';
20
20
  // export async function getDetectionAuditFile( req, res ) {
21
21
  // try {
22
22
  // const bucket = JSON.parse( process.env.BUCKET );
@@ -4050,8 +4050,11 @@ export async function getDraftedData( req, res ) {
4050
4050
  export async function save( req, res ) {
4051
4051
  try {
4052
4052
  const inputData = req.body;
4053
- const data = await createempDetectionOutput( { storeId: inputData.storeId, moduleType: inputData.moduleType, fileDate: inputData.fileDate }, { $set: inputData }, { upsert: true } );
4053
+ const query ={ storeId: inputData.storeId, moduleType: inputData.moduleType, fileDate: inputData.fileDate };
4054
+ const data = await updateOneEmpDetectionOutput( query, { $set: inputData }, { upsert: true } );
4054
4055
  if ( data ) {
4056
+ await updateOneUserEmpDetection( { _id: inputData.auditId }, { auditStatus: 'completed', afterCount: inputData.employeeCount } );
4057
+ await updateOneStoreEmpDetection( query, { status: 'completed', afterCount: inputData.employeeCount } );
4055
4058
  return res.sendSuccess( { result: 'Updated Successfully' } );
4056
4059
  } else {
4057
4060
  return res.sendError( 'something went wrong', 403 );
@@ -1,5 +1,5 @@
1
1
 
2
2
  import empDetectionOutputModel from 'tango-api-schema/schema/empDetectionOutput.model.js';
3
- export function createAuditLog( record ) {
4
- return empDetectionOutputModel.create( record );
3
+ export function updateOneEmpDetectionOutput( query, record, upsert ) {
4
+ return empDetectionOutputModel.updateOne( query, record, upsert );
5
5
  }