diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index bde4203b4..ff2aac6b9 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -29,11 +29,11 @@ describe('Client create path', () => { it('should receive an error when clicking the create button having name and Business name fields empty', async() => { + await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); + await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); await page.write(selectors.createClientView.taxNumber, '74451390E'); await page.write(selectors.createClientView.userName, 'CaptainMarvel'); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); - await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); - await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); await page.waitToClick(selectors.createClientView.createButton); const message = await page.waitForSnackbar(); @@ -83,7 +83,6 @@ describe('Client create path', () => { expect(message.text).toContain('Some fields are invalid'); }); - /* Tarea #3370 it(`should attempt to create a new user with all it's data but wrong business type`, async() => { await page.clearInput(selectors.createClientView.email); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); @@ -91,13 +90,10 @@ describe('Client create path', () => { await page.waitToClick(selectors.createClientView.createButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Some fields are invalid'); - });*/ + expect(message.text).toContain('The type of business must be filled in basic data'); + }); it(`should attempt to create a new user with all it's data but wrong postal code`, async() => { - await page.clearInput(selectors.createClientView.email); - await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); - await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); await page.clearInput(selectors.createClientView.postcode); await page.write(selectors.createClientView.postcode, '479999'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 271c3fd4f..15c65fd89 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -118,5 +118,6 @@ "reference duplicated": "reference duplicated", "The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", "This item is not available": "This item is not available", - "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}" + "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", + "The type of business must be filled in basic data": "The type of business must be filled in basic data" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index afa349684..4a5448d34 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -133,7 +133,7 @@ "reserved": "reservado", "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", - "Deny buy request":"Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", + "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", @@ -211,5 +211,6 @@ "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", "You can't change the credit set to zero from a manager": "No puedes cambiar el cŕedito establecido a cero por un gerente", - "The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'" + "The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", + "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos" } \ No newline at end of file diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 4cac16358..f3591750d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -55,6 +55,15 @@ module.exports = Self => { with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/ }); + Self.validate('businessTypeFk', hasBusinessType, { + message: `The type of business must be filled in basic data` + }); + + function hasBusinessType(err) { + if (!this.businessTypeFk) + err(); + } + Self.validatesLengthOf('postcode', { allowNull: true, allowBlank: true, diff --git a/modules/client/front/create/locale/es.yml b/modules/client/front/create/locale/es.yml index 6922ba917..31b7cd403 100644 --- a/modules/client/front/create/locale/es.yml +++ b/modules/client/front/create/locale/es.yml @@ -7,4 +7,5 @@ Create and edit: Crear y editar You can save multiple emails: >- Puede guardar varios correos electrónicos encadenándolos mediante comas sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer - correo electrónico el principal \ No newline at end of file + correo electrónico el principal +The type of business must be filled in basic data: El tipo de negocio debe estar rellenado en datos básicos