diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 0581635d0..2f5999359 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -51,7 +51,7 @@ describe('Client Add address path', () => { await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Incoterms is required for a non UEE member'); + expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member'); }); it(`should receive an error after clicking save button as customsAgent is empty`, async() => { diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 601a26f5b..1fffe7f35 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -226,5 +226,6 @@ "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked", - "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", + "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member" } \ No newline at end of file diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 8e6db2a22..cb55025ce 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -92,11 +92,12 @@ module.exports = function(Self) { }, myOptions); const isUeeMember = province.country().isUeeMember; - if (!isUeeMember && !args.incotermsFk) - throw new UserError(`Incoterms is required for a non UEE member`); - - if (!isUeeMember && !args.customsAgentFk) - throw new UserError(`Customs agent is required for a non UEE member`); + if (!isUeeMember && (!args.incotermsFk || !args.customsAgentFk)) { + if (!args.incotermsFk) + throw new UserError(`Incoterms and Customs agent are required for a non UEE member`); + else + throw new UserError(`Customs agent is required for a non UEE member`); + } delete args.ctx; // Remove unwanted properties const newAddress = await models.Address.create(args, myOptions); diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index 0841ad98c..bd41d9c50 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -50,7 +50,7 @@ describe('Address createAddress', () => { } expect(error).toBeDefined(); - expect(error.message).toEqual('Incoterms is required for a non UEE member'); + expect(error.message).toEqual('Incoterms and Customs agent are required for a non UEE member'); }); it('should throw a non uee member error if no customsAgent is defined', async() => {