diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 67e0dbb87..fcb49f4b8 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -30,8 +30,13 @@ module.exports = Self => { const sender = await models.Account.findById(accessToken.userId); const recipient = to.replace('@', ''); - if (sender.name != recipient) - return sendMessage(sender, to, message); + if (sender.name != recipient) { + await sendMessage(sender, to, message); + + return true; + } + + return false; }; async function sendMessage(sender, channel, message) { diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 429ecdab0..5c27d72fd 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -5,7 +5,7 @@ module.exports = Self => { description: 'Sends a RocketChat message to a connected user or department channel', accessType: 'WRITE', accepts: [{ - arg: 'recipientId', + arg: 'workerId', type: 'number', required: true, description: 'The recipient user id' diff --git a/db/changes/10420-valentines/00-ImportTicketAcl.sql b/db/changes/10420-valentines/00-ImportTicketAcl.sql index 98192a39c..df61fd5b8 100644 --- a/db/changes/10420-valentines/00-ImportTicketAcl.sql +++ b/db/changes/10420-valentines/00-ImportTicketAcl.sql @@ -1,2 +1,2 @@ -DELETE FROM salix.ACL +DELETE FROM `salix`.`ACL` WHERE model = 'ClaimEnd' AND property = 'importTicketSales'; diff --git a/db/changes/10420-valentines/00-aclCollection.sql b/db/changes/10420-valentines/00-aclCollection.sql index 81e53049c..57774ba29 100644 --- a/db/changes/10420-valentines/00-aclCollection.sql +++ b/db/changes/10420-valentines/00-aclCollection.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES('Collection', 'setSaleQuantity', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-aclDocuware.sql b/db/changes/10420-valentines/00-aclDocuware.sql index 21ed66c4c..c2d47d4ea 100644 --- a/db/changes/10420-valentines/00-aclDocuware.sql +++ b/db/changes/10420-valentines/00-aclDocuware.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES('Docuware', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-defaultViewConfig.sql b/db/changes/10420-valentines/00-defaultViewConfig.sql index c65c1f403..e0d75e9d4 100644 --- a/db/changes/10420-valentines/00-defaultViewConfig.sql +++ b/db/changes/10420-valentines/00-defaultViewConfig.sql @@ -1,3 +1,3 @@ -UPDATE salix.defaultViewConfig +UPDATE `salix`.`defaultViewConfig` SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}' WHERE tableCode ='itemsIndex'; diff --git a/db/changes/10430-ash/00-aclAgencyTerm.sql b/db/changes/10430-ash/00-aclAgencyTerm.sql index d3e11e53e..c43965ed0 100644 --- a/db/changes/10430-ash/00-aclAgencyTerm.sql +++ b/db/changes/10430-ash/00-aclAgencyTerm.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) VALUES ('AgencyTerm','*','*','administrative'); diff --git a/db/changes/10430-ash/00-deliveryBoss.sql b/db/changes/10430-ash/00-deliveryBoss.sql index a4bcdcd0c..ac07bfa31 100644 --- a/db/changes/10430-ash/00-deliveryBoss.sql +++ b/db/changes/10430-ash/00-deliveryBoss.sql @@ -1,3 +1 @@ -UPDATE `account`.`user` -SET `role` = 57 -WHERE id IN (2294, 4365, 7294); \ No newline at end of file +UPDATE `account`.`user` SET `role` = 57 WHERE id IN (2294, 4365, 7294); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-aclIntrastat.sql b/db/changes/10440-fallas/00-aclIntrastat.sql new file mode 100644 index 000000000..16410814d --- /dev/null +++ b/db/changes/10440-fallas/00-aclIntrastat.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` +(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-component.sql b/db/changes/10440-fallas/00-component.sql new file mode 100644 index 000000000..8d2dd6517 --- /dev/null +++ b/db/changes/10440-fallas/00-component.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`) + VALUES ('maná reclamacion',7,4,0,'manaClaim',0); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-invoiceInIntrastat.sql b/db/changes/10440-fallas/00-invoiceInIntrastat.sql new file mode 100644 index 000000000..8f65fac29 --- /dev/null +++ b/db/changes/10440-fallas/00-invoiceInIntrastat.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-manaCustomerUpdate.sql b/db/changes/10440-fallas/00-manaCustomerUpdate.sql new file mode 100644 index 000000000..80838bca2 --- /dev/null +++ b/db/changes/10440-fallas/00-manaCustomerUpdate.sql @@ -0,0 +1,106 @@ +DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`() +BEGIN + DECLARE vToDated DATE; + DECLARE vFromDated DATE; + DECLARE vForDeleteDated DATE; + DECLARE vManaId INT; + DECLARE vManaAutoId INT; + DECLARE vClaimManaId INT; + DECLARE vManaBankId INT; + DECLARE vManaGreugeTypeId INT; + + SELECT id INTO vManaId + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vManaAutoId + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimManaId + FROM `component` WHERE code = 'manaClaim'; + + SELECT id INTO vManaBankId + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeTypeId + FROM `greugeType` WHERE code = 'mana'; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + DELETE + FROM bs.manaCustomer + WHERE dated = vFromDated; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO + + SELECT + timestampadd(DAY,30,vFromDated), + timestampadd(DAY,-90,vFromDated) + INTO + vToDated, + vForDeleteDated; + + DELETE FROM bs.manaCustomer + WHERE dated <= vForDeleteDated; + + + INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated) + + SELECT + Id_Cliente, + cast(sum(mana) as decimal(10,2)) as mana, + vToDated as dated + FROM + + ( + SELECT cs.Id_Cliente, Cantidad * Valor as mana + FROM vn2008.Tickets t + JOIN vn2008.Consignatarios cs using(Id_Consigna) + JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento + WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) + AND t.Fecha > vFromDated + AND date(t.Fecha) <= vToDated + + + UNION ALL + + SELECT r.Id_Cliente, - Entregado + FROM vn2008.Recibos r + WHERE Id_Banco = vManaBankId + AND Fechacobro > vFromDated + AND Fechacobro <= vToDated + + UNION ALL + + SELECT g.Id_Cliente, g.Importe + FROM vn2008.Greuges g + WHERE Greuges_type_id = vManaGreugeTypeId + AND Fecha > vFromDated + AND Fecha <= vToDated + + UNION ALL + + SELECT Id_Cliente, mana + FROM bs.manaCustomer + WHERE dated = vFromDated + ) sub + + GROUP BY Id_Cliente + HAVING Id_Cliente; + + SET vFromDated = vToDated; + + END WHILE; + +END$$ +DELIMITER ; diff --git a/db/changes/10440-fallas/00-manaSpellersRequery.sql b/db/changes/10440-fallas/00-manaSpellersRequery.sql new file mode 100644 index 000000000..9c1a10c6a --- /dev/null +++ b/db/changes/10440-fallas/00-manaSpellersRequery.sql @@ -0,0 +1,75 @@ +DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) +BEGIN +/** + * Recalcula el mana consumido por un trabajador + * + * @param vWorkerFk Id Trabajador + */ + DECLARE vWorkerIsExcluded BOOLEAN; + DECLARE vFromDated DATE; + DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); + DECLARE vMana INT; + DECLARE vAutoMana INT; + DECLARE vClaimMana INT; + DECLARE vManaBank INT; + DECLARE vManaGreugeType INT; + + SELECT COUNT(*) INTO vWorkerIsExcluded + FROM workerManaExcluded + WHERE workerFk = vWorkerFk; + + IF NOT vWorkerIsExcluded THEN + SELECT id INTO vMana + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vAutoMana + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimMana + FROM `component` WHERE code = 'manaClaim'; + + SELECT id INTO vManaBank + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeType + FROM `greugeType` WHERE code = 'mana'; + + SELECT max(dated) INTO vFromDated + FROM clientManaCache; + + REPLACE workerMana (workerFk, amount) + SELECT vWorkerFk, sum(mana) FROM + ( + SELECT s.quantity * sc.value as mana + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN client c ON c.id = a.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana) + AND t.shipped > vFromDated AND t.shipped < vToDated + UNION ALL + SELECT - r.amountPaid + FROM receipt r + JOIN client c ON c.id = r.clientFk + WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank + AND payed > vFromDated + UNION ALL + SELECT g.amount + FROM greuge g + JOIN client c ON c.id = g.clientFk + WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType + AND g.shipped > vFromDated and g.shipped < CURDATE() + UNION ALL + SELECT cc.mana + FROM clientManaCache cc + JOIN client c ON c.id = cc.clientFk + WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated + ) sub; + END IF; +END$$ +DELIMITER ; diff --git a/db/changes/10440-fallas/00-ticketRefund.sql b/db/changes/10440-fallas/00-ticketRefund.sql new file mode 100644 index 000000000..66de21e91 --- /dev/null +++ b/db/changes/10440-fallas/00-ticketRefund.sql @@ -0,0 +1,149 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT) +BEGIN + + DECLARE vDone BIT DEFAULT 0; + DECLARE vCustomer MEDIUMINT; + DECLARE vWarehouse TINYINT; + DECLARE vCompany MEDIUMINT; + DECLARE vAddress MEDIUMINT; + DECLARE vRefundAgencyMode INT; + DECLARE vItemFk INT; + DECLARE vQuantity DECIMAL (10,2); + DECLARE vConcept VARCHAR(50); + DECLARE vPrice DECIMAL (10,2); + DECLARE vDiscount TINYINT; + DECLARE vSaleNew INT; + DECLARE vSaleMain INT; + DECLARE vZoneFk INT; + + DECLARE vRsMainTicket CURSOR FOR + SELECT * + FROM tmp.sale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + SELECT id INTO vRefundAgencyMode + FROM agencyMode WHERE `name` = 'ABONO'; + + SELECT clientFk, warehouseFk, companyFk, addressFk + INTO vCustomer, vWarehouse, vCompany, vAddress + FROM ticket + WHERE id = vOriginTicket; + + SELECT id INTO vZoneFk + FROM zone WHERE agencyModeFk = vRefundAgencyMode + LIMIT 1; + + INSERT INTO vn.ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + companyFk, + landed, + zoneFk + ) + SELECT + vCustomer, + CURDATE(), + vAddress, + vRefundAgencyMode, + a.nickname, + vWarehouse, + vCompany, + CURDATE(), + vZoneFk + FROM address a + WHERE a.id = vAddress; + + SET vNewTicket = LAST_INSERT_ID(); + + SET vDone := 0; + OPEN vRsMainTicket ; + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + WHILE NOT vDone DO + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) + VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); + + SET vSaleNew = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent + WHERE saleFk = vSaleMain; + + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + END WHILE; + CLOSE vRsMainTicket; + + INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk) + VALUES(vNewTicket, vOriginTicket); + +END$$ +DELIMITER ; + +CREATE TABLE `vn`.`ticketRefund` ( + `id` INT auto_increment NULL, + `refundTicketFk` INT NOT NULL, + `originalTicketFk` INT NOT NULL, + CONSTRAINT `ticketRefund_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci; + +ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert` + BEFORE INSERT ON `ticketRefund` + FOR EACH ROW +BEGIN + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + + IF NEW.refundTicketFk = NEW.originalTicketFk THEN + CALL util.throw('Original ticket and refund ticket has same id'); + END IF; + + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE refundTicketFk = NEW.originalTicketFk; + + IF vAlreadyExists > 0 THEN + CALL util.throw('This ticket is already a refund'); + END IF; +END$$ +DELIMITER ; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate` + BEFORE UPDATE ON `ticketRefund` + FOR EACH ROW +BEGIN + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + + IF NEW.refundTicketFk = NEW.originalTicketFk THEN + CALL util.throw('Original ticket and refund ticket has same id'); + END IF; + + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE refundTicketFk = NEW.originalTicketFk; + + IF vAlreadyExists > 0 THEN + CALL util.throw('This ticket is already a refund'); + END IF; +END$$ +DELIMITER ; diff --git a/db/changes/10440-fallas/00-travelThermograph.sql b/db/changes/10440-fallas/00-travelThermograph.sql new file mode 100644 index 000000000..f76f070a0 --- /dev/null +++ b/db/changes/10440-fallas/00-travelThermograph.sql @@ -0,0 +1,16 @@ +DROP TRIGGER `vn`.`travelThermograph_beforeInsert`; + +ALTER TABLE `vn`.`travelThermograph` CHANGE `temperature` `temperature__` enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL; + +CREATE OR REPLACE +ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS +select + `tt`.`thermographFk` AS `thermograph_id`, + `tt`.`created` AS `odbc_date`, + `tt`.`warehouseFk` AS `warehouse_id`, + `tt`.`travelFk` AS `travel_id`, + `tt`.`temperatureFk` AS `temperature`, + `tt`.`result` AS `result`, + `tt`.`dmsFk` AS `gestdoc_id` +from + `vn`.`travelThermograph` `tt`; \ No newline at end of file diff --git a/db/changes/10450-april/00-timeControl_getError.sql b/db/changes/10450-april/00-timeControl_getError.sql new file mode 100644 index 000000000..0caf8ab62 --- /dev/null +++ b/db/changes/10450-april/00-timeControl_getError.sql @@ -0,0 +1,73 @@ +DROP PROCEDURE IF EXISTS vn.timeControl_getError; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN +/* + * @param vDatedFrom + * @param vDatedTo + * @table tmp.`user`(userFk) + * Fichadas incorrectas de las cuales no se puede calcular horas trabajadas + * @return tmp.timeControlError (id) + */ + DECLARE vDayMaxTime INTEGER; + + SET @journeyCounter := 0; + SET @lastUserFk := NULL; + + SELECT dayMaxTime INTO vDayMaxTime + FROM workerTimeControlConfig LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + CREATE TEMPORARY TABLE tmp.timeControl + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT sub.id, + sub.direction, + sub.timed, + IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter, + @lastUserFk := sub.userFk workerFk, + IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE) + FROM ( + SELECT DISTINCT wtc.id, + wtc.direction, + wtc.timed, + wtc.userFk + FROM workerTimeControl wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY) + ORDER BY wtc.userFk, wtc.timed + ) sub; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + CREATE TEMPORARY TABLE tmp.timeControlAux + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT * FROM tmp.timeControl; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError; + CREATE TEMPORARY TABLE tmp.timeControlError + (INDEX(id)) + ENGINE = MEMORY + SELECT id + FROM tmp.timeControlAux tca + JOIN (SELECT journeyCounter, + UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork, + SUM(direction = 'in') totalIn, + SUM(direction = 'out') totalOut, + timed + FROM tmp.timeControl + GROUP BY journeyCounter + HAVING COUNT(*) MOD 2 = 1 + OR totalIn <> 1 + OR totalOut <> 1 + OR timeWork >= vDayMaxTime + )sub ON sub.journeyCounter = tca.journeyCounter + WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + +END$$ +DELIMITER ; diff --git a/db/changes/10450-april/delete.keep b/db/changes/10450-april/delete.keep new file mode 100644 index 000000000..e69de29bb diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index bae229513..0849e6708 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -318,10 +318,10 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), @@ -2454,6 +2454,13 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (6, 29.95, '7001000000', NULL, 7, 20), (7, 58.64, '6210000567', NULL, 8, 20); +INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) + VALUES + (1, 30.50, 5080000, 10.00, 162, 5), + (1, 10, 6021010, 20.00, 205, 5), + (2, 13.20, 5080000, 15.00, 580, 5), + (2, 16.10, 6021010, 25.00, 80, 5); + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT `id` FROM `vn`.`ticket` t @@ -2503,18 +2510,6 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced` (1107, 500, CURDATE(), CURDATE()), (1109, 500, CURDATE(), CURDATE()); -UPDATE `vn`.`agency` - SET `supplierFk`=1 - WHERE `id`=1; - -UPDATE `vn`.`agency` - SET `supplierFk`=1 - WHERE `id`=2; - -UPDATE `vn`.`agency` - SET `supplierFk`=2 - WHERE `id`=3; - UPDATE `vn`.`route` SET `invoiceInFk`=1 WHERE `id`=1; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 21ed27158..d664cfbad 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -392,7 +392,6 @@ export default { name: 'vn-item-basic-data vn-textfield[ng-model="$ctrl.item.name"]', relevancy: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.relevancy"]', origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', - compression: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.compression"]', generic: 'vn-autocomplete[ng-model="$ctrl.item.genericFk"]', isFragile: 'vn-check[ng-model="$ctrl.item.isFragile"]', longName: 'vn-textfield[ng-model="$ctrl.item.longName"]', @@ -586,6 +585,7 @@ export default { firstSalePriceInput: '.vn-popover.shown input[ng-model="$ctrl.field"]', firstSaleDiscount: 'vn-ticket-sale vn-table vn-tr:nth-child(1) > vn-td:nth-child(10) > span', firstSaleDiscountInput: '.vn-popover.shown [ng-model="$ctrl.field"]', + saveSaleDiscountButton: '.vn-popover.shown vn-button[label="Save"]', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(11)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleColour: 'vn-ticket-sale vn-tr:nth-child(1) vn-fetched-tags section', diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js index d51f2113f..c7640d028 100644 --- a/e2e/paths/02-client/21_defaulter.spec.js +++ b/e2e/paths/02-client/21_defaulter.spec.js @@ -28,7 +28,7 @@ describe('Client defaulter path', () => { const salesPersonName = await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText'); - expect(clientName).toEqual('Batman'); + expect(clientName).toEqual('Ororo Munroe'); expect(salesPersonName).toEqual('salesPersonNick'); }); diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index 137d94c74..5709e6207 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -99,8 +99,8 @@ describe('Worker time control path', () => { expect(result).toEqual(scanTime); }); - // 3736 check proc vn.timeControl_calculate - xit(`should check Hank Pym worked 6:40 hours`, async() => { + + it(`should check Hank Pym worked 6:40 hours`, async() => { await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.'); }); }); diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js index 0bbb6ad12..a663ea3bb 100644 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -30,8 +30,6 @@ describe('Item Edit basic data path', () => { await page.autocompleteSearch(selectors.itemBasicData.origin, 'Spain'); await page.clearInput(selectors.itemBasicData.relevancy); await page.write(selectors.itemBasicData.relevancy, '1'); - await page.clearInput(selectors.itemBasicData.compression); - await page.write(selectors.itemBasicData.compression, '2'); await page.clearInput(selectors.itemBasicData.generic); await page.autocompleteSearch(selectors.itemBasicData.generic, '16'); await page.waitToClick(selectors.itemBasicData.isActiveCheckbox); @@ -96,13 +94,6 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Spain'); }); - it(`should confirm the item compression was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.itemBasicData.compression, 'value'); - - expect(result).toEqual('2'); - }); - it(`should confirm the item generic was edited`, async() => { const result = await page .waitToGetProperty(selectors.itemBasicData.generic, 'value'); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 5078d5b91..972684708 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -175,7 +175,8 @@ describe('Ticket Edit sale path', () => { it('should update the discount', async() => { await page.waitToClick(selectors.ticketSales.firstSaleDiscount); await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); - await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d'); + await page.type(selectors.ticketSales.firstSaleDiscountInput, '50'); + await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f7c0dad54..9310ae436 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -223,5 +223,6 @@ "The item is required": "El artículo es requerido", "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada" + "reference duplicated": "Referencia duplicada", + "This ticket is already a refund": "Este ticket ya es un abono" } \ No newline at end of file diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index f4eecae6d..e86830200 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -27,7 +27,7 @@ module.exports = Self => { http: {source: 'query'} }, { - arg: 'client', + arg: 'clientName', type: 'string', description: 'The worker name', http: {source: 'query'} @@ -94,14 +94,19 @@ module.exports = Self => { ? {'cl.id': value} : { or: [ - {'cl.socialName': {like: `%${value}%`}} + {'cl.clientName': {like: `%${value}%`}} ] }; + case 'clientName': + return {'cl.clientName': {like: `%${value}%`}}; + case 'clientFk': + return {'cl.clientFk': value}; case 'id': case 'claimStateFk': case 'priority': return {[`cl.${param}`]: value}; case 'salesPersonFk': + return {'cl.salesPersonFk': value}; case 'attenderFk': return {'cl.workerFk': value}; case 'created': @@ -123,13 +128,14 @@ module.exports = Self => { SELECT cl.id, cl.clientFk, - c.socialName, + c.name AS clientName, cl.workerFk, u.name AS workerName, cs.description, cl.created, cs.priority, - cl.claimStateFk + cl.claimStateFk, + c.salesPersonFk FROM claim cl LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN worker w ON w.id = cl.workerFk diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index c54318e45..b26afe8c4 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -25,7 +25,7 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 'Iron man'}}, null, options); + const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); diff --git a/modules/claim/front/index/index.html b/modules/claim/front/index/index.html index 341d6eb2f..102e27245 100644 --- a/modules/claim/front/index/index.html +++ b/modules/claim/front/index/index.html @@ -10,16 +10,16 @@
+ | Id | -+ | Client | Created | -+ | Worker | @@ -40,7 +40,7 @@ - {{::claim.socialName}} + {{::claim.clientName}} | {{::claim.created | date:'dd/MM/yyyy'}} | diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js index bf0cb25c0..084618e16 100644 --- a/modules/claim/front/index/index.js +++ b/modules/claim/front/index/index.js @@ -11,11 +11,11 @@ class Controller extends Section { }, columns: [ { - field: 'clientFk', + field: 'clientName', autocomplete: { url: 'Clients', - showField: 'socialName', - valueField: 'socialName' + showField: 'name', + valueField: 'name' } }, { @@ -46,21 +46,12 @@ class Controller extends Section { exprBuilder(param, value) { switch (param) { + case 'clientName': + return {'cl.clientName': {like: `%${value}%`}}; case 'clientFk': - return {['cl.socialName']: value}; - case 'id': case 'claimStateFk': - case 'priority': + case 'workerFk': return {[`cl.${param}`]: value}; - case 'salesPersonFk': - case 'attenderFk': - return {'cl.workerFk': value}; - case 'created': - value.setHours(0, 0, 0, 0); - to = new Date(value); - to.setHours(23, 59, 59, 999); - - return {'cl.created': {between: [value, to]}}; } } diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 22faf9ec4..d522763a1 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -18,7 +18,7 @@+ | Client | diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 82719bef0..80f510bf2 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -13,11 +13,11 @@ export default class Controller extends Section { }, columns: [ { - field: 'clientName', + field: 'clientFk', autocomplete: { url: 'Clients', - showField: 'socialName', - valueField: 'socialName' + showField: 'name', + valueField: 'id' } }, { @@ -114,7 +114,7 @@ export default class Controller extends Section { switch (param) { case 'creditInsurance': case 'amount': - case 'clientName': + case 'clientFk': case 'workerFk': case 'salesPersonFk': return {[`d.${param}`]: value}; diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index d7d1a684d..5801fa1f8 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -104,15 +104,15 @@ describe('client defaulter', () => { describe('exprBuilder()', () => { it('should search by sales person', () => { - let expr = controller.exprBuilder('salesPersonFk', '5'); + const expr = controller.exprBuilder('salesPersonFk', '5'); expect(expr).toEqual({'d.salesPersonFk': '5'}); }); - it('should search by client name', () => { - let expr = controller.exprBuilder('clientName', '1foo'); + it('should search by client', () => { + const expr = controller.exprBuilder('clientFk', '5'); - expect(expr).toEqual({'d.clientName': '1foo'}); + expect(expr).toEqual({'d.clientFk': '5'}); }); }); }); diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 61cde8b22..1069d3487 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -23,6 +23,7 @@ export default class Client extends ModuleMain { case 'id': case 'fi': case 'postcode': + case 'provinceFk': case 'salesPersonFk': return {[param]: value}; } diff --git a/modules/client/front/notification/index.html b/modules/client/front/notification/index.html index f503c95c8..49e4e3c3f 100644 --- a/modules/client/front/notification/index.html +++ b/modules/client/front/notification/index.html @@ -67,7 +67,7 @@ |
{{::client.id}}
@@ -83,7 +83,9 @@
-
+ |
---|