fix(worker_new): fix countryFk
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
323d26f226
commit
896d273da8
|
@ -53,7 +53,7 @@
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
ng-model="$ctrl.location.countryFk"
|
ng-model="$ctrl.location.countryFk"
|
||||||
url="Countries"
|
url="Countries"
|
||||||
show-field="country"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
label="Country">
|
label="Country">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -171,8 +171,8 @@ module.exports = Self => {
|
||||||
const address = await models.Address.create({
|
const address = await models.Address.create({
|
||||||
clientFk: user.id,
|
clientFk: user.id,
|
||||||
street: street,
|
street: street,
|
||||||
city: city,
|
city,
|
||||||
provinceFk: provinceFk,
|
provinceFk,
|
||||||
postalCode: postcode,
|
postalCode: postcode,
|
||||||
mobile: phone,
|
mobile: phone,
|
||||||
nickname: nickname,
|
nickname: nickname,
|
||||||
|
@ -193,7 +193,9 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await user.updateAttribute('email', email, myOptions);
|
await user.updateAttribute('email', email, myOptions);
|
||||||
|
const {countryFk} = await Self.app.models.Province.findById(provinceFk, {
|
||||||
|
fields: ['countryFk']
|
||||||
|
});
|
||||||
await models.Worker.create({
|
await models.Worker.create({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
firstName,
|
firstName,
|
||||||
|
@ -202,6 +204,7 @@ module.exports = Self => {
|
||||||
bossFk,
|
bossFk,
|
||||||
fi,
|
fi,
|
||||||
birth,
|
birth,
|
||||||
|
originCountryFk: countryFk
|
||||||
|
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
@ -212,11 +215,8 @@ module.exports = Self => {
|
||||||
const message = e.sqlMessage;
|
const message = e.sqlMessage;
|
||||||
|
|
||||||
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`);
|
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(`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`);
|
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`);
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,10 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function tinIsValid(err, done) {
|
async function tinIsValid(err, done) {
|
||||||
const filter = {
|
const country = await Self.app.models.Country.findOne({
|
||||||
fields: ['code'],
|
fields: ['code'],
|
||||||
where: {id: this.countryFk}
|
where: {id: this.originCountryFk}
|
||||||
};
|
});
|
||||||
const country = await Self.app.models.Country.findOne(filter);
|
|
||||||
const code = country ? country.code.toLowerCase() : null;
|
const code = country ? country.code.toLowerCase() : null;
|
||||||
|
|
||||||
if (!this.fi || !validateTin(this.fi, code))
|
if (!this.fi || !validateTin(this.fi, code))
|
||||||
|
|
Loading…
Reference in New Issue