From 186ec2ea41c459097b21973bd546e17e6736a15b Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 12:22:27 +0200 Subject: [PATCH 1/2] fix sendMail: sustituido modelo Journey por BusinessSchedule --- .../methods/worker-time-control/sendMail.js | 18 +++++++++--------- modules/worker/back/model-config.json | 6 +++--- .../{journey.json => business-schedule.json} | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) rename modules/worker/back/models/{journey.json => business-schedule.json} (64%) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 2c827e320..3d57ebbbd 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -230,21 +230,21 @@ module.exports = Self => { }, myOptions); } else { const weekDay = day.dated.getDay(); - const journeys = await models.Journey.find({ + const journeys = await models.BusinessSchedule.find({ where: { - business_id: day.businessFk, - day_id: weekDay + businessFk: day.businessFk, + weekday: weekDay } }, myOptions); let timeTableDecimalInSeconds = 0; for (let journey of journeys) { const start = Date.vnNew(); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); start.setHours(startHours, startMinutes, startSeconds, 0); const end = Date.vnNew(); - const [endHours, endMinutes, endSeconds] = getTime(journey.end); + const [endHours, endMinutes, endSeconds] = getTime(journey.ended); end.setHours(endHours, endMinutes, endSeconds, 0); const result = (end - start) / 1000; @@ -255,7 +255,7 @@ module.exports = Self => { const timeTableDecimal = timeTableDecimalInSeconds / 3600; if (day.timeWorkDecimal == timeTableDecimal) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours, startMinutes, startSeconds), @@ -263,7 +263,7 @@ module.exports = Self => { isSendMail: true }, myOptions); - const [endHours, endMinutes, endSeconds] = getTime(journey.end); + const [endHours, endMinutes, endSeconds] = getTime(journey.ended); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(endHours, endMinutes, endSeconds), @@ -276,7 +276,7 @@ module.exports = Self => { }); if (journey == minStart) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours, startMinutes, startSeconds), @@ -304,7 +304,7 @@ module.exports = Self => { }); if (journey == minStart) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours + 1, startMinutes, startSeconds), diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index fd34c013b..60ec273a5 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -2,6 +2,9 @@ "AbsenceType": { "dataSource": "vn" }, + "BusinessSchedule": { + "dataSource": "vn" + }, "Calendar": { "dataSource": "vn" }, @@ -38,9 +41,6 @@ "EducationLevel": { "dataSource": "vn" }, - "Journey": { - "dataSource": "vn" - }, "ProfileType":{ "dataSource": "vn" }, diff --git a/modules/worker/back/models/journey.json b/modules/worker/back/models/business-schedule.json similarity index 64% rename from modules/worker/back/models/journey.json rename to modules/worker/back/models/business-schedule.json index b7d5f2817..8329d9291 100644 --- a/modules/worker/back/models/journey.json +++ b/modules/worker/back/models/business-schedule.json @@ -1,26 +1,26 @@ { - "name": "Journey", + "name": "BusinessSchedule", "base": "VnModel", "options": { "mysql": { - "table": "postgresql.journey" + "table": "vn.businessSchedule" } }, "properties": { - "journey_id": { + "id": { "id": true, "type": "number" }, - "day_id": { + "weekday": { "type": "number" }, - "start": { + "started": { "type": "date" }, - "end": { + "ended": { "type": "date" }, - "business_id": { + "businessFk": { "type": "number" } } From 01175a4c6c1d3ecfed42a7868422f4b005794f3f Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 12:32:34 +0200 Subject: [PATCH 2/2] quitado vn --- modules/worker/back/models/business-schedule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/business-schedule.json b/modules/worker/back/models/business-schedule.json index 8329d9291..0cc17c844 100644 --- a/modules/worker/back/models/business-schedule.json +++ b/modules/worker/back/models/business-schedule.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "vn.businessSchedule" + "table": "businessSchedule" } }, "properties": {