fix(worker_new): fix countryFk
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-12 12:06:37 +02:00
parent 323d26f226
commit 896d273da8
3 changed files with 10 additions and 11 deletions

View File

@ -53,7 +53,7 @@
<vn-autocomplete vn-one
ng-model="$ctrl.location.countryFk"
url="Countries"
show-field="country"
show-field="name"
value-field="id"
label="Country">
</vn-autocomplete>

View File

@ -171,8 +171,8 @@ module.exports = Self => {
const address = await models.Address.create({
clientFk: user.id,
street: street,
city: city,
provinceFk: provinceFk,
city,
provinceFk,
postalCode: postcode,
mobile: phone,
nickname: nickname,
@ -193,7 +193,9 @@ module.exports = Self => {
}
await user.updateAttribute('email', email, myOptions);
const {countryFk} = await Self.app.models.Province.findById(provinceFk, {
fields: ['countryFk']
});
await models.Worker.create({
id: user.id,
firstName,
@ -202,6 +204,7 @@ module.exports = Self => {
bossFk,
fi,
birth,
originCountryFk: countryFk
}, myOptions);
@ -212,11 +215,8 @@ module.exports = Self => {
const message = e.sqlMessage;
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`);
throw e;
}

View File

@ -27,11 +27,10 @@ module.exports = Self => {
});
async function tinIsValid(err, done) {
const filter = {
const country = await Self.app.models.Country.findOne({
fields: ['code'],
where: {id: this.countryFk}
};
const country = await Self.app.models.Country.findOne(filter);
where: {id: this.originCountryFk}
});
const code = country ? country.code.toLowerCase() : null;
if (!this.fi || !validateTin(this.fi, code))