Merge branch '1999-travel_basicData' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-01-15 07:47:12 +00:00 committed by Gitea
commit 0fb6d27fd1
4 changed files with 382 additions and 201 deletions

File diff suppressed because one or more lines are too long

View File

@ -13606,6 +13606,10 @@ CREATE TABLE `business_labour_payroll` (
`cod_contrato` int(11) DEFAULT NULL,
`importepactado` decimal(10,2) NOT NULL DEFAULT '0.00',
PRIMARY KEY (`business_id`),
KEY `business_labour_payroll_cod_categoria_idx` (`cod_categoria`),
KEY `business_labour_payroll_cod_contrato` (`cod_contrato`),
CONSTRAINT `business_labour_payroll_cod_categoria` FOREIGN KEY (`cod_categoria`) REFERENCES `vn2008`.`payroll_categorias` (`codcategoria`) ON UPDATE CASCADE,
CONSTRAINT `business_labour_payroll_cod_contrato` FOREIGN KEY (`cod_contrato`) REFERENCES `vn2008`.`payroll_contratos` (`CodContrato`) ON UPDATE CASCADE,
CONSTRAINT `business_labour_payroll_fk1` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -20972,9 +20976,6 @@ DELIMITER ;;
BEFORE INSERT ON `item` FOR EACH ROW
BEGIN
DECLARE vDensity DOUBLE;
DECLARE vInsertId INT;
DECLARE vProducerFk VARCHAR(50);
DECLARE vInkName VARCHAR(50);
IF NEW.density IS NULL THEN
SELECT density INTO vDensity
@ -24185,21 +24186,18 @@ CREATE TABLE `sharingCart` (
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeInsert` BEFORE INSERT ON `sharingCart` FOR EACH ROW
BEGIN
SET NEW.started = GREATEST(CURDATE(),NEW.started);
SET NEW.ended = GREATEST(CURDATE(),NEW.ended);
IF NEW.workerFk = NEW.workerSubstitute THEN
SET NEW.workerFk = NULL;
END IF;
IF NEW.workerFk = NEW.workerSubstitute THEN
CALL util.throw ('worker and workerSubstitute must be different');
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -24209,20 +24207,16 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeUpdate` BEFORE UPDATE ON `sharingCart` FOR EACH ROW
BEGIN
SET NEW.started = GREATEST(CURDATE(),NEW.started);
SET NEW.ended = GREATEST(CURDATE(),NEW.ended);
IF NEW.workerFk = NEW.workerSubstitute THEN
SET NEW.workerFk = NULL;
IF NEW.workerFk = NEW.workerSubstitute THEN
CALL util.throw ('worker and workerSubstitute must be different');
END IF;
END */;;
DELIMITER ;
@ -24231,6 +24225,27 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `sharingCartDaily`
--
DROP TABLE IF EXISTS `sharingCartDaily`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sharingCartDaily` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ownerFk` int(11) NOT NULL,
`substituteFk` int(11) NOT NULL,
`dated` date NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `sharingCartDailyWorker_idx` (`ownerFk`,`dated`),
KEY `sharingCartDailySubstitute_idx` (`substituteFk`),
CONSTRAINT `sharingCartDailySubstitute` FOREIGN KEY (`substituteFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `sharingCartDailyWorker` FOREIGN KEY (`ownerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='para calcular las comisiones de las sustituciones de los comerciales';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `sharingClient`
--
@ -25990,7 +26005,7 @@ BEGIN
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
WHERE travelFk = NEW.id;
END IF;
/*
IF !(ABS(NEW.isDelivered) <=> ABS(OLD.isDelivered))
THEN
INSERT INTO vn2008.travel_dits SET
@ -25999,7 +26014,7 @@ BEGIN
Id_Ticket = NEW.id,
value_old = OLD.isDelivered,
value_new = NEW.isDelivered;
END IF;
END IF; */
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -26031,7 +26046,7 @@ CREATE TABLE `travelLog` (
KEY `userFk` (`userFk`),
CONSTRAINT `travelLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -26242,11 +26257,14 @@ CREATE TABLE `warehouse` (
`hasDms` tinyint(1) NOT NULL DEFAULT '0',
`pickUpAgencyModeFk` int(11) DEFAULT NULL,
`isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT '0',
`aliasFk` smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
KEY `Id_Paises` (`countryFk`),
KEY `isComparativeIdx` (`isComparative`),
CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`)
KEY `warehouse_ibfk_1_idx` (`aliasFk`),
CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`),
CONSTRAINT `warehouse_ibfk_2` FOREIGN KEY (`aliasFk`) REFERENCES `warehouseAlias` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@ -26304,7 +26322,8 @@ DROP TABLE IF EXISTS `warehouseAlias`;
CREATE TABLE `warehouseAlias` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -32416,9 +32435,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@ -32457,6 +32476,7 @@ BEGIN
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL;
DELETE FROM claim WHERE ticketCreated < v18Month;
DELETE FROM message WHERE sendDate < vDateShort;
DELETE FROM travelLog WHERE creationDate < v18Month;
DELETE sc FROM saleChecked sc
JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort;
DELETE bm
@ -33370,70 +33390,56 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `clonTravelComplete`(IN `vTravelFk` INT, IN `vDateStart` DATE, IN `vDateEnd` DATE, IN `vRef` VARCHAR(255))
BEGIN
DECLARE vTravelNew INT;
DECLARE vEntryNew INT;
DECLARE vDone BIT DEFAULT 0;
DECLARE vAuxEntryFk INT;
DECLARE vRsEntry CURSOR FOR
SELECT e.id
FROM entry e
JOIN travel t
ON t.id = e.travelFk
WHERE e.travelFk = vTravelFk;
DECLARE vRsBuy CURSOR FOR
SELECT b.*
FROM buy b
JOIN entry e
ON b.entryFk = e.id
WHERE e.travelFk = vTravelNew and b.entryFk=entryNew
ORDER BY e.id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
INSERT INTO travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3, kg)
SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3, kg
FROM travel
WHERE id = vTravelFk;
SET vTravelNew = LAST_INSERT_ID();
SET vDone = 0;
OPEN vRsEntry ;
FETCH vRsEntry INTO vAuxEntryFk;
DECLARE vTravelNew INT;
DECLARE vEntryNew INT;
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vAuxEntryFk INT;
DECLARE vRsEntry CURSOR FOR
SELECT e.id
FROM entry e
JOIN travel t
ON t.id = e.travelFk
WHERE e.travelFk = vTravelFk;
WHILE NOT vDone DO
INSERT INTO entry (supplierFk,
ref,
isInventory,
isConfirmed,
isOrdered,
isRaid,
commission,
created,
evaNotes,
travelFk,
currencyFk,
companyFk,
gestDocFk,
invoiceInFk)
SELECT supplierFk,
DECLARE vRsBuy CURSOR FOR
SELECT b.*
FROM buy b
JOIN entry e
ON b.entryFk = e.id
WHERE e.travelFk = vTravelNew and b.entryFk=entryNew
ORDER BY e.id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
INSERT INTO travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3, kg)
SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3, kg
FROM travel
WHERE id = vTravelFk;
SET vTravelNew = LAST_INSERT_ID();
SET vDone = FALSE;
OPEN vRsEntry ;
FETCH vRsEntry INTO vAuxEntryFk;
WHILE NOT vDone DO
INSERT INTO entry (supplierFk,
ref,
isInventory,
isConfirmed,
@ -33442,66 +33448,82 @@ BEGIN
commission,
created,
evaNotes,
vTravelNew,
travelFk,
currencyFk,
companyFk,
gestDocFk,
invoiceInFk
FROM entry
WHERE id = vAuxEntryFk;
SET vEntryNew = LAST_INSERT_ID();
INSERT INTO buy (entryFk,
itemFk,
quantity,
buyingValue,
packageFk,
stickers,
freightValue,
packageValue,
comissionValue,
packing,
`grouping`,
groupingMode,
location,
price1,
price2,
price3,
minPrice,
producer,
printedStickers,
isChecked)
SELECT vEntryNew,
itemFk,
quantity,
buyingValue,
packageFk,
stickers,
freightValue,
packageValue,
comissionValue,
packing,
`grouping`,
groupingMode,
location,
price1,
price2,
price3,
minPrice,
producer,
printedStickers,
isChecked
FROM buy
WHERE entryFk = vAuxEntryFk;
FETCH vRsEntry INTO vAuxEntryFk;
END WHILE;
CLOSE vRsEntry;
COMMIT;
END ;;
invoiceInFk)
SELECT supplierFk,
ref,
isInventory,
isConfirmed,
isOrdered,
isRaid,
commission,
created,
evaNotes,
vTravelNew,
currencyFk,
companyFk,
gestDocFk,
invoiceInFk
FROM entry
WHERE id = vAuxEntryFk;
SET vEntryNew = LAST_INSERT_ID();
INSERT INTO buy (entryFk,
itemFk,
quantity,
buyingValue,
packageFk,
stickers,
freightValue,
packageValue,
comissionValue,
packing,
`grouping`,
groupingMode,
location,
price1,
price2,
price3,
minPrice,
producer,
printedStickers,
isChecked,
weight)
SELECT vEntryNew,
itemFk,
quantity,
buyingValue,
packageFk,
stickers,
freightValue,
packageValue,
comissionValue,
packing,
`grouping`,
groupingMode,
location,
price1,
price2,
price3,
minPrice,
producer,
printedStickers,
isChecked,
weight
FROM buy
WHERE entryFk = vAuxEntryFk;
FETCH vRsEntry INTO vAuxEntryFk;
END WHILE;
CLOSE vRsEntry;
COMMIT;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
@ -33513,7 +33535,7 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_unicode_ci */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@ -33521,11 +33543,13 @@ CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get`(vCollectionFk INT)
BEGIN
DECLARE vCalcFk INT;
DECLARE vWarehouseFk INT;
DECLARE vWarehouseAliasFk INT;
SELECT t.warehouseFk
INTO vWarehouseFk
SELECT t.warehouseFk, w.aliasFk
INTO vWarehouseFk, vWarehouseAliasFk
FROM vn.ticket t
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
JOIN vn.warehouse w ON w.id = t.warehouseFk
LIMIT 1;
CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk);
@ -33533,13 +33557,18 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.parked;
CREATE TEMPORARY TABLE tmp.parked
ENGINE MEMORY
SELECT s.itemFk,
sum(IFNULL(ish.visible,0)) as quantity
SELECT s.itemFk, 0 as quantity
FROM vn.ticketCollection tc
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
LEFT JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
WHERE tc.collectionFk = vCollectionFk
GROUP BY s.itemFk;
WHERE tc.collectionFk = vCollectionFk;
UPDATE tmp.parked pk
JOIN ( SELECT itemFk, sum(visible) as visible
FROM vn.itemShelvingStock iss
JOIN vn.warehouse w ON w.id = iss.warehouseFk
WHERE w.aliasFk = vWarehouseAliasFk
GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk
SET pk.quantity = iss.visible;
DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`;
CREATE TEMPORARY TABLE tmp.`grouping`
@ -33580,8 +33609,10 @@ BEGIN
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk
JOIN tmp.`grouping` g ON g.itemFk = s.itemFk
WHERE tc.collectionFk = vCollectionFk
AND w.aliasFk = vWarehouseAliasFk
UNION ALL
SELECT s.id as saleFk, s.itemFk,
ip.code COLLATE utf8_general_ci as placement,
@ -33597,7 +33628,9 @@ BEGIN
JOIN tmp.parked p ON p.itemFk = s.itemFk
JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk
LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk
WHERE tc.collectionFk = vCollectionFk;
WHERE tc.collectionFk = vCollectionFk
-- HAVING visible > 0
;
DROP TEMPORARY TABLE
tmp.parked,
@ -33613,9 +33646,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@ -33640,18 +33673,19 @@ BEGIN
i.longName,
i.size,
s.reserved,
stPrevious.isChecked as isPreviousPrepared,
stPrepared.isChecked as isPrepared,
stControled.isChecked as isControlled
IF(st.semaphore <=> 1, TRUE, FALSE) as isPreviousPrepared,
IF(st.semaphore <=> 2, TRUE, FALSE) as isPrepared,
IF(st.semaphore <=> 3, TRUE, FALSE) as isControlled
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26
LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14
LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8
LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1
LEFT JOIN vn.state st ON st.id = str.stateFk
JOIN vn.ticketCollection tc ON tc.ticketFk = s.ticketFk
WHERE tc.collectionFk = vCollectionFk
) sub
GROUP BY saleFk
HAVING quantity > 0
UNION ALL
@ -33660,8 +33694,8 @@ BEGIN
0,
1,
CONCAT('POLIZON T',stow.id),
NULL,
NULL,
0 AS size,
0 AS reserved,
IF(st.semaphore <=> 1,TRUE, FALSE) as isPreviousPrepared,
IF(st.semaphore <=> 2,TRUE, FALSE) as isPrepared,
IF(st.semaphore <=> 3,TRUE, FALSE) as isControlled
@ -33710,9 +33744,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@ -33723,9 +33757,9 @@ BEGIN
tc.level,
am.name as agencyName
FROM vn.ticketCollection tc
JOIN vn.ticket t ON t.id = tc.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
JOIN vn.ticket t ON t.id = tc.ticketFk
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
WHERE tc.collectionFk = vCollectionFk;
END ;;
@ -33763,6 +33797,7 @@ proc:BEGIN
DECLARE vVolumetryLitersMax INT;
DECLARE vVolumetryLinesMax INT;
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vWorkerCode VARCHAR(3);
DECLARE cVolumetry CURSOR FOR
SELECT level, liters, `lines`
@ -33778,8 +33813,8 @@ proc:BEGIN
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket
WHERE pb.problems = 0
AND tc.ticketFk IS NULL
AND s.isPreparable
ORDER BY pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC
AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode))
ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC
LIMIT vMaxTickets;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
@ -33789,6 +33824,11 @@ proc:BEGIN
FROM vn.sector
WHERE id = vSectorFk;
SELECT w.code
INTO vWorkerCode
FROM vn.worker w
WHERE w.id = account.myUserGetId();
IF vIsPreviousPrepared THEN
SELECT id INTO vStateFk
@ -33811,7 +33851,7 @@ proc:BEGIN
-- Empieza el bucle
OPEN cVolumetry;
OPEN cTicket;
/*
DROP TEMPORARY TABLE IF EXISTS tmp.kk;
CREATE TEMPORARY TABLE tmp.kk
SELECT pb.Id_Ticket ticketFk,pb.Hora, pb.Minuto,
@ -33822,10 +33862,10 @@ proc:BEGIN
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket
WHERE pb.problems = 0
AND tc.ticketFk IS NULL
AND s.isPreparable
ORDER BY pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC
AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode))
ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC
LIMIT vMaxTickets;
*/
FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters;
FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines;
@ -33841,7 +33881,9 @@ proc:BEGIN
bucle:WHILE NOT vDone DO
IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN
LEAVE bucle;
LEAVE bucle;
END IF;
SELECT COUNT(*) INTO vIsTicketCollected
@ -33876,7 +33918,9 @@ proc:BEGIN
SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines);
IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN
LEAVE bucle;
END IF;
IF vTicketLiters > 0 OR vTicketLines > 0 THEN
@ -38668,14 +38712,71 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25))
BEGIN
/**
* Factura un conjunto de tickets.
*
* @param vInvoice, vTaxAreaFk
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
* @return tmp.ticketAmount
* @return tmp.ticketTax Impuesto desglosado para cada ticket.
*/
DELETE FROM invoiceOutTax
WHERE invoiceOutFk = vInvoice;
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
CREATE TEMPORARY TABLE tmp.ticket
(KEY (ticketFk))
ENGINE = MEMORY
SELECT id ticketFk
FROM ticketToInvoice;
CALL ticket_getTax(vTaxArea);
INSERT INTO invoiceOutTax(
invoiceOutFk,
pgcFk,
taxableBase,
vat
)
SELECT vInvoice,
pgcFk,
SUM(taxableBase) as BASE,
CAST(SUM(taxableBase) * rate / 100 AS DECIMAL (10,2))
FROM tmp.ticketTax
GROUP BY pgcFk
HAVING BASE
ORDER BY priority;
DROP TEMPORARY TABLE tmp.ticket;
DROP TEMPORARY TABLE tmp.ticketTax;
DROP TEMPORARY TABLE tmp.ticketAmount;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceTaxMake__` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `invoiceTaxMake__`(vInvoice INT, vTaxArea VARCHAR(25))
BEGIN
/**
* Factura un conjunto de tickets.
*
@ -42492,7 +42593,7 @@ BEGIN
ON DUPLICATE KEY UPDATE `code` = vCode;
SET vRow = vRow + 1;
SET vCode = CONCAT(LPAD(vColumn,3,'0'),IF(vIsLetterMode, MID(vLetters, vRow, 1), CONCAT('-',LPAD(vRow, 2,'0'))));
SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
END WHILE;
@ -47431,7 +47532,7 @@ BEGIN
SELECT tp.ticketFk, CONCAT(vCollectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.code = p.sectorFk
JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
JOIN vn.ticketStateToday tst ON tst.ticket = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk
@ -49308,9 +49409,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@ -49318,6 +49419,43 @@ CREATE DEFINER=`root`@`%` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek
BEGIN
DECLARE vCounter INT;
SET vCounter = vSinceWeek;
vWeekLoop :LOOP
INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk, kg)
SELECT @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
@a := TIMESTAMPADD(DAY,duration,@a),
warehouseOutFk,
warehouseInFk,
agencyModeFk,
ref,
cargoSupplierFk,
kg
FROM travel_cloneWeekly;
IF vCounter = vToWeek THEN
LEAVE vWeekLoop;
END IF;
SET vCounter = vCounter + 1;
END LOOP;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_weeklyClone__` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `travel_weeklyClone__`(vSinceWeek INT, vToWeek INT)
BEGIN
DECLARE vCounter INT;
SET vCounter = vSinceWeek;
vWeekLoop :LOOP
INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk)
@ -51218,6 +51356,49 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_getProductionErrors` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `worker_getProductionErrors`(vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.total;
CREATE TEMPORARY TABLE tmp.total
ENGINE = MEMORY
SELECT tt.workerFk, Count(tt.ticketFk) AS CuentaDeId_Ticket
FROM state s
INNER JOIN ticketTracking tt ON s.id = tt.stateFk
INNER JOIN ticket t ON tt.ticketFk = t.id
INNER JOIN worker w ON tt.workerFk = w.id
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND s.code = vStateCode
GROUP BY tt.workerFk;
SELECT w.code, w.firstName, w.lastName, CAST(tmp.total.CuentaDeId_Ticket AS DECIMAL(10,0)) AS Totaltickets,
CAST(sub.CuentaDeId_Ticket AS DECIMAL(10,0)) AS Fallos
fROM tmp.total
JOIN worker w ON w.id= tmp.total.workerFk
LEFT JOIN ( SELECT Count(s.ticketFk) AS CuentaDeId_Ticket, cd.workerFk
FROM (claimDevelopment cd
INNER JOIN ((sale s
INNER JOIN claimBeginning cb ON s.id = cb.saleFk)
INNER JOIN ticket t ON s.ticketFk = t.id) ON cd.claimFk = cb.claimFk)
INNER JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id
WHERE t.shipped BETwEEN vDatedFrom AND vDatedTo AND cr.description=vDepartment
GROUP BY cd.workerFk)sub ON tmp.total.workerFk = sub.workerFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workingHours` */;
ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@ -54751,4 +54932,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-01-08 13:31:07
-- Dump completed on 2020-01-15 7:33:42

View File

@ -7,7 +7,7 @@ describe('Client activeWorkersWithRole', () => {
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
expect(result.length).toEqual(14);
expect(result.length).toEqual(15);
expect(isSalesPerson).toBeTruthy();
});

View File

@ -6,7 +6,7 @@ describe('Client listWorkers', () => {
.then(result => {
let amountOfEmployees = Object.keys(result).length;
expect(amountOfEmployees).toEqual(49);
expect(amountOfEmployees).toEqual(50);
done();
})
.catch(done.fail);