Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3002-more_module_transactions
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-07-12 13:56:58 +02:00
commit 1835171fe8
1 changed files with 14 additions and 12 deletions

View File

@ -103,21 +103,23 @@ module.exports = function(Self) {
}, myOptions);
const provinceId = args.provinceFk || address.provinceFk;
const province = await models.Province.findById(provinceId, {
include: {
relation: 'country'
}
}, myOptions);
if (provinceId) {
const province = await models.Province.findById(provinceId, {
include: {
relation: 'country'
}
}, myOptions);
const isUeeMember = province.country().isUeeMember;
const isUeeMember = province.country().isUeeMember;
const incotermsId = args.incotermsFk || address.incotermsFk;
const incotermsId = args.incotermsFk || address.incotermsFk;
if (!isUeeMember && !incotermsId)
throw new UserError(`Incoterms is required for a non UEE member`);
if (!isUeeMember && !incotermsId)
throw new UserError(`Incoterms is required for a non UEE member`);
const customsAgentId = args.customsAgentFk || address.customsAgentFk;
if (!isUeeMember && !customsAgentId)
throw new UserError(`Customs agent is required for a non UEE member`);
const customsAgentId = args.customsAgentFk || address.customsAgentFk;
if (!isUeeMember && !customsAgentId)
throw new UserError(`Customs agent is required for a non UEE member`);
}
delete args.ctx; // Remove unwanted properties