From 10b23858dab69da5ad2340048f632b6e6568f416 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Wed, 14 Jun 2023 11:46:59 -0300 Subject: [PATCH 01/18] =?UTF-8?q?fga-eps-mds/2023-1-CAPJu-Doc#68)=20-=20Ad?= =?UTF-8?q?iciona=20migration=20de=20adi=C3=A7=C3=A3o=20de=20coluna=20na?= =?UTF-8?q?=20tabela=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30614132802-add-progress-column-in-process.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/database/migrations/20230614132802-add-progress-column-in-process.js diff --git a/src/database/migrations/20230614132802-add-progress-column-in-process.js b/src/database/migrations/20230614132802-add-progress-column-in-process.js new file mode 100644 index 00000000..fc5272de --- /dev/null +++ b/src/database/migrations/20230614132802-add-progress-column-in-process.js @@ -0,0 +1,16 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('process', 'progress', { + type: Sequelize.ARRAY(Sequelize.JSON), + allowNull: true, + defaultValue: null, + }); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('process', 'progress'); + } +}; \ No newline at end of file From bee79ade838a407bbb9b9251f25c6a0b91b015ea Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Wed, 14 Jun 2023 11:48:10 -0300 Subject: [PATCH 02/18] fga-eps-mds/2023-1-CAPJu-Doc#68) - Adiciona retorno da coluna progress na busca por processos --- src/controllers/ProcessController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 71b592a6..be6eb377 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -67,6 +67,7 @@ class ProcessController { idPriority: process.idPriority, idFlow: flowProcessesIdFlows, status: process.status, + progress: process.progress }); } @@ -78,7 +79,6 @@ class ProcessController { .json({ processes: processesWithFlows, totalPages }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro ao buscar processos", From a14fb7672c22cf96b6f3abce8046af4a3db447ec Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Wed, 14 Jun 2023 11:48:51 -0300 Subject: [PATCH 03/18] fga-eps-mds/2023-1-CAPJu-Doc#68) - Adiciona na model de process a referencia para a nova coluna criada --- src/models/Process.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/models/Process.js b/src/models/Process.js index b71e3194..9dd906f3 100644 --- a/src/models/Process.js +++ b/src/models/Process.js @@ -34,11 +34,15 @@ class Process extends Model { }, status: { type: DataTypes.ENUM({ - values: ["inProgress", "archived", "finished", "notStarted"], + values: ['inProgress', 'archived', 'finished', 'notStarted'] }), allowNull: false, defaultValue: "notStarted", }, + progress: { + type: DataTypes.ARRAY(DataTypes.JSON), + allowNull: true, + } }, { sequelize, From 370510a32465cbbf22b4999c237ba76f8f014fdd Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Wed, 14 Jun 2023 23:24:21 -0300 Subject: [PATCH 04/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Adiciona mapeamento de entrada de processo em etapa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vinícius Vieira de Souza Co-authored-by: harry-cmartin Co-authored-by: GuilhermeDSa1013 --- src/controllers/ProcessController.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index be6eb377..123c2e46 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -3,6 +3,7 @@ import FlowStage from "../models/FlowStage.js"; import Priority from "../models/Priority.js"; import Process from "../models/Process.js"; import Flow from "../models/Flow.js"; +import Stage from "../models/Stage.js" import Database from "../database/index.js"; import { QueryTypes } from "sequelize"; import { tokenToUser } from "../middleware/authMiddleware.js"; @@ -355,10 +356,45 @@ class ProcessController { message: `Não há a transição da etapa '${to}' para '${from}' no fluxo '${idFlow}'`, }); } + + // BUSCAR O PROCESSO + const currentProcess = await Process.findOne({ + where: { record } + }); + + let tempProgress = [] + let maturityDate; + let stageStartDate; + let stageEndDate; + let progressData = {} + + if (from < to) { + const currentStage = await Stage.findOne({ + where: { idStage: from } + }) + stageStartDate = new Date(); + stageEndDate = new Date(stageStartDate); + stageEndDate.setDate(stageEndDate.getDate() + (currentStage.duration + 1)); + maturityDate = stageEndDate.toLocaleString("pt-BR", { + year: "numeric", + month: "long", + day: "numeric", + }); + + progressData = { + idStage: to, + entrada: new Date(), + vencimento: maturityDate, + } + tempProgress = currentProcess.progress; + tempProgress.push(progressData); + } + const process = await Process.update( { idStage: to, effectiveDate: new Date(), + progress: tempProgress }, { where: { From 1fe9089da5961fb99de011e349a0f4f8f354f528 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Thu, 15 Jun 2023 22:14:27 -0300 Subject: [PATCH 05/18] (fga-eps-mds/2023-1-Capju-Doc#68) - Adiciona retorno de data formatado e muda valor default da migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vinícius Vieira de Souza Co-authored-by: harry-cmartin Co-authored-by: GuilhermeDSa1013 --- src/controllers/ProcessController.js | 6 +++++- .../20230614132802-add-progress-column-in-process.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 123c2e46..143e764c 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -383,7 +383,11 @@ class ProcessController { progressData = { idStage: to, - entrada: new Date(), + entrada: new Date().toLocaleString("pt-BR", { + year: "numeric", + month: "long", + day: "numeric", + }), vencimento: maturityDate, } tempProgress = currentProcess.progress; diff --git a/src/database/migrations/20230614132802-add-progress-column-in-process.js b/src/database/migrations/20230614132802-add-progress-column-in-process.js index fc5272de..c70563ba 100644 --- a/src/database/migrations/20230614132802-add-progress-column-in-process.js +++ b/src/database/migrations/20230614132802-add-progress-column-in-process.js @@ -6,7 +6,7 @@ module.exports = { await queryInterface.addColumn('process', 'progress', { type: Sequelize.ARRAY(Sequelize.JSON), allowNull: true, - defaultValue: null, + defaultValue: [], }); }, From 60d2f7f9a17a9abebb0b73d6b137ae1cc8b765f2 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Sat, 17 Jun 2023 11:15:12 -0300 Subject: [PATCH 06/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Adiciona retrocesso de etapa --- src/app.js | 2 +- src/controllers/ProcessController.js | 43 ++++++++++++++++------------ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/app.js b/src/app.js index d39394f0..8ab43041 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,7 @@ app.use(express.urlencoded({ extended: true })); const app_route = process.env.API_ENV || "dev"; -app.use(`/${app_route}`, routes); +app.use(`/`, routes); cron.schedule("0 0 0 * * *", () => { Emailer.sendEmail(); diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 143e764c..3b427cfb 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -357,31 +357,25 @@ class ProcessController { }); } - // BUSCAR O PROCESSO const currentProcess = await Process.findOne({ where: { record } }); - + const currentStage = await Stage.findOne({ + where: { idStage: to } + }) let tempProgress = [] let maturityDate; - let stageStartDate; - let stageEndDate; - let progressData = {} + const stageStartDate = new Date(); + const stageEndDate = new Date(stageStartDate); + stageEndDate.setDate(stageEndDate.getDate() + (currentStage.duration + 1)); + maturityDate = stageEndDate.toLocaleString("pt-BR", { + year: "numeric", + month: "long", + day: "numeric", + }); if (from < to) { - const currentStage = await Stage.findOne({ - where: { idStage: from } - }) - stageStartDate = new Date(); - stageEndDate = new Date(stageStartDate); - stageEndDate.setDate(stageEndDate.getDate() + (currentStage.duration + 1)); - maturityDate = stageEndDate.toLocaleString("pt-BR", { - year: "numeric", - month: "long", - day: "numeric", - }); - - progressData = { + const progressData = { idStage: to, entrada: new Date().toLocaleString("pt-BR", { year: "numeric", @@ -392,6 +386,18 @@ class ProcessController { } tempProgress = currentProcess.progress; tempProgress.push(progressData); + } else { + tempProgress = currentProcess.progress; + tempProgress.pop(); + tempProgress[tempProgress.length - 1] = { + idStage: to, + entrada: new Date().toLocaleString("pt-BR", { + year: "numeric", + month: "long", + day: "numeric", + }), + vencimento: maturityDate, + } } const process = await Process.update( @@ -407,7 +413,6 @@ class ProcessController { }, } ); - console.log(process[0]); if (process[0] > 0) { return res.status(200).json({ message: "Etapa atualizada com sucesso", From 3cd70339359b952a45fcbdb7f16abef7e1da9b31 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Tue, 20 Jun 2023 17:08:31 -0300 Subject: [PATCH 07/18] =?UTF-8?q?feat:=20adiciona=20verifica=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20dia=20=C3=BAtil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GuilhermeDSa1013 Co-authored-by: harry-cmartin --- src/controllers/ProcessController.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 3b427cfb..ed9154fe 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -18,6 +18,23 @@ const recordFilter = (record) => { return record.replace(regex, ""); }; +const IsUtilDay = (data) => { + const diaDaSemana = data.getDay(); + return diaDaSemana >= 1 && diaDaSemana <= 5; +} + +const handleVerifyDate = (startDate, duration) => { + let days = 0; + while (duration > 0) { + startDate.setDate(startDate.getDate() + 1); + if (IsUtilDay(startDate)) { + duration--; + } + days++; + } + return days; +} + const validateRecord = (record) => { const filtered = recordFilter(record); return { @@ -367,7 +384,8 @@ class ProcessController { let maturityDate; const stageStartDate = new Date(); const stageEndDate = new Date(stageStartDate); - stageEndDate.setDate(stageEndDate.getDate() + (currentStage.duration + 1)); + stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentStage.duration))); + maturityDate = stageEndDate.toLocaleString("pt-BR", { year: "numeric", month: "long", From 3b12c2006bbf5eb5c362dd9a7280f204c9e4fc06 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Tue, 20 Jun 2023 22:42:15 -0300 Subject: [PATCH 08/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Adiciona data de entrada no inicio do processo Co-authored-by: harry-cmartin Co-authored-by: GuilhermeDSa1013 --- src/app.js | 2 +- src/controllers/ProcessController.js | 44 ++++++++++++++++------------ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/app.js b/src/app.js index 8ab43041..d39394f0 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,7 @@ app.use(express.urlencoded({ extended: true })); const app_route = process.env.API_ENV || "dev"; -app.use(`/`, routes); +app.use(`/${app_route}`, routes); cron.schedule("0 0 0 * * *", () => { Emailer.sendEmail(); diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index ed9154fe..b7da2e7b 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -276,17 +276,35 @@ class ProcessController { const startingProcess = process.status === "notStarted" && status === "inProgress" ? { - idStage: flowStages[0].idStageA, - effectiveDate: new Date(), - } + idStage: flowStages[0].idStageA, + effectiveDate: new Date(), + } : {}; + let tempProgress = [] + if (process.status === "notStarted" && status === "inProgress") { + const currentStage = await Stage.findOne({ + where: { idStage: flowStages[0].idStageA } + }) + + const stageStartDate = new Date(); + const stageEndDate = new Date(stageStartDate); + stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentStage.duration))); + + const progressData = { + idStage: flowStages[0].idStageA, + entrada: new Date(), + vencimento: stageEndDate, + } + tempProgress.push(progressData); + } process.set({ nickname, idStage: idStage || process.idStage, idPriority: priority, status, - ...startingProcess, + progress: tempProgress, + ...startingProcess }); await process.save(); @@ -386,20 +404,12 @@ class ProcessController { const stageEndDate = new Date(stageStartDate); stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentStage.duration))); - maturityDate = stageEndDate.toLocaleString("pt-BR", { - year: "numeric", - month: "long", - day: "numeric", - }); + maturityDate = stageEndDate; if (from < to) { const progressData = { idStage: to, - entrada: new Date().toLocaleString("pt-BR", { - year: "numeric", - month: "long", - day: "numeric", - }), + entrada: new Date(), vencimento: maturityDate, } tempProgress = currentProcess.progress; @@ -409,11 +419,7 @@ class ProcessController { tempProgress.pop(); tempProgress[tempProgress.length - 1] = { idStage: to, - entrada: new Date().toLocaleString("pt-BR", { - year: "numeric", - month: "long", - day: "numeric", - }), + entrada: new Date(), vencimento: maturityDate, } } From e35f30072a366d2c0a8ce56ee6a92a6466df284e Mon Sep 17 00:00:00 2001 From: harry-cmartin Date: Wed, 21 Jun 2023 19:11:31 -0300 Subject: [PATCH 09/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) [HOTFLIX] - Resolve bug das datas ao arquivar processo. Co-authored-by: victordsantoss Co-authored-by: GuilhermeDSa1013 --- src/app.js | 2 +- src/controllers/ProcessController.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index d39394f0..8ab43041 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,7 @@ app.use(express.urlencoded({ extended: true })); const app_route = process.env.API_ENV || "dev"; -app.use(`/${app_route}`, routes); +app.use(`/`, routes); cron.schedule("0 0 0 * * *", () => { Emailer.sendEmail(); diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index b7da2e7b..c62d4b1f 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -296,6 +296,8 @@ class ProcessController { vencimento: stageEndDate, } tempProgress.push(progressData); + }else{ + tempProgress = process.progress; } process.set({ From 29845c83039e739fbca3b5e44aba55d5b5badf4f Mon Sep 17 00:00:00 2001 From: harry-cmartin Date: Thu, 22 Jun 2023 17:00:39 -0300 Subject: [PATCH 10/18] (fga-eps-mds/2023-1-CAPJu-Service#68) - HOTFLIX - Resolve e atualiza bugs das datas. Co-authored-by: Wellington Jonathan Co-authored-by: victordsantoss Co-authored-by: GuilhermeDSa1013 --- src/controllers/ProcessController.js | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index c62d4b1f..08b03482 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -296,7 +296,7 @@ class ProcessController { vencimento: stageEndDate, } tempProgress.push(progressData); - }else{ + } else { tempProgress = process.progress; } @@ -397,14 +397,19 @@ class ProcessController { const currentProcess = await Process.findOne({ where: { record } }); - const currentStage = await Stage.findOne({ + const currentToStage = await Stage.findOne({ where: { idStage: to } }) + + const currentFromStage = await Stage.findOne({ + where: { idStage: from } + }) + let tempProgress = [] let maturityDate; const stageStartDate = new Date(); const stageEndDate = new Date(stageStartDate); - stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentStage.duration))); + stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentToStage.duration))); maturityDate = stageEndDate; @@ -417,12 +422,22 @@ class ProcessController { tempProgress = currentProcess.progress; tempProgress.push(progressData); } else { - tempProgress = currentProcess.progress; - tempProgress.pop(); - tempProgress[tempProgress.length - 1] = { - idStage: to, - entrada: new Date(), - vencimento: maturityDate, + if (currentFromStage.createdAt > currentToStage.createdAt) { + const progressData = { + idStage: to, + entrada: new Date(), + vencimento: maturityDate, + } + tempProgress = currentProcess.progress; + tempProgress.push(progressData); + } else { + tempProgress = currentProcess.progress; + tempProgress.pop(); + tempProgress[tempProgress.length - 1] = { + idStage: to, + entrada: new Date(), + vencimento: maturityDate, + } } } From 6a389f7cbd0e360d684b66089951afc96ba12dca Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Mon, 26 Jun 2023 11:33:21 -0300 Subject: [PATCH 11/18] =?UTF-8?q?(fga-eps-mds/2023-1-CAPJu-Doc#68)=20-=20A?= =?UTF-8?q?tualiza=20rota=20padr=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index 8ab43041..d39394f0 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,7 @@ app.use(express.urlencoded({ extended: true })); const app_route = process.env.API_ENV || "dev"; -app.use(`/`, routes); +app.use(`/${app_route}`, routes); cron.schedule("0 0 0 * * *", () => { Emailer.sendEmail(); From 9469a1b1ba4c9e3aad8c3138129bfe0d6ae09473 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Mon, 26 Jun 2023 11:50:28 -0300 Subject: [PATCH 12/18] =?UTF-8?q?(fga-eps-mds/2023-1-CAPJu-Doc#68)=20-=20F?= =?UTF-8?q?ormata=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sérgio Cipriano --- src/controllers/ProcessController.js | 54 ++++++++++--------- src/controllers/UserContoller.js | 2 - ...14132802-add-progress-column-in-process.js | 10 ++-- src/models/Process.js | 4 +- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 08b03482..1f6121ea 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -3,7 +3,7 @@ import FlowStage from "../models/FlowStage.js"; import Priority from "../models/Priority.js"; import Process from "../models/Process.js"; import Flow from "../models/Flow.js"; -import Stage from "../models/Stage.js" +import Stage from "../models/Stage.js"; import Database from "../database/index.js"; import { QueryTypes } from "sequelize"; import { tokenToUser } from "../middleware/authMiddleware.js"; @@ -21,7 +21,7 @@ const recordFilter = (record) => { const IsUtilDay = (data) => { const diaDaSemana = data.getDay(); return diaDaSemana >= 1 && diaDaSemana <= 5; -} +}; const handleVerifyDate = (startDate, duration) => { let days = 0; @@ -33,7 +33,7 @@ const handleVerifyDate = (startDate, duration) => { days++; } return days; -} +}; const validateRecord = (record) => { const filtered = recordFilter(record); @@ -85,7 +85,7 @@ class ProcessController { idPriority: process.idPriority, idFlow: flowProcessesIdFlows, status: process.status, - progress: process.progress + progress: process.progress, }); } @@ -276,25 +276,28 @@ class ProcessController { const startingProcess = process.status === "notStarted" && status === "inProgress" ? { - idStage: flowStages[0].idStageA, - effectiveDate: new Date(), - } + idStage: flowStages[0].idStageA, + effectiveDate: new Date(), + } : {}; - let tempProgress = [] + let tempProgress = []; if (process.status === "notStarted" && status === "inProgress") { const currentStage = await Stage.findOne({ - where: { idStage: flowStages[0].idStageA } - }) + where: { idStage: flowStages[0].idStageA }, + }); const stageStartDate = new Date(); const stageEndDate = new Date(stageStartDate); - stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentStage.duration))); + stageEndDate.setDate( + stageEndDate.getDate() + + handleVerifyDate(stageStartDate, currentStage.duration) + ); const progressData = { idStage: flowStages[0].idStageA, entrada: new Date(), vencimento: stageEndDate, - } + }; tempProgress.push(progressData); } else { tempProgress = process.progress; @@ -306,7 +309,7 @@ class ProcessController { idPriority: priority, status, progress: tempProgress, - ...startingProcess + ...startingProcess, }); await process.save(); @@ -395,21 +398,24 @@ class ProcessController { } const currentProcess = await Process.findOne({ - where: { record } + where: { record }, }); const currentToStage = await Stage.findOne({ - where: { idStage: to } - }) + where: { idStage: to }, + }); const currentFromStage = await Stage.findOne({ - where: { idStage: from } - }) + where: { idStage: from }, + }); - let tempProgress = [] + let tempProgress = []; let maturityDate; const stageStartDate = new Date(); const stageEndDate = new Date(stageStartDate); - stageEndDate.setDate(stageEndDate.getDate() + (handleVerifyDate(stageStartDate, currentToStage.duration))); + stageEndDate.setDate( + stageEndDate.getDate() + + handleVerifyDate(stageStartDate, currentToStage.duration) + ); maturityDate = stageEndDate; @@ -418,7 +424,7 @@ class ProcessController { idStage: to, entrada: new Date(), vencimento: maturityDate, - } + }; tempProgress = currentProcess.progress; tempProgress.push(progressData); } else { @@ -427,7 +433,7 @@ class ProcessController { idStage: to, entrada: new Date(), vencimento: maturityDate, - } + }; tempProgress = currentProcess.progress; tempProgress.push(progressData); } else { @@ -437,7 +443,7 @@ class ProcessController { idStage: to, entrada: new Date(), vencimento: maturityDate, - } + }; } } @@ -445,7 +451,7 @@ class ProcessController { { idStage: to, effectiveDate: new Date(), - progress: tempProgress + progress: tempProgress, }, { where: { diff --git a/src/controllers/UserContoller.js b/src/controllers/UserContoller.js index 0fea5396..b077d7ab 100644 --- a/src/controllers/UserContoller.js +++ b/src/controllers/UserContoller.js @@ -176,8 +176,6 @@ class UserController { }); return res.json(user); } catch (error) { - console.log(error); - if (error.name === "SequelizeUniqueConstraintError") { const errorMessages = { cpf: "Este CPF já foi cadastrado na plataforma.", diff --git a/src/database/migrations/20230614132802-add-progress-column-in-process.js b/src/database/migrations/20230614132802-add-progress-column-in-process.js index c70563ba..91cc8039 100644 --- a/src/database/migrations/20230614132802-add-progress-column-in-process.js +++ b/src/database/migrations/20230614132802-add-progress-column-in-process.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; /** @type {import('sequelize-cli').Migration} */ module.exports = { up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('process', 'progress', { + await queryInterface.addColumn("process", "progress", { type: Sequelize.ARRAY(Sequelize.JSON), allowNull: true, defaultValue: [], @@ -11,6 +11,6 @@ module.exports = { }, down: async (queryInterface, Sequelize) => { - await queryInterface.removeColumn('process', 'progress'); - } -}; \ No newline at end of file + await queryInterface.removeColumn("process", "progress"); + }, +}; diff --git a/src/models/Process.js b/src/models/Process.js index 9dd906f3..62ef4355 100644 --- a/src/models/Process.js +++ b/src/models/Process.js @@ -34,7 +34,7 @@ class Process extends Model { }, status: { type: DataTypes.ENUM({ - values: ['inProgress', 'archived', 'finished', 'notStarted'] + values: ["inProgress", "archived", "finished", "notStarted"], }), allowNull: false, defaultValue: "notStarted", @@ -42,7 +42,7 @@ class Process extends Model { progress: { type: DataTypes.ARRAY(DataTypes.JSON), allowNull: true, - } + }, }, { sequelize, From dd609d888f0c922545e1c4334254b3fec434f227 Mon Sep 17 00:00:00 2001 From: Sergio de Almeida Cipriano Junior Date: Sat, 1 Jul 2023 15:33:25 -0300 Subject: [PATCH 13/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Migration de progresso corrigida --- .../20230614132802-add-progress-column-in-process.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database/migrations/20230614132802-add-progress-column-in-process.js b/src/database/migrations/20230614132802-add-progress-column-in-process.js index 91cc8039..d61cbb49 100644 --- a/src/database/migrations/20230614132802-add-progress-column-in-process.js +++ b/src/database/migrations/20230614132802-add-progress-column-in-process.js @@ -4,9 +4,9 @@ module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.addColumn("process", "progress", { - type: Sequelize.ARRAY(Sequelize.JSON), + type: Sequelize.JSON, allowNull: true, - defaultValue: [], + defaultValue: JSON.stringify([]), }); }, From 6e753e3b8a69423a21fcd93dcbaf41a1d2865c1f Mon Sep 17 00:00:00 2001 From: Sergio de Almeida Cipriano Junior Date: Sat, 1 Jul 2023 15:33:51 -0300 Subject: [PATCH 14/18] =?UTF-8?q?(fga-eps-mds/2023-1-CAPJu-Doc#68)=20-=20R?= =?UTF-8?q?emove=20console.log=20desnecess=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/Emailer.js | 4 ---- src/controllers/FlowController.js | 11 ----------- src/controllers/ProcessController.js | 9 --------- src/controllers/RoleController.js | 1 - src/controllers/StageController.js | 1 - src/controllers/UnitController.js | 4 ---- src/controllers/UserContoller.js | 7 ------- src/tests/__tests__/test_emailer.js | 8 -------- src/tests/__tests__/test_flow_routes.js | 2 -- src/tests/__tests__/test_process_routes.js | 3 ++- src/tests/__tests__/test_user_routes.js | 4 ---- src/tests/__tests__/teste_role_routes.js | 1 - 12 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/controllers/Emailer.js b/src/controllers/Emailer.js index 226dc91e..8ad0fbb5 100644 --- a/src/controllers/Emailer.js +++ b/src/controllers/Emailer.js @@ -25,7 +25,6 @@ export async function getMailContents() { }); return mailContents; } catch (error) { - console.log(error); return { error, message: "Erro ao obter conteúdo dos emails", @@ -40,11 +39,9 @@ export async function sendEmail() { json = await getMailContents(); if (json.length == 0) { - console.log("Não há processos atrasados"); return true; } if (!senha) { - console.log("Não há senha"); return false; } @@ -199,7 +196,6 @@ export async function sendEmail() { transport.sendMail(message); process = []; } catch (err) { - console.log("Error occurred. " + err.message); return false; } } diff --git a/src/controllers/FlowController.js b/src/controllers/FlowController.js index 584702e7..2065d18d 100644 --- a/src/controllers/FlowController.js +++ b/src/controllers/FlowController.js @@ -131,7 +131,6 @@ class FlowController { message: `Não há fluxos com o processo '${record}'`, }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: `Erro ao buscar fluxos do processo ${record}`, @@ -181,12 +180,10 @@ class FlowController { flowsWithSequences.push(flowSequence); } - console.log("aquii pelo amor"); return res .status(200) .json({ flows: flowsWithSequences || [], totalPages }); } catch (error) { - console.log(error); return res .status(500) .json({ error, message: "Impossível obter fluxos" }); @@ -218,7 +215,6 @@ class FlowController { return res.status(200).json(flowSequence); } catch (error) { - console.log(error); return res.status(500).json({ error, message: `Impossível obter fluxo ${idFlow}`, @@ -258,7 +254,6 @@ class FlowController { sequences: sequences, }); } catch (error) { - console.log(error); return res .status(500) .json({ error, message: "Impossível ler sequências" }); @@ -277,7 +272,6 @@ class FlowController { return res.status(200).json(flowStages); } catch (error) { - console.log(error); return res .status(500) .json({ error, message: "Erro ao ler fluxos ligados a etapas" }); @@ -304,7 +298,6 @@ class FlowController { res.status(200).json({ usersToNotify: result }); } catch (error) { - console.log(error); res.status(500).json({ error, message: "Impossível obter usuários que devem ser notificados no fluxo", @@ -327,7 +320,6 @@ class FlowController { ? res.status(status).json(json) : res.status(status).json({ message }); } catch (error) { - console.log(error); return res.status(500).json({ error: "Impossível criar fluxo" }); } } @@ -368,7 +360,6 @@ class FlowController { : res.status(status).json({ message }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Impossível criar fluxo" }); } } @@ -392,7 +383,6 @@ class FlowController { return res.status(404).json({ message: "Fluxo não encontrado" }); } } catch (error) { - console.log(error); return res .status(500) .json({ error, message: "Impossível apagar fluxo" }); @@ -417,7 +407,6 @@ class FlowController { message: `Desassociação entre fluxo '${idFlow}' e etapas '${idStageA}' e '${idStageB}' concluída`, }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: `Falha ao desassociar fluxo '${idFlow}' e etapas '${idStageA}' e '${idStageB}'`, diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 1f6121ea..0778b431 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -155,7 +155,6 @@ class ProcessController { return res.json(process); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: `Erro ao procurar processo ${idProcess}`, @@ -199,13 +198,11 @@ class ProcessController { .json({ message: "Criado com sucesso!", flowProcess }); } } catch (error) { - console.log(error); return res.status(500).json(error); } } return res.status(404).json({ message: "Erro na criação de processo" }); } catch (error) { - console.log(error); return res.status(500).json(error); } } @@ -237,7 +234,6 @@ class ProcessController { return res.status(200).json(processes); } catch (error) { - console.log(error); return res .status(500) .json({ error, message: "Erro ao buscar processos" }); @@ -330,7 +326,6 @@ class ProcessController { return res.status(200).json({ process, flows: flowProcesses }); } catch (error) { - console.log(error); return res.status(500).json(error); } } @@ -350,7 +345,6 @@ class ProcessController { return res.status(200).json({ message: "OK" }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Impossível apagar" }); } } @@ -471,7 +465,6 @@ class ProcessController { message: `Impossível atualizar processo '${record}' para etapa '${to}`, }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: `Erro ao atualizar processo '${record}' para etapa '${to}`, @@ -516,12 +509,10 @@ class ProcessController { } ); - console.log("updateResult = ", updateResult); return res.status(200).json({ message: "Comentário adicionado com sucesso", }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Falha ao adicionar comentário", diff --git a/src/controllers/RoleController.js b/src/controllers/RoleController.js index 36146728..04f00e53 100644 --- a/src/controllers/RoleController.js +++ b/src/controllers/RoleController.js @@ -63,7 +63,6 @@ class RoleController { }); return res.json(role); } catch (error) { - console.log(error); return res.status(error).json(error); } } diff --git a/src/controllers/StageController.js b/src/controllers/StageController.js index 9048bd21..4f0ff37c 100644 --- a/src/controllers/StageController.js +++ b/src/controllers/StageController.js @@ -51,7 +51,6 @@ class StageController { return res.json(stage); } catch (error) { - console.log(error); return res.status(error).json(error); } } diff --git a/src/controllers/UnitController.js b/src/controllers/UnitController.js index f4535e6d..e4dcb711 100644 --- a/src/controllers/UnitController.js +++ b/src/controllers/UnitController.js @@ -13,7 +13,6 @@ class UnitController { const totalPages = Math.ceil(totalCount / parseInt(req.query.limit, 10)); return res.json({ units: units || [], totalPages }); } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro ao listar unidades", @@ -29,7 +28,6 @@ class UnitController { }); return res.json(unit); } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro ao criar unidade", @@ -127,7 +125,6 @@ class UnitController { }; return res.status(200).json(userNoPassword); } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro ao configurar usuário como administrador", @@ -154,7 +151,6 @@ class UnitController { await user.save(); return res.status(200).json(user); } catch (error) { - console.log(error); return res.status(500).json({ error: "Erro ao configurar usuário como administrador", }); diff --git a/src/controllers/UserContoller.js b/src/controllers/UserContoller.js index b077d7ab..1a204617 100644 --- a/src/controllers/UserContoller.js +++ b/src/controllers/UserContoller.js @@ -46,7 +46,6 @@ class UserController { }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "erro inesperado" }); } } @@ -153,7 +152,6 @@ class UserController { return res.status(200).json({ users: mappedUsers || [] }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro ao listar usuários aceitos ou não", @@ -213,7 +211,6 @@ class UserController { }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Impossível atualizar email", @@ -238,7 +235,6 @@ class UserController { }); } } catch (error) { - console.log(error); return res.status(500).json({ message: "Usuário não atualizado!" }); } } @@ -264,7 +260,6 @@ class UserController { return res.status(400).json({ message: "Senha inválida!" }); } } catch (error) { - console.log(error); return res.status(500).json({ error, message: "Erro a atualizar usuário ", @@ -308,7 +303,6 @@ class UserController { }); } } catch (error) { - console.log("error", error); return res.status(500).json({ error, message: "Falha ao aceitar usuário", @@ -330,7 +324,6 @@ class UserController { }); } } catch (error) { - console.log("error", error); return res.status(500).json({ error, message: "Erro ao negar pedido do usuário", diff --git a/src/tests/__tests__/test_emailer.js b/src/tests/__tests__/test_emailer.js index 29a7d8fe..67834cbd 100644 --- a/src/tests/__tests__/test_emailer.js +++ b/src/tests/__tests__/test_emailer.js @@ -89,17 +89,9 @@ describe("Test for function sendEmail", () => { const result = sendEmail(); expect(result).toBeTruthy(); }); - it("Retorno dos console.log", async () => { - const mockGetMailContents = jest.fn().mockResolvedValue([]); - console.log = jest.fn(); - await sendEmail(mockGetMailContents); - expect(console.log).toHaveBeenCalledTimes(2); - }); it("should log 'Não há senha' and return false if password is not set", async () => { process.env.CAPJU_EMAIL_PASSWORD = ""; - console.log = jest.fn(); const result = await sendEmail(); - expect(console.log).toHaveBeenCalledWith("Não há senha"); expect(result).toBe(false); delete process.env.CAPJU_EMAIL_PASSWORD; }); diff --git a/src/tests/__tests__/test_flow_routes.js b/src/tests/__tests__/test_flow_routes.js index 1395ab4d..3feca6b3 100644 --- a/src/tests/__tests__/test_flow_routes.js +++ b/src/tests/__tests__/test_flow_routes.js @@ -5,8 +5,6 @@ import { app, injectDB } from "../TestApp"; import Flow from "../../models/Flow.js"; import jwt from "jsonwebtoken"; import { tokenToUser } from "../../middleware/authMiddleware.js"; -import Process from "../../models/Process.js"; -import FlowProcess from "../../models/FlowProcess.js"; describe("flow endpoints", () => { beforeEach(async () => { diff --git a/src/tests/__tests__/test_process_routes.js b/src/tests/__tests__/test_process_routes.js index 9e8c8583..8c90607c 100644 --- a/src/tests/__tests__/test_process_routes.js +++ b/src/tests/__tests__/test_process_routes.js @@ -315,11 +315,12 @@ describe("process endpoints", () => { .put(`/processUpdateStage`) .send(processStageData); - expect(updatedProcessStage.status).toBe(200); expect(updatedProcessStage.body.message).toEqual( "Etapa atualizada com sucesso" ); + expect(updatedProcessStage.status).toBe(200); }); + test("test", async () => { const testUser = { cpf: "12345678901", diff --git a/src/tests/__tests__/test_user_routes.js b/src/tests/__tests__/test_user_routes.js index d88dc84f..87df0bdc 100644 --- a/src/tests/__tests__/test_user_routes.js +++ b/src/tests/__tests__/test_user_routes.js @@ -81,8 +81,6 @@ describe("user endpoints", () => { expect(usersDb.length).toBe(testUsers.length + 2); - console.info(usersDb); - expect(usersDb).toEqual( expect.arrayContaining( expectedTestUsers.map((etu) => { @@ -142,8 +140,6 @@ describe("user endpoints", () => { where: { accepted: true, idRole: 5 }, }); - console.info(acceptedUsersDb[0].dataValues.cpf); - // Only the administrator is accepted expect(acceptedUsersDb.length).toBe(1); expect(acceptedUsersDb[0].dataValues.cpf).toEqual(adminUser[0].cpf); diff --git a/src/tests/__tests__/teste_role_routes.js b/src/tests/__tests__/teste_role_routes.js index 2070815a..58c819f9 100644 --- a/src/tests/__tests__/teste_role_routes.js +++ b/src/tests/__tests__/teste_role_routes.js @@ -2,7 +2,6 @@ import { Database } from "../TestDatabase.js"; import "sequelize"; import supertest from "supertest"; import { app, injectDB } from "../TestApp"; -import Unit from "../../models/Unit.js"; describe("role endpoints", () => { beforeEach(async () => { From 82f7c7e93923e9a0a3637fd9277b57974d0049da Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Sat, 1 Jul 2023 20:48:22 -0300 Subject: [PATCH 15/18] feat: corrige erros --- src/controllers/ProcessController.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 0778b431..b7b44168 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -62,7 +62,7 @@ class ProcessController { }); if (!processes || processes.length === 0) { - return res.status(404).json({ error: "Não há processos" }); + return res.status(204).json({ error: "Não há processos" }); } else { const processesWithFlows = []; for (const process of processes) { @@ -272,9 +272,9 @@ class ProcessController { const startingProcess = process.status === "notStarted" && status === "inProgress" ? { - idStage: flowStages[0].idStageA, - effectiveDate: new Date(), - } + idStage: flowStages[0].idStageA, + effectiveDate: new Date(), + } : {}; let tempProgress = []; if (process.status === "notStarted" && status === "inProgress") { @@ -286,7 +286,7 @@ class ProcessController { const stageEndDate = new Date(stageStartDate); stageEndDate.setDate( stageEndDate.getDate() + - handleVerifyDate(stageStartDate, currentStage.duration) + handleVerifyDate(stageStartDate, currentStage.duration) ); const progressData = { @@ -296,6 +296,8 @@ class ProcessController { }; tempProgress.push(progressData); } else { + let aux = []; + aux.push(process.progress); tempProgress = process.progress; } @@ -408,7 +410,7 @@ class ProcessController { const stageEndDate = new Date(stageStartDate); stageEndDate.setDate( stageEndDate.getDate() + - handleVerifyDate(stageStartDate, currentToStage.duration) + handleVerifyDate(stageStartDate, currentToStage.duration) ); maturityDate = stageEndDate; @@ -419,7 +421,7 @@ class ProcessController { entrada: new Date(), vencimento: maturityDate, }; - tempProgress = currentProcess.progress; + tempProgress = Array.isArray(currentProcess.progress) ? currentProcess.progress : [currentProcess.progress]; tempProgress.push(progressData); } else { if (currentFromStage.createdAt > currentToStage.createdAt) { From f635d7c27f20f0e3cd84c6352aa958e7ab0e3430 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Sat, 1 Jul 2023 22:25:00 -0300 Subject: [PATCH 16/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Corrige erros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sérgio Cipriano Co-authored-by: Vinícius Vieira de Souza --- src/controllers/ProcessController.js | 41 ++++++++----------- ...14132802-add-progress-column-in-process.js | 3 +- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index b7b44168..b14a5c40 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -296,8 +296,8 @@ class ProcessController { }; tempProgress.push(progressData); } else { - let aux = []; - aux.push(process.progress); + // let aux = []; + // aux.push(process.progress); tempProgress = process.progress; } @@ -328,6 +328,7 @@ class ProcessController { return res.status(200).json({ process, flows: flowProcesses }); } catch (error) { + console.log(error); return res.status(500).json(error); } } @@ -352,7 +353,7 @@ class ProcessController { } async updateProcessStage(req, res) { - const { record, from, to, idFlow } = req.body; + const { record, from, to, idFlow, isNextStage } = req.body; if ( isNaN(parseInt(from)) || @@ -415,34 +416,27 @@ class ProcessController { maturityDate = stageEndDate; - if (from < to) { + if (isNextStage) { const progressData = { idStage: to, entrada: new Date(), vencimento: maturityDate, }; - tempProgress = Array.isArray(currentProcess.progress) ? currentProcess.progress : [currentProcess.progress]; - tempProgress.push(progressData); + tempProgress = currentProcess.progress; + const index = tempProgress.findIndex(x => x.idStage == to); + index === -1 && tempProgress.push(progressData) } else { - if (currentFromStage.createdAt > currentToStage.createdAt) { - const progressData = { - idStage: to, - entrada: new Date(), - vencimento: maturityDate, - }; - tempProgress = currentProcess.progress; - tempProgress.push(progressData); - } else { - tempProgress = currentProcess.progress; - tempProgress.pop(); - tempProgress[tempProgress.length - 1] = { - idStage: to, - entrada: new Date(), - vencimento: maturityDate, - }; - } + tempProgress = currentProcess.progress; + tempProgress.pop(); + tempProgress[tempProgress.length - 1] = { + idStage: to, + entrada: new Date(), + vencimento: maturityDate, + }; } + console.log("FROM TO", currentProcess.idStage, from, to) + const process = await Process.update( { idStage: to, @@ -467,6 +461,7 @@ class ProcessController { message: `Impossível atualizar processo '${record}' para etapa '${to}`, }); } catch (error) { + console.log(error); return res.status(500).json({ error, message: `Erro ao atualizar processo '${record}' para etapa '${to}`, diff --git a/src/database/migrations/20230614132802-add-progress-column-in-process.js b/src/database/migrations/20230614132802-add-progress-column-in-process.js index d61cbb49..f8576147 100644 --- a/src/database/migrations/20230614132802-add-progress-column-in-process.js +++ b/src/database/migrations/20230614132802-add-progress-column-in-process.js @@ -4,9 +4,8 @@ module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.addColumn("process", "progress", { - type: Sequelize.JSON, + type: Sequelize.ARRAY(Sequelize.JSON), allowNull: true, - defaultValue: JSON.stringify([]), }); }, From 58e384528d7436c6bb9ad8ef1ad101a3c024ad46 Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Sat, 1 Jul 2023 22:39:38 -0300 Subject: [PATCH 17/18] (fga-eps-mds/2023-1-CAPJu-Doc#68) - Corrige erros em testes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sérgio Cipriano Co-authored-by: Vinícius Vieira de Souza --- src/controllers/ProcessController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index b14a5c40..6131ee27 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -426,7 +426,7 @@ class ProcessController { const index = tempProgress.findIndex(x => x.idStage == to); index === -1 && tempProgress.push(progressData) } else { - tempProgress = currentProcess.progress; + tempProgress = Array.isArray(currentProcess.progress) ? currentProcess.progress : [currentProcess.progres]; tempProgress.pop(); tempProgress[tempProgress.length - 1] = { idStage: to, From 74ee636a22221934b7b7601edcfb32295bc90a6a Mon Sep 17 00:00:00 2001 From: Victor Samuel dos Santos Lucas Date: Sat, 1 Jul 2023 22:42:34 -0300 Subject: [PATCH 18/18] =?UTF-8?q?(fga-eps-mds/2023-1-CAPJu-Doc#68)=20-=20C?= =?UTF-8?q?orrige=20erros=20de=20formata=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sérgio Cipriano Co-authored-by: Vinícius Vieira de Souza --- src/controllers/ProcessController.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/controllers/ProcessController.js b/src/controllers/ProcessController.js index 6131ee27..efbd16c2 100644 --- a/src/controllers/ProcessController.js +++ b/src/controllers/ProcessController.js @@ -272,9 +272,9 @@ class ProcessController { const startingProcess = process.status === "notStarted" && status === "inProgress" ? { - idStage: flowStages[0].idStageA, - effectiveDate: new Date(), - } + idStage: flowStages[0].idStageA, + effectiveDate: new Date(), + } : {}; let tempProgress = []; if (process.status === "notStarted" && status === "inProgress") { @@ -286,7 +286,7 @@ class ProcessController { const stageEndDate = new Date(stageStartDate); stageEndDate.setDate( stageEndDate.getDate() + - handleVerifyDate(stageStartDate, currentStage.duration) + handleVerifyDate(stageStartDate, currentStage.duration) ); const progressData = { @@ -411,7 +411,7 @@ class ProcessController { const stageEndDate = new Date(stageStartDate); stageEndDate.setDate( stageEndDate.getDate() + - handleVerifyDate(stageStartDate, currentToStage.duration) + handleVerifyDate(stageStartDate, currentToStage.duration) ); maturityDate = stageEndDate; @@ -423,10 +423,12 @@ class ProcessController { vencimento: maturityDate, }; tempProgress = currentProcess.progress; - const index = tempProgress.findIndex(x => x.idStage == to); - index === -1 && tempProgress.push(progressData) + const index = tempProgress.findIndex((x) => x.idStage == to); + index === -1 && tempProgress.push(progressData); } else { - tempProgress = Array.isArray(currentProcess.progress) ? currentProcess.progress : [currentProcess.progres]; + tempProgress = Array.isArray(currentProcess.progress) + ? currentProcess.progress + : [currentProcess.progres]; tempProgress.pop(); tempProgress[tempProgress.length - 1] = { idStage: to, @@ -435,7 +437,7 @@ class ProcessController { }; } - console.log("FROM TO", currentProcess.idStage, from, to) + console.log("FROM TO", currentProcess.idStage, from, to); const process = await Process.update( {