Merge pull request 'refs #6291 validateTin' (!1836) from 6291-comprobarDNI into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1836 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
6647649f5e
|
@ -3011,6 +3011,15 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
|
|||
(2, 'Error in sales details'),
|
||||
(3, 'Error in customer data');
|
||||
|
||||
UPDATE `vn`.`client`
|
||||
SET fi='65004204V'
|
||||
WHERE id=1;
|
||||
|
||||
UPDATE `vn`.`worker`
|
||||
SET fi='59328808D'
|
||||
WHERE id=1106;
|
||||
|
||||
|
||||
INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
|
||||
VALUES
|
||||
(1, 1),
|
||||
|
@ -3022,16 +3031,16 @@ INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
|
|||
('Tablet1','Jarvis tablet'),
|
||||
('Tablet2','Avengers tablet');
|
||||
|
||||
INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
|
||||
INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
|
||||
VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()),
|
||||
(2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()),
|
||||
(3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()),
|
||||
(4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
|
||||
INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
|
||||
VALUES(1, 1103, 1, NULL),
|
||||
(2, 1103, 2, NULL),
|
||||
(3, 1103, 3, 32),
|
||||
(4, 1103, 4, 32),
|
||||
(13, 1101, 1, NULL),
|
||||
(14, 1101, 4, 27);
|
||||
(14, 1101, 4, 27);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
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,4 +24,21 @@ module.exports = Self => {
|
|||
Self.validatesUniquenessOf('locker', {
|
||||
message: 'This locker has already been assigned'
|
||||
});
|
||||
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
||||
async function tinIsValid(err, done) {
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (!this.fi || !validateTin(this.fi, code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue