Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker

This commit is contained in:
Jorge Penadés 2024-05-09 08:45:17 +02:00
commit dc45527e1d
14 changed files with 85 additions and 22 deletions

View File

@ -188,11 +188,12 @@ BEGIN
FROM tPendingDuedates vp
LEFT JOIN supplier s ON s.id = vp.supplierFk
LEFT JOIN client c ON c.fi = s.nif
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
AND cr.companyFk = vp.companyFk
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
LEFT JOIN country co ON co.id = be.countryFk;
LEFT JOIN country co ON co.id = be.countryFk
GROUP BY vp.id;
DROP TEMPORARY TABLE tOpeningBalances;
DROP TEMPORARY TABLE tPendingDuedates;

View File

@ -21,9 +21,6 @@ BEGIN
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 (
SELECT i.id,
typeFk,
@ -82,7 +79,7 @@ BEGIN
AND iss.warehouseFk = vWarehouseFk
JOIN itemTags its
WHERE a.available > 0
AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
AND (i.typeFk = its.typeFk OR NOT vShowType)
AND i.id <> vSelf
ORDER BY `counter` DESC,
(t.name = its.name) DESC,

View File

@ -34,7 +34,7 @@ BEGIN
ticketFk INT(11),
saleFk INT(11),
isFreezed INTEGER(1) DEFAULT 0,
risk DECIMAL(10,2) DEFAULT 0,
risk DECIMAL(10,1) DEFAULT 0,
hasHighRisk TINYINT(1) DEFAULT 0,
hasTicketRequest INTEGER(1) DEFAULT 0,
itemShortage VARCHAR(255),

View File

@ -7,7 +7,7 @@ BEGIN
*
* @param vSelf El id del ticket
*/
DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT;
DECLARE vCmrFk INT;
SELECT cmrFk INTO vCmrFk
FROM ticket
WHERE id = vSelf;
@ -44,8 +44,6 @@ BEGIN
AND t.id = vSelf
GROUP BY t.id;
START TRANSACTION;
IF vCmrFk THEN
UPDATE cmr c
JOIN tTicket t
@ -57,9 +55,7 @@ BEGIN
c.supplierFk = t.supplierFk,
c.ead = t.landed
WHERE id = vCmrFk;
ELSE
SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
ELSE
INSERT INTO cmr (
senderInstruccions,
truckPlate,
@ -70,17 +66,14 @@ BEGIN
ead
)
SELECT * FROM tTicket;
SELECT MAX(id) INTO vCurrentCmrFk FROM cmr;
IF vPreviousCmrFk <> vCurrentCmrFk THEN
IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN
UPDATE ticket
SET cmrFk = vCurrentCmrFk
SET cmrFk = LAST_INSERT_ID()
WHERE id = vSelf;
END IF;
END IF;
COMMIT;
DROP TEMPORARY TABLE tTicket;
END$$
DELIMITER ;

View File

@ -7,6 +7,8 @@ BEGIN
UPDATE expedition
SET hasNewRoute = TRUE
WHERE ticketFk = NEW.id;
CALL ticket_doCmr(NEW.id);
END IF;
END$$
DELIMITER ;

View File

@ -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';

View File

@ -0,0 +1,5 @@
-- Place your SQL code here
ALTER TABLE vn.packaging
MODIFY COLUMN height decimal(10,2) DEFAULT NULL NULL,
MODIFY COLUMN `depth` decimal(10,2) DEFAULT NULL NULL,
MODIFY COLUMN width decimal(10,2) DEFAULT NULL NULL;

View File

@ -0,0 +1 @@
REVOKE UPDATE (`size`, longName, name) ON vn.item FROM buyer;

View File

@ -226,4 +226,4 @@
"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",
"InvoiceIn is already booked": "InvoiceIn is already booked"
}
}

View File

@ -10,6 +10,9 @@
"id": {
"type": "number",
"id": true
},
"workcenterFk" : {
"type": "number"
}
},
"relations": {
@ -24,4 +27,4 @@
"foreignKey": "departmentFk"
}
}
}
}

View File

@ -98,6 +98,22 @@ module.exports = Self => {
if (isHalfHoliday && hasHalfHoliday)
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({
businessFk: labour.businessFk,
dayOffTypeFk: args.absenceTypeId,

View File

@ -104,6 +104,35 @@ describe('Worker createAbsence()', () => {
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() => {
const ctx = {
req: {accessToken: {userId: 19}},

View File

@ -22,7 +22,10 @@
},
"holidayEntitlementRate": {
"type": "number"
}
},
"isFestiveEligible": {
"type": "boolean"
}
},
"acls": [
{
@ -32,4 +35,4 @@
"permission": "ALLOW"
}
]
}
}

View File

@ -59,6 +59,9 @@
},
"sex": {
"type" : "string"
},
"isFreelance": {
"type" : "boolean"
}
},
"relations": {