Merge pull request '#7488: Deleted nif validation' (!3402) from 7488-DeleteNifValidation into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #3402 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
ef8e206520
|
@ -1,5 +1,4 @@
|
|||
module.exports = Self => {
|
||||
const validateTin = require('vn-loopback/util/validateTin');
|
||||
require('../methods/worker/filter')(Self);
|
||||
require('../methods/worker/mySubordinates')(Self);
|
||||
require('../methods/worker/isSubordinate')(Self);
|
||||
|
@ -23,26 +22,10 @@ module.exports = Self => {
|
|||
require('../methods/worker/getAvailablePda')(Self);
|
||||
require('../methods/worker/myTeam')(Self);
|
||||
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
||||
Self.canModifyAbsenceInPast = async(ctx, time) => {
|
||||
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
return hasPrivs || today.getTime() < time;
|
||||
};
|
||||
|
||||
async function tinIsValid(err, done) {
|
||||
const country = await Self.app.models.Country.findOne({
|
||||
fields: ['code'],
|
||||
where: {id: this.originCountryFk}
|
||||
});
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (!this.fi || !validateTin(this.fi, code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue