refs #7292 hook ueemember

This commit is contained in:
Carlos Satorres 2024-05-21 10:19:21 +02:00
parent cbbd488674
commit 9bd5244f64
4 changed files with 10 additions and 8 deletions

View File

@ -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() => {

View File

@ -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"
}

View File

@ -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);

View File

@ -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() => {