feat(worker_calendar): add restriction to choose "Vacaciones 1/2 día"
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2021-11-15 14:49:14 +01:00
parent 7f64f4d8ad
commit 7efb19ab83
2 changed files with 9 additions and 0 deletions

View File

@ -193,6 +193,7 @@
"Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
"None": "Ninguno",
"The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada",
"Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'",
"This document already exists on this ticket": "Este documento ya existe en el ticket",
"Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables",
"You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes",

View File

@ -65,6 +65,14 @@ module.exports = Self => {
if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended))
throw new UserError(`The contract was not active during the selected date`);
let result = await Self.rawSql(
`SELECT COUNT(*) halfDayHolidayCounter
FROM vn.calendar c
WHERE c.dayOffTypeFk = 6 AND c.businessFk = ?`, [args.businessFk]);
if (args.absenceTypeId == 6 && result[0].halfDayHolidayCounter > 0)
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
const absence = await models.Calendar.create({
businessFk: labour.businessFk,
dayOffTypeFk: args.absenceTypeId,