Merge pull request 'fix: show correct payedHolidays' (#1007) from 4231-worker.calendar_payedHolidays into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
Reviewed-on: #1007 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
01ac06d845
|
@ -1892,6 +1892,10 @@ INSERT INTO `postgresql`.`business` (`client_id`, `provider_id`, `date_start`, `
|
|||
FROM `postgresql`.`profile` `p`
|
||||
WHERE `p`.`profile_id` = 1109;
|
||||
|
||||
UPDATE `postgresql`.`business`
|
||||
SET `payedHolidays`= 8
|
||||
WHERE `business_id`= 1106;
|
||||
|
||||
INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
|
||||
VALUES
|
||||
(1111, NULL, 23, 1, 0.0, 1, 1, 1, 1);
|
||||
|
|
|
@ -57,25 +57,9 @@ module.exports = Self => {
|
|||
ended.setDate(0);
|
||||
ended.setHours(23, 59, 59, 59);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
and: [
|
||||
{workerFk: id},
|
||||
{
|
||||
or: [
|
||||
{started: {between: [started, ended]}},
|
||||
{ended: {between: [started, ended]}},
|
||||
{and: [{started: {lt: started}}, {ended: {gt: ended}}]},
|
||||
{and: [{started: {lt: started}}, {ended: null}]}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
}
|
||||
};
|
||||
const contracts = await models.WorkerLabour.find(filter, myOptions);
|
||||
let [firstContract] = contracts;
|
||||
const payedHolidays = firstContract.payedHolidays;
|
||||
const filter = {where: {businessFk: args.businessFk}};
|
||||
const contract = await models.WorkerLabour.findOne(filter, myOptions);
|
||||
const payedHolidays = contract.payedHolidays;
|
||||
|
||||
let queryIndex;
|
||||
const year = started.getFullYear();
|
||||
|
|
|
@ -27,4 +27,15 @@ describe('Worker holidays()', () => {
|
|||
expect(result.totalHolidays).toEqual(27.5);
|
||||
expect(result.holidaysEnjoyed).toEqual(5);
|
||||
});
|
||||
|
||||
it('should now get the payed holidays calendar for a worker', async() => {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
|
||||
ctx.args = {businessFk: businessId, year: year};
|
||||
|
||||
const result = await app.models.Worker.holidays(ctx, workerId);
|
||||
|
||||
expect(result.payedHolidays).toEqual(8);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue