Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7019_fix_createManualInvoice
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-04-25 17:18:37 +02:00
commit b9de2b3ce6
7 changed files with 46 additions and 10 deletions

View File

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [24.20.01] - 2024-05-14
### Fixed
- (Worker -> time-control) Corrección de errores
## [24.18.01] - 2024-05-07
## [24.16.01] - 2024-04-18

View File

@ -121,15 +121,17 @@ BEGIN
CALL util.throw(vErrorCode);
END IF;
-- DIRECCION CORRECTA
CALL workerTimeControl_direction(vWorkerFk, vTimed);
IF (SELECT
IF(IF(option1 IN ('inMiddle', 'outMiddle'),
IF((IF(option1 IN ('inMiddle', 'outMiddle'),
'middle',
option1) <> vDirection
AND IF(option2 IN ('inMiddle', 'outMiddle'),
'middle',
IFNULL(option2, '')) <> vDirection,
IFNULL(option2, '')) <> vDirection)
OR (option1 IS NULL AND option2 IS NULL),
TRUE ,
FALSE)
FROM tmp.workerTimeControlDirection
@ -137,12 +139,17 @@ BEGIN
SET vIsError = TRUE;
END IF;
DROP TEMPORARY TABLE tmp.workerTimeControlDirection;
IF vIsError THEN
SET vErrorCode = 'WRONG_DIRECTION';
IF(SELECT option1 IS NULL AND option2 IS NULL
FROM tmp.workerTimeControlDirection) THEN
SET vErrorCode = 'DAY_MAX_TIME';
END IF;
CALL util.throw(vErrorCode);
END IF;
DROP TEMPORARY TABLE tmp.workerTimeControlDirection;
-- FICHADAS IMPARES
SELECT timed INTO vLastIn
FROM workerTimeControl

View File

@ -0,0 +1,2 @@
-- Place your SQL code here
ALTER TABLE vn.claimBeginning MODIFY COLUMN quantity double DEFAULT 0 NULL;

View File

@ -83,7 +83,6 @@ module.exports = Self => {
const newClaimBeginning = models.ClaimBeginning.create({
saleFk: sale.id,
claimFk: newClaim.id,
quantity: sale.quantity
}, myOptions);
promises.push(newClaimBeginning);

View File

@ -37,7 +37,7 @@ describe('Claim createFromSales()', () => {
let claimBeginning = await models.ClaimBeginning.findOne({where: {claimFk: claim.id}}, options);
expect(claimBeginning.saleFk).toEqual(newSale[0].id);
expect(claimBeginning.quantity).toEqual(newSale[0].quantity);
expect(claimBeginning.quantity).toEqual(0);
await tx.rollback();
} catch (e) {
@ -67,7 +67,7 @@ describe('Claim createFromSales()', () => {
const claimBeginning = await models.ClaimBeginning.findOne({where: {claimFk: claim.id}}, options);
expect(claimBeginning.saleFk).toEqual(newSale[0].id);
expect(claimBeginning.quantity).toEqual(newSale[0].quantity);
expect(claimBeginning.quantity).toEqual(0);
await tx.rollback();
} catch (e) {

View File

@ -16,8 +16,7 @@
"description": "Identifier"
},
"quantity": {
"type": "number",
"required": true
"type": "number"
}
},
"relations": {

View File

@ -99,6 +99,32 @@ describe('workerTimeControl clockIn()', () => {
}
});
it('should throw an error trying to add an "in" entry if the last clockIn is not out', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
ctx.args = {timed: "2000-12-25T21:00:00.000Z", direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-25T22:00:00.000Z", direction: 'middle'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-25T22:30:00.000Z", direction: 'middle'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-26T01:00:00.000Z", direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
await tx.rollback();
} catch (e) {
expect(e.message).toBe('Dirección incorrecta');
await tx.rollback();
}
});
describe('as Role errors', () => {
it('should add if the current user is team boss and the target user is himself', async() => {
activeCtx.accessToken.userId = teamBossId;