diff --git a/db/changes/10240-allSaints/00-ACL.sql b/db/changes/10240-allSaints/00-ACL.sql index 60882e308..332c7677e 100644 --- a/db/changes/10240-allSaints/00-ACL.sql +++ b/db/changes/10240-allSaints/00-ACL.sql @@ -1,3 +1,8 @@ UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '97'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '100'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '103'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '202'); + INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); diff --git a/db/changes/10240-allSaints/00-claimState.sql b/db/changes/10240-allSaints/00-claimState.sql new file mode 100644 index 000000000..64ec0f30d --- /dev/null +++ b/db/changes/10240-allSaints/00-claimState.sql @@ -0,0 +1,3 @@ +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '3'); +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '4'); +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '5'); \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index ffbece93b..70e5d9b83 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -61,7 +61,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claim','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-13 10:01:32'); +INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-13 10:01:32'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index c36e8d8cf..cc3f2f689 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1534,9 +1534,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`) VALUES ( 1, 'pending', 'Pendiente', 1, 1), ( 2, 'managed', 'Gestionado', 1, 5), - ( 3, 'resolved', 'Resuelto', 21, 7), - ( 4, 'canceled', 'Anulado', 1, 6), - ( 5, 'disputed', 'Cuestionado', 21, 3), + ( 3, 'resolved', 'Resuelto', 72, 7), + ( 4, 'canceled', 'Anulado', 72, 6), + ( 5, 'disputed', 'Cuestionado', 72, 3), ( 6, 'mana', 'Mana', 1, 4), ( 7, 'inProgress', 'En Curso', 1, 2); diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js index dd55d0053..4b60b2689 100644 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ b/e2e/paths/06-claim/01_basic_data.spec.js @@ -14,8 +14,8 @@ describe('Claim edit basic data path', () => { await browser.close(); }); - it(`should log in as salesAssistant then reach basic data of the target claim`, async() => { - await page.loginAndModule('salesAssistant', 'claim'); + it(`should log in as claimManager then reach basic data of the target claim`, async() => { + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.basicData'); }); @@ -30,7 +30,7 @@ describe('Claim edit basic data path', () => { expect(message.type).toBe('success'); }); - it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => { + it(`should have been redirected to the next section of claims as the role is claimManager`, async() => { await page.waitForState('claim.card.detail'); }); diff --git a/e2e/paths/06-claim/02_development.spec.js b/e2e/paths/06-claim/02_development.spec.js index 8efae48d4..545ec340b 100644 --- a/e2e/paths/06-claim/02_development.spec.js +++ b/e2e/paths/06-claim/02_development.spec.js @@ -8,7 +8,7 @@ describe('Claim development', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('salesAssistant', 'claim'); + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.development'); }); @@ -31,7 +31,7 @@ describe('Claim development', () => { expect(message.type).toBe('success'); }); - it(`should redirect to the next section of claims as the role is salesAssistant`, async() => { + it(`should redirect to the next section of claims as the role is claimManager`, async() => { await page.waitForState('claim.card.action'); }); diff --git a/e2e/paths/06-claim/04_claim_action.spec.js b/e2e/paths/06-claim/04_claim_action.spec.js index e7ab8638c..710dc1809 100644 --- a/e2e/paths/06-claim/04_claim_action.spec.js +++ b/e2e/paths/06-claim/04_claim_action.spec.js @@ -8,7 +8,7 @@ describe('Claim action path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('administrative', 'claim'); + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('2'); await page.accessToSection('claim.card.action'); }); diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js index 43d046d62..63db37731 100644 --- a/e2e/paths/06-claim/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -26,8 +26,8 @@ describe('claim Descriptor path', () => { await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); }); - it(`should log in as salesAssistant and navigate to the target claim`, async() => { - await page.loginAndModule('salesAssistant', 'claim'); + it(`should log in as claimManager and navigate to the target claim`, async() => { + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult(claimId); await page.waitForState('claim.card.summary'); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 498635832..3dfb73833 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -73,6 +73,7 @@ "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "The grade must be similar to the last one": "The grade must be similar to the last one", "agencyModeFk": "Agency", "clientFk": "Client", "zoneFk": "Zone", diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index 226a07917..8c013c172 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -2,13 +2,13 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); describe('claimBeginning', () => { - const salesAssistantId = 21; + const claimManagerId = 72; let ticket; let refundTicketSales; let salesInsertedInClaimEnd; const activeCtx = { - accessToken: {userId: salesAssistantId}, + accessToken: {userId: claimManagerId}, }; const ctx = {req: activeCtx}; diff --git a/modules/claim/back/methods/claim/isEditable.js b/modules/claim/back/methods/claim/isEditable.js index 2e9991584..ce68153b5 100644 --- a/modules/claim/back/methods/claim/isEditable.js +++ b/modules/claim/back/methods/claim/isEditable.js @@ -21,10 +21,8 @@ module.exports = Self => { Self.isEditable = async(ctx, id) => { const userId = ctx.req.accessToken.userId; - - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - - let claim = await Self.app.models.Claim.findById(id, { + const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); + const claim = await Self.app.models.Claim.findById(id, { fields: ['claimStateFk'], include: [{ relation: 'claimState' @@ -33,7 +31,7 @@ module.exports = Self => { const isClaimResolved = claim && claim.claimState().code == 'resolved'; - if (!claim || (isClaimResolved && !isSalesAssistant)) + if (!claim || (isClaimResolved && !isClaimManager)) return false; return true; diff --git a/modules/claim/back/methods/claim/specs/isEditable.spec.js b/modules/claim/back/methods/claim/specs/isEditable.spec.js index ca419de4c..19436e16f 100644 --- a/modules/claim/back/methods/claim/specs/isEditable.spec.js +++ b/modules/claim/back/methods/claim/specs/isEditable.spec.js @@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server'); describe('claim isEditable()', () => { const salesPerdonId = 18; - const salesAssistantId = 21; + const claimManagerId = 72; it('should return false if the given claim does not exist', async() => { - let ctx = {req: {accessToken: {userId: salesAssistantId}}}; + let ctx = {req: {accessToken: {userId: claimManagerId}}}; let result = await app.models.Claim.isEditable(ctx, 99999); expect(result).toEqual(false); @@ -17,14 +17,14 @@ describe('claim isEditable()', () => { expect(result).toEqual(false); }); - it('should be able to edit a resolved claim for a salesAssistant', async() => { - let ctx = {req: {accessToken: {userId: salesAssistantId}}}; + it('should be able to edit a resolved claim for a claimManager', async() => { + let ctx = {req: {accessToken: {userId: claimManagerId}}}; let result = await app.models.Claim.isEditable(ctx, 4); expect(result).toEqual(true); }); - it('should be able to edit a claim for a salesAssistant', async() => { + it('should be able to edit a claim for a claimManager', async() => { let ctx = {req: {accessToken: {userId: salesPerdonId}}}; let result = await app.models.Claim.isEditable(ctx, 1); diff --git a/modules/claim/back/methods/claim/specs/updateClaim.spec.js b/modules/claim/back/methods/claim/specs/updateClaim.spec.js index 2a36bab9b..7ce6a4d3c 100644 --- a/modules/claim/back/methods/claim/specs/updateClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaim.spec.js @@ -42,17 +42,17 @@ describe('Update Claim', () => { it(`should success to update the claim within privileges `, async() => { let newClaim = await app.models.Claim.create(originalData); - const correctState = 4; - const salesPersonId = 18; + const canceledState = 4; + const claimManagerId = 72; const ctx = { req: { accessToken: { - userId: salesPersonId + userId: claimManagerId } }, args: { observation: 'valid observation', - claimStateFk: correctState, + claimStateFk: canceledState, hasToPickUp: false } }; @@ -66,15 +66,15 @@ describe('Update Claim', () => { await app.models.Claim.destroyById(newClaim.id); }); - it('should change some sensible fields as salesAssistant', async() => { + it('should change some sensible fields as claimManager', async() => { let newClaim = await app.models.Claim.create(originalData); const chatModel = app.models.Chat; spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); - const salesAssistantId = 21; + const claimManagerId = 72; const ctx = { req: { - accessToken: {userId: salesAssistantId}, + accessToken: {userId: claimManagerId}, headers: {origin: 'http://localhost'} }, args: { diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index c2c97d925..6c16b5737 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -60,9 +60,9 @@ module.exports = Self => { if (args.claimStateFk) { const canUpdate = await canChangeState(ctx, claim.claimStateFk); const hasRights = await canChangeState(ctx, args.claimStateFk); - const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant'); + const isClaimManager = await models.Account.hasRole(userId, 'claimManager'); - if (!canUpdate || !hasRights || changedHasToPickUp && !isSalesAssistant) + if (!canUpdate || !hasRights || changedHasToPickUp && !isClaimManager) throw new UserError(`You don't have enough privileges to change that field`); } delete args.ctx; diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 226794903..d2338bcc3 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -56,7 +56,8 @@ class="vn-mr-md" label="Pick up" ng-model="$ctrl.claim.hasToPickUp" - vn-acl="salesAssistant"> + vn-acl="claimManager" + info="When checked will notify to the salesPerson"> diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js index 9fa3bdf4d..818012bb9 100644 --- a/modules/claim/front/basic-data/index.js +++ b/modules/claim/front/basic-data/index.js @@ -5,7 +5,7 @@ import './style.scss'; class Controller extends Section { onSubmit() { this.$.watcher.submit().then(() => { - if (this.aclService.hasAny(['salesAssistant'])) + if (this.aclService.hasAny(['claimManager'])) this.$state.go('claim.card.detail'); }); } diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml index d6bae25f6..174eb4b62 100644 --- a/modules/claim/front/basic-data/locale/es.yml +++ b/modules/claim/front/basic-data/locale/es.yml @@ -4,4 +4,5 @@ Is paid with mana: Cargado al maná Responsability: Responsabilidad Company: Empresa Sales/Client: Comercial/Cliente -Pick up: Recoger \ No newline at end of file +Pick up: Recoger +When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial \ No newline at end of file diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index d6fb75ac5..1337c6242 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -13,7 +13,7 @@ Send Pickup order + vn-acl="claimManager"> diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index cae95c1dd..61cde8b22 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -7,7 +7,7 @@ export default class Client extends ModuleMain { case 'search': return /^\d+$/.test(value) ? {id: value} - : {name: {like: `%${value}%`}}; + : {or: [{name: {like: `%${value}%`}}, {socialName: {like: `%${value}%`}}]}; case 'phone': return { or: [ diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 080cc0f36..b8572dcff 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -55,8 +55,8 @@ - {{::sale.origin | dashIfEmpty}} @@ -94,3 +94,7 @@ + + + diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 953d203e8..bf04fabe9 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -58,10 +58,12 @@ class Controller extends Section { this.$anchorScroll(); } - showTicketDescriptor(event, sale) { - if (!sale.isTicket) return; + showDescriptor(event, sale) { + let descriptor = 'entryDescriptor'; + if (sale.isTicket) + descriptor = 'ticketDescriptor'; - this.$.ticketDescriptor.show(event.target, sale.origin); + this.$[descriptor].show(event.target, sale.origin); } } diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index 52608cde3..988914978 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -60,6 +60,34 @@ describe('Item', () => { expect(controller.$anchorScroll).toHaveBeenCalledWith(); }); }); + + describe('showDescriptor ()', () => { + it('should call to the entryDescriptor show() method', () => { + controller.$.entryDescriptor = {}; + controller.$.entryDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1}; + controller.showDescriptor($event, data); + + expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + + it('should call to the ticketDescriptor show() method', () => { + controller.$.ticketDescriptor = {}; + controller.$.ticketDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1, isTicket: true}; + controller.showDescriptor($event, data); + + expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + }); }); }); diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 2aab4301e..d3bde0205 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "icon-item", "validations" : true, - "dependencies": ["worker", "client", "ticket"], + "dependencies": ["worker", "client", "ticket", "entry"], "menus": { "main": [ {"state": "item.index", "icon": "icon-item"}, diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 676a5b0b8..924ad6d6d 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -28,8 +28,12 @@ - + + + {{$ctrl.summary.zone.name}} + @@ -247,3 +251,6 @@ + + \ No newline at end of file diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index b802aaa4a..5fa43fd1d 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -3,7 +3,7 @@ "name": "Travels", "icon": "local_airport", "validations": true, - "dependencies": ["worker"], + "dependencies": ["worker", "entry"], "menus": { "main": [ {"state": "travel.index", "icon": "local_airport"} diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 12dbded4e..7e055a0f1 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -41,7 +41,7 @@ value="{{$ctrl.travelData.ref}}"> Package CC Pallet - m3 + @@ -75,7 +75,12 @@ disabled="true"> - {{entry.id}} + + + {{entry.id}} + + {{entry.supplierName}} {{entry.ref}} {{entry.hb}} @@ -141,4 +146,7 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml index c82508dfc..8d2e7e78c 100644 --- a/modules/travel/front/summary/locale/es.yml +++ b/modules/travel/front/summary/locale/es.yml @@ -9,7 +9,7 @@ Received: Recibida Agency: Agencia Entries: Entradas Confirmed: Confirmada -Entry Id: Entrada Id +Entry Id: Id entrada Supplier: Proveedor Pallet: Pallet Freight: Porte diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index eea24a132..d48b5f0d8 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -73,7 +73,7 @@ value="{{::row.bonus | currency:'EUR':2}}"> @@ -166,7 +166,7 @@