feat: refs #7335 Added call ticket_afterUpdate #2415
|
@ -21,9 +21,6 @@ BEGIN
|
||||||
|
|
||||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
||||||
|
|
||||||
-- Añadido temporalmente para ver si ya no sucede el cuelgue de db
|
|
||||||
SET vShowType = TRUE;
|
|
||||||
|
|
||||||
WITH itemTags AS (
|
WITH itemTags AS (
|
||||||
SELECT i.id,
|
SELECT i.id,
|
||||||
typeFk,
|
typeFk,
|
||||||
|
@ -82,7 +79,7 @@ BEGIN
|
||||||
AND iss.warehouseFk = vWarehouseFk
|
AND iss.warehouseFk = vWarehouseFk
|
||||||
JOIN itemTags its
|
JOIN itemTags its
|
||||||
WHERE a.available > 0
|
WHERE a.available > 0
|
||||||
AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
|
AND (i.typeFk = its.typeFk OR NOT vShowType)
|
||||||
AND i.id <> vSelf
|
AND i.id <> vSelf
|
||||||
ORDER BY `counter` DESC,
|
ORDER BY `counter` DESC,
|
||||||
(t.name = its.name) DESC,
|
(t.name = its.name) DESC,
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.absenceType ADD isFestiveEligible BOOL DEFAULT 1 NOT NULL COMMENT 'Para marcar un tipo de absence';
|
||||||
|
|
||||||
|
UPDATE vn.absenceType
|
||||||
|
SET isFestiveEligible = 0
|
||||||
|
WHERE code = 'holiday';
|
||||||
|
|
||||||
|
UPDATE vn.absenceType
|
||||||
|
SET isFestiveEligible=0
|
||||||
|
WHERE code = 'halfHoliday';
|
|
@ -226,4 +226,4 @@
|
||||||
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
|
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
|
||||||
"They're not your subordinate": "They're not your subordinate",
|
"They're not your subordinate": "They're not your subordinate",
|
||||||
"InvoiceIn is already booked": "InvoiceIn is already booked"
|
"InvoiceIn is already booked": "InvoiceIn is already booked"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true
|
"id": true
|
||||||
|
},
|
||||||
|
"workcenterFk" : {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -24,4 +27,4 @@
|
||||||
"foreignKey": "departmentFk"
|
"foreignKey": "departmentFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,22 @@ module.exports = Self => {
|
||||||
if (isHalfHoliday && hasHalfHoliday)
|
if (isHalfHoliday && hasHalfHoliday)
|
||||||
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
||||||
|
|
||||||
|
const isFestive = absenceType.isFestiveEligible;
|
||||||
|
|
||||||
|
const workCenter = await models.Business.findOne({
|
||||||
|
where: {id: args.businessFk}
|
||||||
|
},);
|
||||||
|
|
||||||
|
const [holiday] = await models.CalendarHoliday.find({
|
||||||
|
where: {
|
||||||
|
dated: args.dated,
|
||||||
|
workCenterFk: workCenter.workCenterFk
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (holiday && isFestive)
|
||||||
|
throw new UserError(`Cannot add holidays on this day`);
|
||||||
|
|
||||||
const absence = await models.Calendar.create({
|
const absence = await models.Calendar.create({
|
||||||
businessFk: labour.businessFk,
|
businessFk: labour.businessFk,
|
||||||
dayOffTypeFk: args.absenceTypeId,
|
dayOffTypeFk: args.absenceTypeId,
|
||||||
|
|
|
@ -104,6 +104,35 @@ describe('Worker createAbsence()', () => {
|
||||||
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`should throw an error when adding a "Holiday" absence if there's a festivity`, async() => {
|
||||||
|
const ctx = {
|
||||||
|
req: {accessToken: {userId: 9}},
|
||||||
|
args: {
|
||||||
|
id: 3,
|
||||||
|
businessFk: 3,
|
||||||
|
absenceTypeId: 1,
|
||||||
|
dated: '2001-12-08T23:00:00.000Z'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const workerId = 1;
|
||||||
|
|
||||||
|
const tx = await app.models.Calendar.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await app.models.Worker.createAbsence(ctx, workerId, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual(`Cannot add holidays on this day`);
|
||||||
|
});
|
||||||
|
|
||||||
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {accessToken: {userId: 19}},
|
req: {accessToken: {userId: 19}},
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
},
|
},
|
||||||
"holidayEntitlementRate": {
|
"holidayEntitlementRate": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
},
|
||||||
|
"isFestiveEligible": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
{
|
{
|
||||||
|
@ -32,4 +35,4 @@
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@
|
||||||
},
|
},
|
||||||
"isF11Allowed": {
|
"isF11Allowed": {
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
|
},
|
||||||
|
"isFreelance": {
|
||||||
|
"type" : "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
Loading…
Reference in New Issue