From 878e989c027a9ea5f35c8dbcf1a3299acfa715df Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 12 Jul 2021 08:29:21 +0200 Subject: [PATCH] HOTFIX: Disable address without a province --- .../back/methods/client/updateAddress.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index 27f9faf1c..1ee6e5db8 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -91,20 +91,22 @@ module.exports = function(Self) { } }); const provinceId = args.provinceFk || address.provinceFk; - const province = await models.Province.findById(provinceId, { - include: { - relation: 'country' - } - }, options); + if (provinceId) { + const province = await models.Province.findById(provinceId, { + include: { + relation: 'country' + } + }, options); - const isUeeMember = province.country().isUeeMember; - const incotermsId = args.incotermsFk || address.incotermsFk; - if (!isUeeMember && !incotermsId) - throw new UserError(`Incoterms is required for a non UEE member`); + const isUeeMember = province.country().isUeeMember; + const incotermsId = args.incotermsFk || address.incotermsFk; + 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 const updatedAddress = await address.updateAttributes(ctx.args, options);