7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +00:00
3 changed files with 12 additions and 12 deletions
Showing only changes of commit 585a0c68a8 - Show all commits

View File

@ -1,3 +1,5 @@
const moment = require('moment');
module.exports = Self => {
Self.remoteMethodCtx('resendWeeklyHourEmail', {
description: 'Send the records for the week of the date provided',
@ -31,7 +33,8 @@ module.exports = Self => {
Object.assign(myOptions, options);
const yearNumber = dated.getFullYear();
const weekNumber = getWeekNumber(dated);
const weekNumber = moment(dated).isoWeek();
const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({
where: {
workerFk: workerId,
@ -54,15 +57,4 @@ module.exports = Self => {
return false;
};
function getWeekNumber(date) {
const tempDate = new Date(date);
let dayOfWeek = tempDate.getDay();
dayOfWeek = (dayOfWeek === 0) ? 7 : dayOfWeek;
const firstDayOfWeek = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() - (dayOfWeek - 1));
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
return weekNumber;
}
};

View File

@ -39,6 +39,7 @@
"loopback-context": "^3.5.2",
"loopback-datasource-juggler": "3.36.1",
"md5": "^2.2.1",
"moment": "^2.30.1",
"mysql": "2.18.1",
"node-ssh": "^11.0.0",
"object.pick": "^1.3.0",

View File

@ -83,6 +83,9 @@ dependencies:
md5:
specifier: ^2.2.1
version: 2.3.0
moment:
specifier: ^2.30.1
version: 2.30.1
mysql:
specifier: 2.18.1
version: 2.18.1
@ -10202,6 +10205,10 @@ packages:
to-iso-string: 0.0.2
dev: false
/moment@2.30.1:
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
dev: false
/ms@0.7.1:
resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==}
dev: false