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
|
@ -31,50 +31,43 @@ BEGIN
|
|||
INTO vManaFromDays, vManaToDays
|
||||
FROM vn.salespersonConfig;
|
||||
|
||||
SELECT MAX(dated)
|
||||
INTO vFromDated
|
||||
SELECT MAX(dated) INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
|
||||
DELETE
|
||||
FROM vn.clientManaCache
|
||||
DELETE FROM vn.clientManaCache
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT MAX(dated)
|
||||
INTO vFromDated
|
||||
SELECT MAX(dated) INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
|
||||
IF ISNULL(vFromDated) THEN
|
||||
IF vFromDated IS NULL THEN
|
||||
SELECT manaDateFrom
|
||||
INTO vFromDated
|
||||
FROM vn.salespersonConfig;
|
||||
END IF;
|
||||
|
||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||
SELECT
|
||||
vFromDated + INTERVAL vManaToDays DAY,
|
||||
SELECT vFromDated + INTERVAL vManaToDays DAY,
|
||||
vFromDated - INTERVAL vManaFromDays DAY
|
||||
INTO
|
||||
vToDated,
|
||||
INTO vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM vn.clientManaCache
|
||||
WHERE dated <= vForDeleteDated;
|
||||
|
||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||
SELECT
|
||||
Id_Cliente,
|
||||
SELECT Id_Cliente,
|
||||
SUM(mana),
|
||||
vToDated
|
||||
FROM
|
||||
(
|
||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
|
||||
FROM (
|
||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.sale s on s.ticketFk = t.id
|
||||
JOIN vn.saleComponent sc on sc.saleFk = s.id
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||
AND t.shipped > vFromDated
|
||||
AND date(t.shipped) <= vToDated
|
||||
AND DATE(t.shipped) <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, - amountPaid
|
||||
FROM vn.receipt
|
||||
|
|
|
@ -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';
|
|
@ -10,6 +10,9 @@
|
|||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"workcenterFk" : {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}},
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
},
|
||||
"holidayEntitlementRate": {
|
||||
"type": "number"
|
||||
},
|
||||
"isFestiveEligible": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
},
|
||||
"isF11Allowed": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"isFreelance": {
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
Loading…
Reference in New Issue