Merge branch 'dev' into 7161-deleteItemTrash
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
0d42b32611
|
@ -5,97 +5,90 @@ BEGIN
|
||||||
DECLARE vFromDated DATE;
|
DECLARE vFromDated DATE;
|
||||||
DECLARE vForDeleteDated DATE;
|
DECLARE vForDeleteDated DATE;
|
||||||
DECLARE vManaId INT;
|
DECLARE vManaId INT;
|
||||||
DECLARE vManaAutoId INT;
|
DECLARE vManaAutoId INT;
|
||||||
DECLARE vClaimManaId INT;
|
DECLARE vClaimManaId INT;
|
||||||
DECLARE vManaBankId INT;
|
DECLARE vManaBankId INT;
|
||||||
DECLARE vManaGreugeTypeId INT;
|
DECLARE vManaGreugeTypeId INT;
|
||||||
DECLARE vManaFromDays INT;
|
DECLARE vManaFromDays INT;
|
||||||
DECLARE vManaToDays INT;
|
DECLARE vManaToDays INT;
|
||||||
|
|
||||||
SELECT id INTO vManaId
|
SELECT id INTO vManaId
|
||||||
FROM vn.component WHERE code = 'mana';
|
FROM vn.component WHERE code = 'mana';
|
||||||
|
|
||||||
SELECT id INTO vManaAutoId
|
SELECT id INTO vManaAutoId
|
||||||
FROM vn.component WHERE code = 'autoMana';
|
FROM vn.component WHERE code = 'autoMana';
|
||||||
|
|
||||||
SELECT id INTO vClaimManaId
|
SELECT id INTO vClaimManaId
|
||||||
FROM vn.component WHERE code = 'manaClaim';
|
FROM vn.component WHERE code = 'manaClaim';
|
||||||
|
|
||||||
SELECT id INTO vManaBankId
|
SELECT id INTO vManaBankId
|
||||||
FROM vn.accounting WHERE code = 'mana';
|
FROM vn.accounting WHERE code = 'mana';
|
||||||
|
|
||||||
SELECT id INTO vManaGreugeTypeId
|
SELECT id INTO vManaGreugeTypeId
|
||||||
FROM vn.greugeType WHERE code = 'mana';
|
FROM vn.greugeType WHERE code = 'mana';
|
||||||
|
|
||||||
SELECT manaFromDays, manaToDays
|
SELECT manaFromDays, manaToDays
|
||||||
INTO vManaFromDays, vManaToDays
|
INTO vManaFromDays, vManaToDays
|
||||||
FROM vn.salespersonConfig;
|
FROM vn.salespersonConfig;
|
||||||
|
|
||||||
SELECT MAX(dated)
|
SELECT MAX(dated) INTO vFromDated
|
||||||
INTO vFromDated
|
FROM vn.clientManaCache;
|
||||||
FROM vn.clientManaCache;
|
|
||||||
|
|
||||||
DELETE
|
DELETE FROM vn.clientManaCache
|
||||||
FROM vn.clientManaCache
|
WHERE dated = vFromDated;
|
||||||
WHERE dated = vFromDated;
|
|
||||||
|
SELECT MAX(dated) INTO vFromDated
|
||||||
SELECT MAX(dated)
|
FROM vn.clientManaCache;
|
||||||
INTO vFromDated
|
|
||||||
FROM vn.clientManaCache;
|
IF vFromDated IS NULL THEN
|
||||||
|
SELECT manaDateFrom
|
||||||
IF ISNULL(vFromDated) THEN
|
INTO vFromDated
|
||||||
SELECT manaDateFrom
|
FROM vn.salespersonConfig;
|
||||||
INTO vFromDated
|
END IF;
|
||||||
FROM vn.salespersonConfig;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||||
SELECT
|
SELECT vFromDated + INTERVAL vManaToDays DAY,
|
||||||
vFromDated + INTERVAL vManaToDays DAY,
|
vFromDated - INTERVAL vManaFromDays DAY
|
||||||
vFromDated - INTERVAL vManaFromDays DAY
|
INTO vToDated,
|
||||||
INTO
|
vForDeleteDated;
|
||||||
vToDated,
|
|
||||||
vForDeleteDated;
|
DELETE FROM vn.clientManaCache
|
||||||
|
WHERE dated <= vForDeleteDated;
|
||||||
DELETE FROM vn.clientManaCache
|
|
||||||
WHERE dated <= vForDeleteDated;
|
|
||||||
|
|
||||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||||
SELECT
|
SELECT Id_Cliente,
|
||||||
Id_Cliente,
|
SUM(mana),
|
||||||
SUM(mana),
|
vToDated
|
||||||
vToDated
|
FROM (
|
||||||
FROM
|
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
|
||||||
(
|
FROM vn.ticket t
|
||||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
FROM vn.ticket t
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.address a ON a.id = t.addressFk
|
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
JOIN vn.sale s on s.ticketFk = t.id
|
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||||
JOIN vn.saleComponent sc on sc.saleFk = s.id
|
AND t.shipped > vFromDated
|
||||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
AND DATE(t.shipped) <= vToDated
|
||||||
AND t.shipped > vFromDated
|
UNION ALL
|
||||||
AND date(t.shipped) <= vToDated
|
SELECT clientFk, - amountPaid
|
||||||
UNION ALL
|
FROM vn.receipt
|
||||||
SELECT clientFk, - amountPaid
|
WHERE bankFk = vManaBankId
|
||||||
FROM vn.receipt
|
AND payed > vFromDated
|
||||||
WHERE bankFk = vManaBankId
|
AND payed <= vToDated
|
||||||
AND payed > vFromDated
|
UNION ALL
|
||||||
AND payed <= vToDated
|
SELECT clientFk, amount
|
||||||
UNION ALL
|
FROM vn.greuge
|
||||||
SELECT clientFk, amount
|
WHERE greugeTypeFk = vManaGreugeTypeId
|
||||||
FROM vn.greuge
|
AND shipped > vFromDated
|
||||||
WHERE greugeTypeFk = vManaGreugeTypeId
|
AND shipped <= vToDated
|
||||||
AND shipped > vFromDated
|
UNION ALL
|
||||||
AND shipped <= vToDated
|
SELECT clientFk, mana
|
||||||
UNION ALL
|
FROM vn.clientManaCache
|
||||||
SELECT clientFk, mana
|
WHERE dated = vFromDated
|
||||||
FROM vn.clientManaCache
|
) sub
|
||||||
WHERE dated = vFromDated
|
GROUP BY Id_Cliente
|
||||||
) sub
|
HAVING Id_Cliente;
|
||||||
GROUP BY Id_Cliente
|
|
||||||
HAVING Id_Cliente;
|
|
||||||
|
|
||||||
SET vFromDated = vToDated;
|
SET vFromDated = vToDated;
|
||||||
END WHILE;
|
END WHILE;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -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