fix: worker new if not has provinceFk #2741

Merged
alexm merged 2 commits from warmFix_worker_new into test 2024-07-16 08:54:52 +00:00
1 changed files with 7 additions and 4 deletions

View File

@ -193,9 +193,13 @@ module.exports = Self => {
} }
await user.updateAttribute('email', email, myOptions); await user.updateAttribute('email', email, myOptions);
const {countryFk} = await Self.app.models.Province.findById(provinceFk, { let countryFk;
if (provinceFk) {
const province = await Self.app.models.Province.findById(provinceFk, {
fields: ['countryFk'] fields: ['countryFk']
}); });
countryFk = province.countryFk;
}
await models.Worker.create({ await models.Worker.create({
id: user.id, id: user.id,
firstName, firstName,
@ -205,7 +209,6 @@ module.exports = Self => {
fi, fi,
birth, birth,
originCountryFk: countryFk originCountryFk: countryFk
}, myOptions); }, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();