refactor(worker): absences return one or all abscences
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
17b178b6bf
commit
c33b8fbb83
|
@ -12,6 +12,11 @@ module.exports = Self => {
|
|||
arg: 'year',
|
||||
type: 'date',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'all',
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
}],
|
||||
returns: [{
|
||||
arg: 'absences',
|
||||
|
@ -27,7 +32,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.absences = async(ctx, businessFk, year, options) => {
|
||||
Self.absences = async(ctx, businessFk, year, all, options) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const started = new Date();
|
||||
|
@ -45,6 +50,12 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
let where = {businessFk};
|
||||
if (all) {
|
||||
let worker = await models.WorkerLabour.findOne({where: where});
|
||||
where = {workerFk: worker.workerFk};
|
||||
}
|
||||
|
||||
const contract = await models.WorkerLabour.findOne({
|
||||
include: [{
|
||||
relation: 'holidays',
|
||||
|
@ -82,7 +93,7 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}],
|
||||
where: {businessFk}
|
||||
where: where
|
||||
}, myOptions);
|
||||
|
||||
if (!contract) return;
|
||||
|
|
|
@ -128,7 +128,8 @@ class Controller extends Section {
|
|||
const fullYear = this.started.getFullYear();
|
||||
let params = {
|
||||
businessFk: this.businessId,
|
||||
year: fullYear
|
||||
year: fullYear,
|
||||
all: true
|
||||
};
|
||||
|
||||
return this.$http.get(`Calendars/absences`, {params})
|
||||
|
|
Loading…
Reference in New Issue