diff --git a/db/changes/10002-lent/00-clientGetSalesPerson.sql b/db/changes/10002-lent/00-clientGetSalesPerson.sql new file mode 100644 index 000000000..f93e528a2 --- /dev/null +++ b/db/changes/10002-lent/00-clientGetSalesPerson.sql @@ -0,0 +1,76 @@ + +DROP function IF EXISTS `vn`.`clientGetSalesPerson`; +DELIMITER $$ +CREATE DEFINER=`root`@`%` FUNCTION `vn`.`clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo + * en cuenta la jerarquía de las tablas: 1º la de sharingClient, 2º la de + * sharingCart y tercero la de clientes. + * + * @param vClientFk El id del cliente + * @param vDated Fecha a comprobar + * @return El id del comercial para la fecha dada + **/ + DECLARE vSalesperson INT DEFAULT NULL; + DECLARE vSubstitute INT DEFAULT NULL; + DECLARE vLoop BOOLEAN; + + -- Obtiene el comercial original y el de sharingClient + + SELECT c.salesPersonFk, s.workerFk + INTO vSalesperson, vSubstitute + FROM client c + LEFT JOIN sharingClient s + ON c.id = s.clientFk + AND vDated BETWEEN s.started AND s.ended + WHERE c.id = vClientFk + ORDER BY s.id + LIMIT 1; + + -- Si no hay ninguno en sharingClient busca en sharingCart + + IF vSubstitute IS NOT NULL + THEN + SET vSalesperson = vSubstitute; + ELSEIF vSalesperson IS NOT NULL + THEN + DROP TEMPORARY TABLE IF EXISTS tmp.stack; + CREATE TEMPORARY TABLE tmp.stack + (INDEX (substitute)) + ENGINE = MEMORY + SELECT vSalesperson substitute; + + l: LOOP + SELECT workerSubstitute INTO vSubstitute + FROM sharingCart + WHERE vDated BETWEEN started AND ended + AND workerFk = vSalesperson + ORDER BY id + LIMIT 1; + + IF vSubstitute IS NULL THEN + LEAVE l; + END IF; + + SELECT COUNT(*) > 0 INTO vLoop + FROM tmp.stack WHERE substitute = vSubstitute; + + IF vLoop THEN + LEAVE l; + END IF; + + INSERT INTO tmp.stack SET + substitute = vSubstitute; + + SET vSalesperson = vSubstitute; + END LOOP; + + DROP TEMPORARY TABLE tmp.stack; + END IF; + + RETURN vSalesperson; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10002-lent/00-sharingCart.sql b/db/changes/10002-lent/00-sharingCart.sql new file mode 100644 index 000000000..1267cd044 --- /dev/null +++ b/db/changes/10002-lent/00-sharingCart.sql @@ -0,0 +1,14 @@ +CREATE + ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`sharingCart` AS + SELECT + `s`.`id` AS `id`, + `s`.`Id_Trabajador` AS `workerFk`, + `s`.`datSTART` AS `started`, + `s`.`datEND` AS `ended`, + `s`.`Id_Suplente` AS `workerSubstitute`, + `s`.`odbc_date` AS `created` + FROM + `vn2008`.`sharingcart` `s` \ No newline at end of file diff --git a/db/changes/10002-lent/00-sharingclient.sql b/db/changes/10002-lent/00-sharingclient.sql new file mode 100644 index 000000000..ab76ec6c5 --- /dev/null +++ b/db/changes/10002-lent/00-sharingclient.sql @@ -0,0 +1,13 @@ +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`sharingClient` AS + SELECT + `s`.`id` AS `id`, + `s`.`Id_Trabajador` AS `workerFk`, + `s`.`datSTART` AS `started`, + `s`.`datEND` AS `ended`, + `s`.`Id_Cliente` AS `clientFk` + FROM + `vn2008`.`sharingclient` `s`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index aec4a3a3a..13233b69e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1317,3 +1317,11 @@ INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `user`, `password`, `title`) VALUES ('1', 'https://websms.xtratelecom.es/api_php/server.wsdl', 'VERDINATURA', '182wbOKu', 'Verdnatura'); +INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) + VALUES + (1, 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 101), + (2, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 106); + +INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`) + VALUES + (1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY)); \ No newline at end of file diff --git a/front/core/components/td-editable/style.scss b/front/core/components/td-editable/style.scss index cff3400b9..19c56cb02 100644 --- a/front/core/components/td-editable/style.scss +++ b/front/core/components/td-editable/style.scss @@ -3,9 +3,16 @@ vn-td-editable { text { border-bottom: 1px solid rgba(0,0,0,.12); + min-height: 15px; cursor: pointer; display: block } + + text::after { + overflow: hidden; + content: ''; + clear: both; + } outline: none; position: relative; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d9cc89541..d30886476 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -80,5 +80,6 @@ "We weren't able to send this SMS": "No hemos podido enviar el SMS", "This client can't be invoiced": "Este cliente no puede ser facturado", "This ticket can't be invoiced": "Este ticket no puede ser facturado", - "That item is not available on that day": "That item is not available on that day" + "That item is not available on that day": "That item is not available on that day", + "That item doesn't exists": "That item doesn't exists" } \ No newline at end of file diff --git a/modules/client/front/credit-insurance/create/index.html b/modules/client/front/credit-insurance/create/index.html index c635f75d6..c4b7dc35f 100644 --- a/modules/client/front/credit-insurance/create/index.html +++ b/modules/client/front/credit-insurance/create/index.html @@ -1,7 +1,7 @@