fix sendMail: sustituido modelo Journey por BusinessSchedule
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-06-02 12:22:27 +02:00
parent c05d6bb9a1
commit 186ec2ea41
3 changed files with 19 additions and 19 deletions

View File

@ -230,21 +230,21 @@ module.exports = Self => {
}, myOptions); }, myOptions);
} else { } else {
const weekDay = day.dated.getDay(); const weekDay = day.dated.getDay();
const journeys = await models.Journey.find({ const journeys = await models.BusinessSchedule.find({
where: { where: {
business_id: day.businessFk, businessFk: day.businessFk,
day_id: weekDay weekday: weekDay
} }
}, myOptions); }, myOptions);
let timeTableDecimalInSeconds = 0; let timeTableDecimalInSeconds = 0;
for (let journey of journeys) { for (let journey of journeys) {
const start = Date.vnNew(); const start = Date.vnNew();
const [startHours, startMinutes, startSeconds] = getTime(journey.start); const [startHours, startMinutes, startSeconds] = getTime(journey.started);
start.setHours(startHours, startMinutes, startSeconds, 0); start.setHours(startHours, startMinutes, startSeconds, 0);
const end = Date.vnNew(); const end = Date.vnNew();
const [endHours, endMinutes, endSeconds] = getTime(journey.end); const [endHours, endMinutes, endSeconds] = getTime(journey.ended);
end.setHours(endHours, endMinutes, endSeconds, 0); end.setHours(endHours, endMinutes, endSeconds, 0);
const result = (end - start) / 1000; const result = (end - start) / 1000;
@ -255,7 +255,7 @@ module.exports = Self => {
const timeTableDecimal = timeTableDecimalInSeconds / 3600; const timeTableDecimal = timeTableDecimalInSeconds / 3600;
if (day.timeWorkDecimal == timeTableDecimal) { if (day.timeWorkDecimal == timeTableDecimal) {
const timed = new Date(day.dated); const timed = new Date(day.dated);
const [startHours, startMinutes, startSeconds] = getTime(journey.start); const [startHours, startMinutes, startSeconds] = getTime(journey.started);
await models.WorkerTimeControl.create({ await models.WorkerTimeControl.create({
userFk: day.workerFk, userFk: day.workerFk,
timed: timed.setHours(startHours, startMinutes, startSeconds), timed: timed.setHours(startHours, startMinutes, startSeconds),
@ -263,7 +263,7 @@ module.exports = Self => {
isSendMail: true isSendMail: true
}, myOptions); }, myOptions);
const [endHours, endMinutes, endSeconds] = getTime(journey.end); const [endHours, endMinutes, endSeconds] = getTime(journey.ended);
await models.WorkerTimeControl.create({ await models.WorkerTimeControl.create({
userFk: day.workerFk, userFk: day.workerFk,
timed: timed.setHours(endHours, endMinutes, endSeconds), timed: timed.setHours(endHours, endMinutes, endSeconds),
@ -276,7 +276,7 @@ module.exports = Self => {
}); });
if (journey == minStart) { if (journey == minStart) {
const timed = new Date(day.dated); const timed = new Date(day.dated);
const [startHours, startMinutes, startSeconds] = getTime(journey.start); const [startHours, startMinutes, startSeconds] = getTime(journey.started);
await models.WorkerTimeControl.create({ await models.WorkerTimeControl.create({
userFk: day.workerFk, userFk: day.workerFk,
timed: timed.setHours(startHours, startMinutes, startSeconds), timed: timed.setHours(startHours, startMinutes, startSeconds),
@ -304,7 +304,7 @@ module.exports = Self => {
}); });
if (journey == minStart) { if (journey == minStart) {
const timed = new Date(day.dated); const timed = new Date(day.dated);
const [startHours, startMinutes, startSeconds] = getTime(journey.start); const [startHours, startMinutes, startSeconds] = getTime(journey.started);
await models.WorkerTimeControl.create({ await models.WorkerTimeControl.create({
userFk: day.workerFk, userFk: day.workerFk,
timed: timed.setHours(startHours + 1, startMinutes, startSeconds), timed: timed.setHours(startHours + 1, startMinutes, startSeconds),

View File

@ -2,6 +2,9 @@
"AbsenceType": { "AbsenceType": {
"dataSource": "vn" "dataSource": "vn"
}, },
"BusinessSchedule": {
"dataSource": "vn"
},
"Calendar": { "Calendar": {
"dataSource": "vn" "dataSource": "vn"
}, },
@ -38,9 +41,6 @@
"EducationLevel": { "EducationLevel": {
"dataSource": "vn" "dataSource": "vn"
}, },
"Journey": {
"dataSource": "vn"
},
"ProfileType":{ "ProfileType":{
"dataSource": "vn" "dataSource": "vn"
}, },

View File

@ -1,26 +1,26 @@
{ {
"name": "Journey", "name": "BusinessSchedule",
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "postgresql.journey" "table": "vn.businessSchedule"
} }
}, },
"properties": { "properties": {
"journey_id": { "id": {
"id": true, "id": true,
"type": "number" "type": "number"
}, },
"day_id": { "weekday": {
"type": "number" "type": "number"
}, },
"start": { "started": {
"type": "date" "type": "date"
}, },
"end": { "ended": {
"type": "date" "type": "date"
}, },
"business_id": { "businessFk": {
"type": "number" "type": "number"
} }
} }