Parcourir la source

fixing sanksi dan pencabutan sanksi

yazid138 il y a 3 ans
Parent
commit
50355802fe

+ 4 - 6
controller/sanksi.controller.js

@@ -99,15 +99,13 @@ exports.getAll = handleError(async (req, res) => {
       where['jawaban.banding'] = { $exists: true, $ne: null }
     }
   } else if (cabutSanksi === 'true') {
-    where['pengajuan.cabut_sanksi'] = { $exists: true, $ne: null }
+    where.perbaikan = { $exists: true, $ne: [] }
     if (jawaban === 'true') {
-      where['jawaban.cabut_sanksi'] = { $exists: true, $ne: null }
+      where['pengajuan.cabut_sanksi'] = { $exists: true, $ne: null }
+      // where['jawaban.cabut_sanksi'] = { $exists: true, $ne: null }
     }
   } else if (perbaikan === 'true') {
-    where.$or = [
-      { 'jawaban.cabut_sanksi': { $exists: true, $ne: null } },
-      { 'jawaban.banding': { $exists: true, $ne: null } },
-    ]
+    where['jawaban.banding'] = { $exists: true, $ne: null }
   }
   const data = await cekBanyakDataSanksi(user, where)
   return response.success(res, {

+ 1 - 3
controller/sanksi/cabutSanksi.controller.js

@@ -5,9 +5,6 @@ const { validate } = require('../../utils/validation')
 const { cekSatuDataSanksi, cekSatuDataLaporan } = require('../../utils/cekData')
 const response = require('../../utils/responseHandler')
 const pemantauanModel = require('../../model/pemantauan.model')
-const logModel = require('../../model/log.model')
-const ip = require('ip')
-const osValue = require('../../utils/osValue')
 
 exports.create = handleError(async (req, res) => {
   const user = req.user
@@ -29,6 +26,7 @@ exports.create = handleError(async (req, res) => {
     {
       laporan: sanksi.laporan._id,
       _id: sanksi._id,
+      perbaikan: { $exists: true, $ne: [] },
       ['pengajuan.cabut_sanksi']: { $exists: false, $eq: null },
     },
     {

+ 1 - 4
controller/sanksi/perbaikan.controller.js

@@ -34,10 +34,7 @@ exports.add = handleError(async (req, res) => {
     {
       laporan: sanksi.laporan._id,
       _id: sanksi._id,
-      $or: [
-        { ['pengajuan.banding']: { $exists: true, $ne: null } },
-        { ['pengajuan.cabut_sanksi']: { $exists: true, $ne: null } },
-      ],
+      ['pengajuan.banding']: { $exists: true, $ne: null },
     },
     {
       $push: {