'
- )
+ )
INTO vSendMail, vBody
- FROM XDiario
+ FROM XDiario
WHERE ASIEN = vAsien;
- DELETE FROM XDiario
+ DELETE FROM XDiario
WHERE ASIEN = vAsien;
-
+
IF vSendMail THEN
CALL mail_insert(
'administracion@verdnatura.es',
@@ -58083,7 +58571,7 @@ BEGIN
SET refFk = NULL
WHERE refFk = vRef;
- DELETE
+ DELETE
FROM invoiceOut
WHERE ref = vRef;
@@ -58093,6 +58581,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutListByCompany` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58100,13 +58590,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE)
BEGIN
-SELECT
+SELECT
c.socialName as RazonSocial,
c.fi as NIF,
io.ref as Factura,
@@ -58118,7 +58606,7 @@ SELECT
pgc.rate as Tipo,
iot.vat as Cuota,
pgc.name as Concepto
-
+
FROM vn.invoiceOut io
JOIN vn.invoiceOutTax iot ON iot.invoiceOutFk = io.id
JOIN vn.client c ON c.id = io.clientFk
@@ -58133,6 +58621,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutTaxAndExpence` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58140,8 +58630,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpence`()
BEGIN
@@ -58222,6 +58710,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_exportationFromClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58229,8 +58719,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_exportationFromClient`(
vMaxTicketDate DATETIME,
@@ -58267,15 +58755,15 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_new` */;
/*!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 = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new`(
vSerial VARCHAR(255),
@@ -58552,6 +59040,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58559,21 +59049,19 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromClient`(
- IN vClientFk INT,
- IN vSerial CHAR(2),
+ IN vClientFk INT,
+ IN vSerial CHAR(2),
IN vMaxShipped DATE,
- IN vCompanyFk INT,
+ IN vCompanyFk INT,
IN vTaxArea VARCHAR(25),
- IN vRef VARCHAR(25),
+ IN vRef VARCHAR(25),
OUT vInvoiceId INT)
BEGIN
/**
* Factura los tickets de un cliente hasta una fecha dada
- * @param vClientFk Id del cliente a facturar
+ * @param vClientFk Id del cliente a facturar
* @param vSerial Serie de factura
* @param vMaxShipped Fecha hasta la cual cogera tickets para facturar
* @param vCompanyFk Id de la empresa desde la que se factura
@@ -58592,11 +59080,11 @@ BEGIN
IF NOT vIsRefEditable THEN
CALL util.throw('serial non editable');
END IF;
- END IF;
+ END IF;
SELECT COUNT(*) INTO vIsExportation
FROM vn.invoiceOutSerial
- WHERE taxAreaFk = 'WORLD'
+ WHERE taxAreaFk = 'WORLD'
AND `code` = vSerial;
IF vIsExportation THEN
@@ -58609,7 +59097,7 @@ BEGIN
UPDATE invoiceOut
SET `ref` = vRef
- WHERE id = vInvoiceId
+ WHERE id = vInvoiceId
AND vRef IS NOT NULL;
IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN
@@ -58621,6 +59109,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58628,8 +59118,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25),
IN vRef varchar(25), OUT vInvoiceId int)
@@ -58638,7 +59126,7 @@ BEGIN
* Factura un ticket
* @param vTicketFk Id del ticket
* @param vSerial Serie de factura
- * @param vTaxArea Area de la factura en caso de querer forzarlo,
+ * @param vTaxArea Area de la factura en caso de querer forzarlo,
* en la mayoria de los casos poner NULL
* @return vInvoiceId
*/
@@ -58653,11 +59141,11 @@ BEGIN
IF NOT vIsRefEditable THEN
CALL util.throw('serial non editable');
END IF;
-
- UPDATE invoiceOut
+
+ UPDATE invoiceOut
SET `ref` = vRef
WHERE id = vInvoiceId;
- END IF;
+ END IF;
IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN
CALL invoiceOutBooking(vInvoiceId);
@@ -58668,6 +59156,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceTaxMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58675,8 +59165,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25))
BEGIN
@@ -58725,6 +59213,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemBarcode_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58732,14 +59222,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL)
BEGIN
IF vDelete THEN
DELETE FROM vn.itemBarcode WHERE itemFk = vItemFk AND code = vCode;
-ELSE
+ELSE
INSERT INTO vn.itemBarcode(itemFk,code) VALUES (vItemFk,vCode);
END IF;
@@ -58749,6 +59237,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemFreight_Show` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58756,13 +59246,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFreight_Show`(vItemFk INT, vWarehouseFk INT)
BEGIN
-
- SELECT cm3 Volumen_Entrada,
+
+ SELECT cm3 Volumen_Entrada,
cm3delivery Volumen_Salida,
p.volume Volumen_del_embalaje,
p.width Ancho_del_embalaje,
@@ -58775,11 +59263,11 @@ BEGIN
b.id buyFk,
b.entryFk,
w.name warehouseFk
- FROM vn.itemCost ic
- JOIN vn.item i ON i.id = ic.itemFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- LEFT JOIN vn.packaging p ON p.id = b.packageFk
+ FROM vn.itemCost ic
+ JOIN vn.item i ON i.id = ic.itemFk
+ LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk
+ LEFT JOIN vn.buy b ON b.id = lb.buy_id
+ LEFT JOIN vn.packaging p ON p.id = b.packageFk
LEFT JOIN vn.warehouse w ON w.id = ic.warehouseFk
WHERE ic.itemFk = vItemFk
AND ic.warehouseFk = vWarehouseFk;
@@ -58789,6 +59277,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemFuentesBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58796,40 +59286,38 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFuentesBalance`(vDaysInFuture INT)
BEGIN
/* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro
- *
+ *
* @param vDaysInFuture Rango de dias para calcular entradas y salidas
- *
+ *
*/
-
+
DECLARE vWarehouseFk INT;
SELECT s.warehouseFk INTO vWarehouseFk
- FROM vn.sector s
+ FROM vn.sector s
WHERE s.code = 'FUENTES_PICASSE';
-
+
CALL cache.stock_refresh(FALSE);
- SELECT i.id itemFk,
+ SELECT i.id itemFk,
i.longName,
i.size,
i.subName,
- v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible,
- fue.Fuentes,
+ v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible,
+ fue.Fuentes,
alb.Albenfruit,
- sale.venta,
- IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra,
- IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0)
+ sale.venta,
+ IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra,
+ IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0)
- IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo
- FROM vn.item i
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ FROM vn.item i
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes
FROM vn.itemShelving ish
@@ -58837,7 +59325,7 @@ BEGIN
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'FUENTES_PICASSE'
- GROUP BY ish.itemFk
+ GROUP BY ish.itemFk
) fue ON fue.itemFk = i.id
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit
@@ -58846,7 +59334,7 @@ BEGIN
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'ALBENFRUIT'
- GROUP BY ish.itemFk
+ GROUP BY ish.itemFk
) alb ON alb.itemFk = i.id
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
LEFT JOIN (
@@ -58871,9 +59359,9 @@ BEGIN
AND warehouse_id = vWarehouseFk
GROUP BY item_id
) mov ON mov.item_id = i.id
- WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit)
+ WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit)
AND i.itemPackingTypeFk = 'H'
- AND ic.shortLife
+ AND ic.shortLife
;
END ;;
@@ -58882,6 +59370,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementFromTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58889,13 +59379,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementFromTicket`(vTicket INT)
BEGIN
/**
- * Llama a itemPlacementUpdateVisible
+ * Llama a itemPlacementUpdateVisible
* de los articulos de la tabla temporal tmp.itemPlacement(itemFk)
* @treturn tmp.itemPlacement
* @param vTicket Id del Ticket
@@ -58909,9 +59397,9 @@ BEGIN
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
WHERE t.id = vTicket;
-
+
CALL itemPlacementUpdateVisible();
-
+
DROP TEMPORARY TABLE tmp.itemPlacement;
END ;;
DELIMITER ;
@@ -58919,6 +59407,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyAiming` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58926,8 +59416,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
BEGIN
@@ -58944,7 +59432,7 @@ BEGIN
CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
' x ',
ish.packing,
- IF (
+ IF (
LEAST(ish.stock,quantity) MOD ish.packing,
CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
''
@@ -58962,6 +59450,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyCloseOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58969,13 +59459,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT)
BEGIN
- UPDATE vn.itemPlacementSupply
+ UPDATE vn.itemPlacementSupply
SET priority = 10
WHERE id = vId;
@@ -58985,6 +59473,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyGetOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58992,8 +59482,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT )
BEGIN
@@ -59001,7 +59489,7 @@ BEGIN
DECLARE vId INT;
DECLARE vLastParkingFk INT;
DECLARE vNextParkingFk INT;
-
+
SELECT sh.parkingFk INTO vLastParkingFk
FROM vn.itemShelvingPlacementSupply isps
JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk
@@ -59009,9 +59497,9 @@ BEGIN
WHERE isps.userFk = getUser()
ORDER BY isps.created DESC
LIMIT 1;
-
+
SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
-
+
SELECT ipsl.id INTO vId
FROM vn.itemPlacementSupplyList ipsl
JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
@@ -59020,13 +59508,13 @@ BEGIN
AND ipsl.sectorFk = vSector
ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created
LIMIT 1;
-
+
UPDATE vn.itemPlacementSupply
SET repoUserFk = getUser()
WHERE id = vId;
-
- SELECT * FROM vn.itemPlacementSupplyList
- WHERE id = vId
+
+ SELECT * FROM vn.itemPlacementSupplyList
+ WHERE id = vId
AND sectorFk = vSector;
END ;;
@@ -59035,6 +59523,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyStockGetTargetList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59042,8 +59532,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
BEGIN
@@ -59082,6 +59570,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemProposal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59089,8 +59579,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal`(vItemFk INT, vTicketFk INT,vShowType BOOL)
BEGIN
@@ -59101,20 +59589,20 @@ BEGIN
* @param vItemFk item id
* @param vTicketFk ticket id
* @param vShowType mostrar tipos
- */
+ */
DECLARE vWarehouseFk INT;
DECLARE vShipped DATE;
DECLARE vCalcFk INT;
DECLARE vTypeFk INT;
-
-
+
+
DECLARE vTag1 VARCHAR(25);
DECLARE vTag5 VARCHAR(25);
DECLARE vTag6 VARCHAR(25);
DECLARE vTag7 VARCHAR(25);
DECLARE vTag8 VARCHAR(25);
-
+
DECLARE vValue1 VARCHAR(50);
DECLARE vValue5 VARCHAR(50);
DECLARE vValue6 VARCHAR(50);
@@ -59124,16 +59612,16 @@ BEGIN
SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
FROM vn.ticket
WHERE id = vTicketFk;
-
+
SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
FROM vn.item i
LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
WHERE i.id = vItemFk;
-
+
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
+
SELECT i.id itemFk,
i.longName,
i.subName,
@@ -59166,7 +59654,7 @@ BEGIN
ORDER BY counter DESC,
(t1.name = vTag1 COLLATE utf8_general_ci) DESC,
(it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
+ (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
(i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
(i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
(i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
@@ -59174,7 +59662,7 @@ BEGIN
(i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
(i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
(i.value8 = vValue8 COLLATE utf8_general_ci) DESC;
-
+
END ;;
DELIMITER ;
@@ -59182,6 +59670,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemProposal_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59189,8 +59679,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT)
BEGIN
@@ -59200,7 +59688,7 @@ BEGIN
* @param vSaleFk id de la tabla sale
* @param vMateFk articulo sustituto
* @ param vQuantity cantidad que se va a sustituir
- */
+ */
DECLARE vTicketFk INT;
DECLARE vItemFk INT;
DECLARE vWarehouseFk SMALLINT;
@@ -59209,41 +59697,41 @@ BEGIN
DECLARE vBox INT;
DECLARE vPacking INT;
DECLARE vRoundQuantity INT DEFAULT 1;
-
+
SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk
INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
WHERE s.id = vSaleFk;
-
+
UPDATE vn.sale
SET quantity = quantity - vQuantity
WHERE id = vSaleFk;
-
+
CALL vn.buyUltimate(vWarehouseFk, vDate);
-
+
SELECT `grouping`, groupingMode, packing
INTO vGrouping,vBox,vPacking
FROM buy b
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
WHERE tmp.itemFk = vMateFk AND tmp.WarehouseFk = vWarehouseFk;
-
+
IF vBox = 2 AND vPacking > 0 THEN
SET vRoundQuantity = vPacking;
END IF;
IF vBox = 1 AND vGrouping > 0 THEN
SET vRoundQuantity = vGrouping;
END IF;
-
+
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept)
SELECT vTicketFk, vMateFk, CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName)
FROM vn.item i
WHERE id = vMateFk;
-
+
SELECT LAST_INSERT_ID() INTO vSaleFk;
-
+
CALL vn.sale_calculateComponent(vSaleFk, NULL);
-
+
INSERT INTO vn.itemProposal(itemFk, mateFk, counter)
VALUES(vItemFk, vMateFk, 1)
ON DUPLICATE KEY UPDATE counter = counter + 1;
@@ -59254,6 +59742,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemProposal_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59261,8 +59751,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_beta`(vItemFk INT, vTicketFk INT)
BEGIN
@@ -59272,13 +59760,13 @@ BEGIN
DECLARE vCalcFk INT;
DECLARE vTypeFk INT;
DECLARE vResultsMax INT DEFAULT 10;
-
+
DECLARE vTag1 VARCHAR(25);
DECLARE vTag5 VARCHAR(25);
DECLARE vTag6 VARCHAR(25);
DECLARE vTag7 VARCHAR(25);
DECLARE vTag8 VARCHAR(25);
-
+
DECLARE vValue1 VARCHAR(50);
DECLARE vValue5 VARCHAR(50);
DECLARE vValue6 VARCHAR(50);
@@ -59288,16 +59776,16 @@ BEGIN
SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
FROM vn.ticket
WHERE id = vTicketFk;
-
+
SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
+ FROM vn.item i
LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
WHERE i.id = vItemFk;
-
+
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
+
SELECT i.id itemFk,
i.longName,
i.subName,
@@ -59315,7 +59803,7 @@ BEGIN
(i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
a.available,
IFNULL(ip.counter,0) counter
- FROM vn.item i
+ FROM vn.item i
JOIN cache.available a ON a.item_id = i.id
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
@@ -59329,7 +59817,7 @@ BEGIN
(it1.value = vValue1 COLLATE utf8_general_ci) DESC,
(i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
(i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
+ (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
(i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
(i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
(i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
@@ -59343,6 +59831,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemRefreshTags` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59350,8 +59840,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemRefreshTags`(IN vItem INT)
BEGIN
@@ -59365,7 +59853,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.item
SELECT vItem id;
-
+
CALL item_refreshTags();
DROP TEMPORARY TABLE tmp.item;
@@ -59376,6 +59864,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemSale_byWeek` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59383,29 +59873,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT)
BEGIN
-
+
DECLARE vStarted DATE;
DECLARE vEnded DATETIME;
SELECT MIN(dated), util.dayEnd(MAX(dated)) INTO vStarted, vEnded
- FROM `time` t
+ FROM `time` t
WHERE CONCAT(vYear, LPAD(vWeek, 2, 0)) = t.period;
SELECT t.shipped,
w.name warehouse,
- s.ticketFk,
- c.quality,
+ s.ticketFk,
t.nickname client,
- am.name agencyName,
+ am.name agencyName,
wk.code salesPerson,
s.itemFk,
- IFNULL(CONCAT(ig.longName,' ',ig.`size`,' ',ig.subName), s.concept) AS concept,
- s.quantity,
+ IFNULL(CONCAT(ig.longName,' ',ig.`size`,' ',ig.subName), s.concept) AS concept,
+ s.quantity,
s.price,
s.priceFixed,
s.discount,
@@ -59415,15 +59902,15 @@ BEGIN
wk.id salesPersonFk
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
- JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN warehouse w ON w.id = t.warehouseFk
JOIN address a ON a.id = t.addressFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN `client` c ON c.id = a.clientFk
- LEFT JOIN worker wk ON wk.id = c.salesPersonFk
+ LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN ticketLastState tls ON tls.ticketFk = t.id
- LEFT JOIN saleBuy sb ON sb.saleFk = s.id
- LEFT JOIN buy b ON b.id = sb.buyFk
- LEFT JOIN item ig ON ig.id = b.itemOriginalFk
+ LEFT JOIN saleBuy sb ON sb.saleFk = s.id
+ LEFT JOIN buy b ON b.id = sb.buyFk
+ LEFT JOIN item ig ON ig.id = b.itemOriginalFk
WHERE s.itemFk = vItemFk
AND t.shipped BETWEEN vStarted AND vEnded
AND IF(vWarehouseFk = 0, w.hasComission , t.warehouseFk = vWarehouseFk)
@@ -59435,6 +59922,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemSaveMin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59442,17 +59931,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSaveMin`(min INT,vBarcode VARCHAR(22))
BEGIN
DECLARE vItemFk INT;
SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
-
+
UPDATE vn.item SET minimum = min WHERE id = vItemFk;
-
+
END ;;
@@ -59461,6 +59948,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemSearchShelving` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59468,14 +59957,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3))
BEGIN
SELECT p.`column` AS col , p.`row`
- FROM vn.shelving s
- JOIN parking p ON s.parkingFk = p.id
+ FROM vn.shelving s
+ JOIN parking p ON s.parkingFk = p.id
WHERE s.`code` = vShelvingFk COLLATE utf8_general_ci;
END ;;
DELIMITER ;
@@ -59483,6 +59970,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59490,8 +59979,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingDelete`(vId INT)
BEGIN
@@ -59504,6 +59991,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingLog_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59511,47 +60000,47 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) )
BEGIN
-
+
/**
* Devuelve el log de los item en cada carro
*
- * @param vShelvingFk Matrícula del carro
- *
+ * @param vShelvingFk Matrícula del carro
+ *
*/
-
- SELECT isl.itemShelvingFk,
- isl.created,
- isl.accion,
- isl.itemFk,
- isl.shelvingFk,
- isl.quantity,
+
+ SELECT isl.itemShelvingFk,
+ isl.created,
+ isl.accion,
+ isl.itemFk,
+ isl.shelvingFk,
+ isl.quantity,
isl.visible,
- isl.available,
- isl.grouping,
- isl.packing,
- isl.stars,
- item.longName,
- item.size,
- item.subName,
- worker.code,
+ isl.available,
+ isl.grouping,
+ isl.packing,
+ isl.stars,
+ item.longName,
+ item.size,
+ item.subName,
+ worker.code,
isl.accion
- FROM item
- JOIN itemShelvingLog isl ON item.id = isl.itemFk
+ FROM item
+ JOIN itemShelvingLog isl ON item.id = isl.itemFk
JOIN worker ON isl.workerFk = worker.id
WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk
ORDER BY isl.created DESC;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMakeFromDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59559,12 +60048,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
-
+
DECLARE vItemFk INT;
SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
@@ -59583,9 +60070,9 @@ BEGIN
END IF;
- IF (SELECT COUNT(*) FROM vn.itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
- AND itemFk = vItemFk
+ IF (SELECT COUNT(*) FROM vn.itemShelving
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE vn.itemShelving
@@ -59615,14 +60102,16 @@ BEGIN
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
- END IF;
-
+ END IF;
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMatch` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59630,16 +60119,14 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME)
BEGIN
DECLARE vTravelFk INT;
-
- SELECT travelFk INTO vTravelFk
- FROM entry
+
+ SELECT travelFk INTO vTravelFk
+ FROM entry
WHERE id = vEntryFk;
SELECT i.id, i.longName, i.size, i.subName, b.stickers, ish.etiquetas, b.printed
@@ -59652,7 +60139,7 @@ BEGIN
GROUP BY itemFk
) b ON b.itemFk = i.id
LEFT JOIN (
- SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
+ SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
LEFT JOIN parking pk ON pk.id = sh.parkingFk
@@ -59667,6 +60154,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingPlacementSupplyAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59674,8 +60163,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT)
BEGIN
@@ -59692,7 +60179,7 @@ BEGIN
UPDATE vn.itemShelving
SET visible = visible - vQuantity
WHERE id = vItemShelvingFk;
-
+
END ;;
DELIMITER ;
@@ -59700,6 +60187,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingProblem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59707,61 +60196,61 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingProblem`(vSectorFk INT)
BEGIN
DECLARE vVisibleCache INT;
DECLARE vWarehouseFk INT;
-
+
SELECT warehouseFk INTO vWarehouseFk
FROM vn.sector
WHERE id = vSectorFk;
CALL cache.visible_refresh (vVisibleCache, FALSE, vWarehouseFk);
-
- SELECT t.id as ticketFk,
- CAST(s.quantity AS DECIMAL(10,0)) as Cantidad,
- s.itemFk,
- s.concept,
- v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho,
+
+ SELECT t.id as ticketFk,
+ CAST(s.quantity AS DECIMAL(10,0)) as Cantidad,
+ s.itemFk,
+ s.concept,
+ v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho,
i.subName,
- GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo,
+ GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo,
s.id as saleFk,
IFNULL(sub3.transit,0) transit,
v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, mm.Id_Movimiento
- FROM vn.ticket t
+ FROM vn.ticket t
JOIN vn.ticketState tst ON tst.ticketFk = t.id
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN cache.visible v ON s.itemFk = v.item_id AND v.calc_id = vVisibleCache
LEFT JOIN vn2008.Movimientos_mark mm ON mm.Id_Movimiento = s.id AND mm.stateFk = 26
- JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id
+ JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id
LEFT JOIN
- (SELECT itemFk, sum(saldo) as transit
- FROM vn.itemPlacementSupplyList
- WHERE saldo > 0
+ (SELECT itemFk, sum(saldo) as transit
+ FROM vn.itemPlacementSupplyList
+ WHERE saldo > 0
AND sectorFk = vSectorFk
GROUP BY itemFk) sub3 ON sub3.itemFk = i.id
- WHERE v.visible + IFNULL(sub3.transit,0) - GREATEST(0,iss.visible) < s.quantity
+ WHERE v.visible + IFNULL(sub3.transit,0) - GREATEST(0,iss.visible) < s.quantity
AND IFNULL(sub3.transit,0) < s.quantity
- AND s.isPicked = FALSE
+ AND s.isPicked = FALSE
AND s.reserved = FALSE
- AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE())
+ AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE())
AND tst.isPreviousPreparable = TRUE
AND t.warehouseFk = vWarehouseFk
AND iss.sectorFk = vSectorFk
AND mm.Id_Movimiento IS NULL
ORDER BY itemFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59769,12 +60258,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar`(vSectorFk INT)
proc:BEGIN
-
+
DECLARE vCalcVisibleFk INT;
DECLARE vCalcAvailableFk INT;
DECLARE hasFatherSector BOOLEAN;
@@ -59782,17 +60269,17 @@ proc:BEGIN
DECLARE vWarehouseFk INT DEFAULT 0;
DECLARE vSonSectorFk INT;
DECLARE vWorkerFk INT;
-
- SELECT s.workerFk
- INTO vWorkerFk
+
+ SELECT s.workerFk
+ INTO vWorkerFk
FROM vn.sector s
WHERE s.id = vSectorFk;
SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk
- FROM vn.worker w
+ FROM vn.worker w
JOIN vn.sector s ON s.code = w.code
WHERE s.id = vSectorFk;
-
+
SELECT s.id INTO vSectorFk
FROM vn.sector s
WHERE s.warehouseFk = vWarehouseFk
@@ -59802,21 +60289,21 @@ proc:BEGIN
SELECT COUNT(*) INTO hasFatherSector
FROM vn.sector
WHERE sonFk = vSectorFk;
-
+
SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk
FROM vn.sector
WHERE id = vSectorFk;
-
+
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar;
-
+
IF hasFatherSector THEN
CREATE TEMPORARY TABLE tmp.itemShelvingRadar
(PRIMARY KEY (itemFk))
- ENGINE = MEMORY
+ ENGINE = MEMORY
SELECT * FROM (
SELECT iss.itemFk,
i.longName,
@@ -59827,7 +60314,7 @@ proc:BEGIN
SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs,
IF(it.isPackaging, null, IFNULL(v.visible,0)) as visible,
vSectorFk as sectorFk
-
+
FROM vn.itemShelvingStock iss
JOIN vn.sector s ON s.id = iss.sectorFk
JOIN vn.item i on i.id = iss.itemFk
@@ -59836,11 +60323,11 @@ proc:BEGIN
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
WHERE vSectorFk IN (iss.sectorFk, s.sonFk)
AND it.workerFk != 3366
-
+
GROUP BY iss.itemFk
-
+
UNION ALL
-
+
SELECT v.item_id,
i.longName,
i.size,
@@ -59850,7 +60337,7 @@ proc:BEGIN
0 downstairs,
IF(it.isPackaging, NULL, v.visible) visible,
vSectorFk as sectorFk
- FROM cache.visible v
+ FROM cache.visible v
JOIN vn.item i on i.id = v.item_id
JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk)
LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk
@@ -59859,8 +60346,8 @@ proc:BEGIN
AND iss.itemFk IS NULL
AND it.isInventory
) sub GROUP BY itemFk;
-
- SELECT ishr.*,
+
+ SELECT ishr.*,
CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho,
CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente
FROM tmp.itemShelvingRadar ishr
@@ -59875,13 +60362,13 @@ proc:BEGIN
) sub ON sub.itemFk = ishr.itemFk
ORDER BY i.typeFk, i.longName
;
-
-
+
+
ELSE
-
+
CREATE TEMPORARY TABLE tmp.itemShelvingRadar
(PRIMARY KEY (itemFk))
- ENGINE = MEMORY
+ ENGINE = MEMORY
SELECT iss.itemFk,
0 `hour`,
0 `minute`,
@@ -59893,7 +60380,7 @@ proc:BEGIN
IFNULL(a.available,0) available,
IFNULL(v.visible - iss.visible,0) dayEndVisible,
IFNULL(v.visible - iss.visible,0) firstNegative,
- IFNULL(v.visible - iss.visible,0) itemPlacementVisible,
+ IFNULL(v.visible - iss.visible,0) itemPlacementVisible,
IFNULL(i.minimum * b.packing,0) itemPlacementSize,
ips.onTheWay,
iss.visible itemShelvingStock,
@@ -59907,13 +60394,13 @@ proc:BEGIN
LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay
- FROM vn.itemPlacementSupplyList
- WHERE saldo > 0
+ FROM vn.itemPlacementSupplyList
+ WHERE saldo > 0
GROUP BY itemFk
) ips ON ips.itemFk = i.id
- WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk)
- OR iss.sectorFk = vSectorFk;
- /*
+ WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk)
+ OR iss.sectorFk = vSectorFk;
+ /*
UPDATE tmp.itemShelvingRadar isr
JOIN vn.itemShelvingStock iss ON iss.itemFk = isr.itemFk
SET isr.dayEndVisible = isr.dayEndVisible + iss.visible,
@@ -59924,10 +60411,10 @@ proc:BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime;
CREATE TEMPORARY TABLE tmp.itemOutTime
SELECT *,SUM(amount) quantity
- FROM
+ FROM
(SELECT item_id itemFk,
- amount,
- IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
+ amount,
+ IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes
FROM vn2008.item_out io
JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.item_id
@@ -59935,23 +60422,23 @@ proc:BEGIN
JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk
JOIN vn.state s ON s.id = ts.stateFk
LEFT JOIN vn.zone z ON z.id = t.zoneFk
- LEFT JOIN (SELECT DISTINCT saleFk
- FROM vn.saleTracking st
- WHERE st.created > util.VN_CURDATE()
+ LEFT JOIN (SELECT DISTINCT saleFk
+ FROM vn.saleTracking st
+ WHERE st.created > util.VN_CURDATE()
AND st.isChecked
) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
WHERE t.warehouseFk = vWarehouseFk
- AND s.isPicked = 0
- AND NOT io.Reservado
+ AND s.isPicked = 0
+ AND NOT io.Reservado
AND stPrevious.saleFk IS NULL
- AND io.dat >= util.VN_CURDATE()
+ AND io.dat >= util.VN_CURDATE()
AND io.dat < util.VN_CURDATE() + INTERVAL 1 DAY
) sub
GROUP BY itemFk, hours, minutes;
-
+
INSERT INTO tmp.itemShelvingRadar (itemFk)
SELECT itemFk FROM tmp.itemOutTime
- ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity,
+ ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity,
firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity),
`hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0),
`minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0);
@@ -59967,13 +60454,15 @@ proc:BEGIN
END IF;
DROP TEMPORARY TABLE tmp.itemShelvingRadar;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Entry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59981,8 +60470,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry`(vEntryFk INT)
BEGIN
@@ -59991,24 +60478,24 @@ BEGIN
DECLARE vCalcVisibleFk INT;
DECLARE vCalcAvailableFk INT;
DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
-
+
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1);
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
ENGINE = MEMORY
SELECT DISTINCT itemFk
- FROM vn.buy
+ FROM vn.buy
WHERE entryFk = vEntryFk;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.item2;
CREATE TEMPORARY TABLE tmp.item2
ENGINE = MEMORY
SELECT *
FROM tmp.item;
-
- SELECT i.id as itemFk,
+
+ SELECT i.id as itemFk,
i.minimum,
CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) AS DECIMAL(10,0)) as enNicho,
CAST(IFNULL(a.available,0) AS DECIMAL(10,0)) as disponible,
@@ -60028,17 +60515,19 @@ BEGIN
AND IFNULL(tst.productionOrder,0) < 5
GROUP BY s.itemFK
) ts ON ts.itemFk = i.id;
-
-
+
+
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.item2;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Entry_State_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60046,8 +60535,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry_State_beta`(vEntryFk INT)
BEGIN
@@ -60056,40 +60543,42 @@ BEGIN
DECLARE vCalcVisibleFk INT;
DECLARE vCalcAvailableFk INT;
DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
-
+
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1);
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
ENGINE = MEMORY
SELECT DISTINCT itemFk
- FROM vn.buy
+ FROM vn.buy
WHERE entryFk = vEntryFk;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.item2;
CREATE TEMPORARY TABLE tmp.item2
ENGINE = MEMORY
SELECT *
FROM tmp.item;
-
- SELECT i.id as itemFk,
+
+ SELECT i.id as itemFk,
CAST(IFNULL(iss.visible,0) - IFNULL(v.visible,0) AS DECIMAL(10,0)) as outShelving
FROM vn.item i
JOIN tmp.item ti ON ti.itemFk = i.id
LEFT JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = i.id
LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id;
-
-
+
+
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.item2;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60097,17 +60586,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT)
BEGIN
/**
* Añade línea a itemShelvingSale y regulariza el carro
- *
+ *
* @param vItemShelvingFk Id itemShelving
* @param vSaleFk Id de sale
- * @param vQuantity cantidad a regularizar
+ * @param vQuantity cantidad a regularizar
*/
INSERT INTO itemShelvingSale(itemShelvingFk,
saleFk,
@@ -60132,6 +60619,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingTransfer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60139,8 +60628,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingTransfer`(vItemShelvingFk INT, vShelvingFk VARCHAR(3))
BEGIN
@@ -60190,6 +60677,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60197,12 +60686,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
-
+
/**
* Añade registro o lo actualiza si ya existe.
@@ -60214,7 +60701,7 @@ BEGIN
* @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra
* @param vPacking el packing del producto, NULL para coger el de la ultima compra
* @param vWarehouseFk indica el sector
- *
+ *
**/
DECLARE vItemFk INT;
@@ -60224,21 +60711,21 @@ BEGIN
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO parking(code) VALUES(vShelvingFk);
- INSERT INTO shelving(code, parkingFk)
+ INSERT INTO shelving(code, parkingFk)
SELECT vShelvingFk, id
- FROM parking
+ FROM parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
- IF (SELECT COUNT(*) FROM itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
- AND itemFk = vItemFk
+ IF (SELECT COUNT(*) FROM itemShelving
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE itemShelving
SET visible = visible+vQuantity
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE
CALL cache.last_buy_refresh(FALSE);
@@ -60266,6 +60753,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_addByClaim` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60273,8 +60762,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
BEGIN
@@ -60309,6 +60796,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_addList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60316,8 +60805,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT)
BEGIN
@@ -60369,6 +60856,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_BuyerGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60376,20 +60865,20 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_BuyerGet`( )
BEGIN
SELECT * FROM vn.buyer;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_filterBuyer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60397,8 +60886,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT)
proc:BEGIN
@@ -60410,10 +60897,10 @@ proc:BEGIN
* @return Lista de articulos
*/
DECLARE vCalcVisibleFk INT;
-
+
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
- SELECT * FROM
+ SELECT * FROM
(SELECT sub.itemFk,
sub.longName,
CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
@@ -60430,28 +60917,28 @@ proc:BEGIN
0 upstairs,
SUM(IFNULL(iss.visible,0)) downstairs,
IF(it.isPackaging, null, IFNULL(v.visible, 0)) visible,
- ik.name
+ ik.name
FROM itemShelvingStock iss
JOIN sector s ON s.id = iss.sectorFk
JOIN item i on i.id = iss.itemFk
- LEFT JOIN ink ik ON ik.id = i.inkFk
+ LEFT JOIN ink ik ON ik.id = i.inkFk
JOIN itemType it ON it.id = i.typeFk
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
WHERE s.warehouseFk = vWarehouseFk
AND it.workerFk = vBuyerFk
- GROUP BY itemFk
+ GROUP BY itemFk
) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente
FROM sale s
LEFT JOIN saleTracking st ON st.saleFk = s.id
- JOIN ticket t ON t.id = s.ticketFk
+ JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
- ) sub2 ON sub2.itemFk = sub.itemFk
- UNION ALL
+ ) sub2 ON sub2.itemFk = sub.itemFk
+ UNION ALL
SELECT v.item_id ,
i.longName,
CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
@@ -60469,7 +60956,7 @@ proc:BEGIN
LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente
FROM sale s
LEFT JOIN saleTracking st ON st.saleFk = s.id
- JOIN ticket t ON t.id = s.ticketFk
+ JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
@@ -60489,6 +60976,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60496,18 +60985,16 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_get`(IN vSelf VARCHAR(8))
BEGIN
/**
-* Lista artículos de itemshelving
+* Lista artículos de itemshelving
*
* @param vSelf matrícula del carro
**/
- SELECT ish.itemFk item,
- IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
+ SELECT ish.itemFk item,
+ IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
ish.visible,
CEIL(ish.visible/ish.packing) stickers,
ish.packing,
@@ -60527,15 +61014,15 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getAlternatives` */;
/*!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 = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10))
BEGIN
@@ -60545,15 +61032,14 @@ BEGIN
*
* @param vShelvingFk matricula del carro
*/
- SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
+ SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2
JOIN shelving sh ON sh.code = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
- LEFT JOIN operator o ON o.sectorFk = s.id
- LEFT JOIN worker w ON w.sectorFk = s.id AND w.id = account.myUser_getId()
+ LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk
- JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
+ JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci
GROUP BY is2.id
ORDER BY p.pickingOrder DESC;
@@ -60563,6 +61049,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60570,8 +61058,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22))
BEGIN
@@ -60600,6 +61086,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getSaleDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60607,40 +61095,38 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
BEGIN
-
+
/* Devuelve la minima fecha en que se necesita cada producto en esa matricula.
- *
+ *
* @param vShelvingFk Matrícula del carro o pallet
*/
-
+
DECLARE vWarehouseFk INT;
SELECT warehouseFk INTO vWarehouseFk
FROM shelving s
- JOIN parking p ON s.parkingFk = p.id
+ JOIN parking p ON s.parkingFk = p.id
JOIN sector st ON st.id = p.sectorFk
WHERE s.code = vShelvingFk COLLATE utf8_unicode_ci;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingDistinct;
CREATE TEMPORARY TABLE tmp.itemShelvingDistinct
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk, SUM(visible) visible
- FROM vn.itemShelving
+ FROM vn.itemShelving
WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
- GROUP BY itemFk;
-
+ GROUP BY itemFk;
+
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT * FROM tmp.itemShelvingDistinct;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.stockByDay;
CREATE TEMPORARY TABLE tmp.stockByDay
(index (itemFk, dated))
@@ -60651,16 +61137,16 @@ BEGIN
FROM (
SELECT * FROM (
SELECT t2.* FROM (
- SELECT item_id itemFk, amount, util.VN_CURDATE() dated
- FROM cache.stock
+ SELECT item_id itemFk, amount, util.VN_CURDATE() dated
+ FROM cache.stock
WHERE warehouse_id = vWarehouseFk
UNION ALL
SELECT ish.itemFk, - sum(visible), util.VN_CURDATE()
- FROM vn.itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
- JOIN parking p ON sh.parkingFk = p.id
+ FROM vn.itemShelving ish
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON sh.parkingFk = p.id
JOIN sector s ON s.id = p.sectorFk
- WHERE s.isReserve
+ WHERE s.isReserve
GROUP BY ish.itemFk
UNION ALL
SELECT item_id, sum(iei.amount), dat
@@ -60669,9 +61155,9 @@ BEGIN
AND warehouse_id = vWarehouseFk
AND isVirtualStock = FALSE
GROUP BY item_id, dat
- UNION ALL
+ UNION ALL
SELECT item_id, sum(ieo.amount), dat
- FROM vn2008.item_entry_out ieo
+ FROM vn2008.item_entry_out ieo
WHERE dat >= util.VN_CURDATE()
AND warehouse_id = vWarehouseFk
GROUP BY item_id, dat
@@ -60682,11 +61168,11 @@ BEGIN
WHERE io.dat >= util.VN_CURDATE()
AND io.warehouse_id = vWarehouseFk
GROUP BY io.item_id, io.dat
- ) t2
+ ) t2
JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = t2.itemFk) t
order by t.itemFk, DATE(t.dated), t.amount DESC) t3;
-
- SELECT sbd.itemFk, i.longName, DATE(dated) dated, ish.visible amount, sbd.stock
+
+ SELECT sbd.itemFk, i.longName, DATE(dated) dated, ish.visible amount, sbd.stock
FROM tmp.stockByDay sbd
JOIN vn.item i ON i.id = sbd.itemFk
JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = sbd.itemFk
@@ -60703,6 +61189,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_inventory` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60710,56 +61198,74 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8))
BEGIN
-
- /**
- * Devuelve un listado de ubicaciones a revisar
- *
- * @param vParkingFromFk Parking de partida, identificador de vn.parking
- * @param vParkingToFk Parking de llegada, identificador de vn.parking
- */
-
+/**
+ * Devuelve un listado de ubicaciones a revisar
+ *
+ * @param vParkingFromFk Parking de partida, identificador de parking
+ * @param vParkingToFk Parking de llegada, identificador de parking
+ */
DECLARE vSectorFk INT;
DECLARE vPickingOrderFrom INT;
DECLARE vPickingOrderTo INT;
SELECT p.sectorFk, p.pickingOrder INTO vSectorFk, vPickingOrderFrom
- FROM vn.parking p
- WHERE p.id = vParkingFromFk;
+ FROM parking p
+ WHERE p.code = vParkingFromFk COLLATE 'utf8mb3_general_ci';
SELECT p.pickingOrder INTO vPickingOrderTo
- FROM vn.parking p
- WHERE p.id = vParkingToFk;
+ FROM parking p
+ WHERE p.code = vParkingToFk COLLATE 'utf8mb3_general_ci';
- CALL vn.visible_getMisfit(vSectorFk);
+ CALL visible_getMisfit(vSectorFk);
- SELECT p.code parking ,
- ish.shelvingFk ,
+ SELECT ish.id,
+ p.pickingOrder,
+ p.code parking,
+ ish.shelvingFk,
ish.itemFk,
i.longName,
- ish.visible ,
- ish.visible / ish.packing packs,
- ish.packing,
- sm.visible - sm.parked faltan
- FROM vn.itemShelving ish
- JOIN vn.item i ON i.id = ish.itemFk
+ ish.visible,
+ p.sectorFk,
+ it.workerFk buyer,
+ CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage,
+ ish.isChecked,
+ CASE
+ WHEN s.notPrepared > sm.parked THEN 0
+ WHEN sm.visible > sm.parked THEN 1
+ ELSE 2
+ END priority
+ FROM itemShelving ish
+ JOIN item i ON i.id = ish.itemFk
+ JOIN itemType it ON it.id = i.typeFk
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ JOIN (
+ SELECT s.itemFk, sum(s.quantity) notPrepared
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN config c ON c.mainWarehouseFk = w.id
+ WHERE t.shipped BETWEEN util.VN_CURDATE()
+ AND util.dayEnd(util.VN_CURDATE())
+ AND s.isPicked = FALSE
+ GROUP BY s.itemFk
+ ) s ON s.itemFk = i.id
+ JOIN hedera.imageConfig ic
WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo
AND p.sectorFk = vSectorFk
- ORDER BY p.pickingOrder ;
-
+ ORDER BY p.pickingOrder;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_selfConsumption` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60767,19 +61273,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_selfConsumption`(
- vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
- vItemFk INT,
+ vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
+ vItemFk INT,
vQuantity INT
)
-BEGIN
+BEGIN
/**
- * Leave the indicated amount on the shelf
+ * Leave the indicated amount on the shelf
* and create a ticket with the difference.
- *
+ *
* @param vShelvingFk id of the shelf where the item is located.
* @param vItemFk article of which the self-consumption ticket is to be created.
* @param vQuantity amount that will stay on the shelf
@@ -60823,10 +61327,10 @@ BEGIN
END IF;
SELECT SUM(visible), id INTO vVisible, vItemShelvingFk
- FROM itemShelving
+ FROM itemShelving
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;
-
+
IF vVisible IS NULL THEN
CALL util.throw('The item is not on the shelf.');
END IF;
@@ -60858,6 +61362,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60865,8 +61371,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT )
BEGIN
@@ -60879,9 +61383,9 @@ BEGIN
* @param vGrouping el grouping del producto en itemShelving
*/
UPDATE itemShelving
- SET visible = vVisible,
- packing = vPacking,
- grouping = vGrouping
+ SET visible = vVisible,
+ packing = vPacking,
+ grouping = vGrouping
WHERE id = vShelf;
END ;;
@@ -60890,75 +61394,8 @@ 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 `itemStock` */;
-/*!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_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStock`(vWarehouseFk SMALLINT, vDated DATETIME, vItemFk INT)
-BEGIN
-/**
- * Calcula el stock del vWarehouseFk desde FechaInventario hasta vDated
- * @param vWarehouse warehouse id
- * @param vDated max date to filter
- * @param vItemFk item id
- **/
-
-
- DECLARE vIsLogifloraDay BOOLEAN;
-
- SET vDated = TIMESTAMP(DATE(vDated), '00:00:00');
-
- SELECT vn.isLogifloraDay(vDated, vWarehouseFk) INTO vIsLogifloraDay ;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
- CREATE TEMPORARY TABLE tmp.itemList
- (UNIQUE INDEX i USING HASH (itemFk))
- ENGINE = MEMORY
- SELECT itemFk, SUM(quantity) stock, SUM(quantity) visible, SUM(quantity) available FROM (
- SELECT itemFk, quantity
- FROM itemTicketOut
- WHERE shipped >= util.VN_CURDATE() AND shipped < vDated
- AND warehouseFk = vWarehouseFk
- AND (vItemFk IS NULL OR itemFk = vItemFk)
- UNION ALL
- SELECT itemFk, quantity
- FROM itemEntryIn i
- LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk
- WHERE i.landed >= util.VN_CURDATE() AND i.landed < vDated
- AND i.warehouseInFk = vWarehouseFk
- AND (vItemFk IS NULL OR i.itemFk = vItemFk)
- AND (ISNULL(wf.entryFk) OR vIsLogifloraDay)
- UNION ALL
- SELECT itemFk, quantity
- FROM itemEntryOut
- WHERE shipped >= util.VN_CURDATE() AND shipped < vDated
- AND warehouseOutFk = vWarehouseFk
- AND (vItemFk IS NULL OR itemFk = vItemFk)
- ) t
- GROUP BY itemFk HAVING stock != 0;
-
- CALL `cache`.stock_refresh (FALSE);
-
- INSERT INTO tmp.itemList (itemFk,stock,visible,available)
- SELECT item_id,amount,amount,amount
- FROM `cache`.stock
- WHERE warehouse_id = vWarehouseFk AND (vItemFk IS NULL OR vItemFk = item_id)
- ON DUPLICATE KEY UPDATE
- stock = stock + VALUES(stock),
- visible = visible + VALUES(visible),
- available = available + VALUES(available);
-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 `itemTagMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60966,13 +61403,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagMake`(vItemFk INT)
BEGIN
-/* * Crea los tags usando la tabla plantilla itemTag
+/* * Crea los tags usando la tabla plantilla itemTag
* y si no existe a partir de la ficha del artículo.
* @param vItemFk El item al que se le añaden los tags
*/
@@ -60982,33 +61417,33 @@ BEGIN
DECLARE vProducer VARCHAR(50);
DECLARE vOrigin VARCHAR(20);
DECLARE vTypeFk INTEGER;
-
- DELETE FROM itemTag
+
+ DELETE FROM itemTag
WHERE itemFk = vItemFk;
-
- SELECT typeFk INTO vTypeFk
+
+ SELECT typeFk INTO vTypeFk
FROM item
WHERE id = vItemFk;
-
+
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT vItemFk, itt.tagFk, NULL, itt.priority
FROM itemTag it
LEFT JOIN itemTypeTag itt ON itt.itemTypeFk = vTypeFk
WHERE it.itemFk = vItemFk;
-
+
IF (SELECT COUNT(*) FROM itemTag WHERE itemFk = vItemFk LIMIT 1) = 0 THEN
- SELECT ik.name, i.size, i.category, p.name, o.name
+ SELECT ik.name, i.size, i.category, p.name, o.name
INTO vInk, vSize, vCategory, vProducer, vOrigin
FROM item i
LEFT JOIN ink ik ON ik.id = i.inkFk
LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
LEFT JOIN origin o ON o.id = i.originFk
WHERE i.id = vItemFk;
-
+
INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority)
VALUES(vItemFk, 1, vInk, 1);
-
+
INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority)
VALUES (vItemFk, 8, vSize, 2);
@@ -61017,17 +61452,19 @@ BEGIN
INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority)
VALUES(vItemFk, 37, vProducer, 4);
-
+
INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority)
VALUES(vItemFk, 35, vOrigin, 5);
END IF;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTagReorder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61035,19 +61472,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorder`(itemTypeFk INT)
BEGIN
SET @isTriggerDisabled = TRUE;
-
+
-- No se puede usar temporary porque da error Error Code: 1137. No puedo reabrir tabla: 'i
DROP TABLE IF EXISTS tmp.item;
CREATE TABLE tmp.item
SELECT DISTINCT i.id
- FROM vn.item i
+ FROM vn.item i
WHERE i.typeFk = itemTypeFk;
UPDATE itemTag it
@@ -61056,8 +61491,8 @@ BEGIN
JOIN itemTypeTag itt ON itt.itemTypeFk = item.typeFk AND itt.tagFk = it.tagFk
SET it.priority = itt.priority
WHERE itt.itemTypeFk = itemTypeFk;
-
- CALL item_refreshTags();
+
+ CALL item_refreshTags();
SET @isTriggerDisabled = FALSE;
@@ -61068,6 +61503,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTagReorderByName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61075,19 +61512,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorderByName`(vName VARCHAR(255))
BEGIN
SET @isTriggerDisabled = TRUE;
-
+
-- No se puede usar temporary porque da error Error Code: 1137. No puedo reabrir tabla: 'i
DROP TABLE IF EXISTS tmp.item;
CREATE TABLE tmp.item
SELECT DISTINCT i.id
- FROM vn.item i
+ FROM vn.item i
WHERE i.`name` LIKE CONCAT(vName,'%');
UPDATE itemTag it
@@ -61096,8 +61531,8 @@ BEGIN
JOIN itemTypeTag itt ON itt.itemTypeFk = item.typeFk AND itt.tagFk = it.tagFk
SET it.priority = itt.priority
WHERE itt.itemTypeFk = itemTypeFk;
-
- CALL item_refreshTags();
+
+ CALL item_refreshTags();
SET @isTriggerDisabled = FALSE;
@@ -61108,6 +61543,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTag_replace` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61115,47 +61552,47 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100))
BEGIN
-
+
/* Reemplaza los tags de un artículo por los de otro, así como su imagen
- *
+ *
* @param vItemFromFk id de vn.item con el artículo del que se toman los tags
* @param vItemToFk id de vn.item con el artículo del que se toman los tags
* @param vPicture imagen del artículo. Opcional. Si no se especifica, hereada la del vItemFromFk
*/
- DELETE FROM vn.itemTag
+ DELETE FROM vn.itemTag
WHERE itemFk = vItemToFk;
-
+
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT vItemToFk, tagFk, value, priority
- FROM vn.itemTag
+ FROM vn.itemTag
WHERE itemFk = vItemFromFk;
-
+
IF ISNULL(vPicture) THEN
-
- SELECT image INTO vPicture
- FROM vn.item
+
+ SELECT image INTO vPicture
+ FROM vn.item
WHERE id = vItemFromFk;
-
+
END IF;
- UPDATE vn.item i
+ UPDATE vn.item i
SET i.image = vPicture
WHERE i.id = vItemToFk;
-
+
CALL vn.itemRefreshTags(vItemToFk);
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTopSeller` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61163,8 +61600,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTopSeller`()
BEGIN
@@ -61174,9 +61609,9 @@ BEGIN
SELECT DISTINCT id
FROM vn.itemCategory
WHERE merchandise <> FALSE;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
RESIGNAL;
END;
@@ -61187,51 +61622,53 @@ BEGIN
INNER JOIN bs.ventas v ON v.Id_Movimiento = s.id
WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, util.VN_CURDATE()) AND util.VN_CURDATE()
GROUP BY s.itemFk;
-
+
DROP TABLE IF EXISTS tmp.topSeller;
- CREATE TEMPORARY TABLE tmp.topSeller
- (
+ CREATE TEMPORARY TABLE tmp.topSeller
+ (
`id` int(11) NOT NULL DEFAULT '0',
`typeFk` smallint(5) unsigned NOT NULL,
`itemCategoryFk` int(10) unsigned NOT NULL,
`total` bigint(21) NOT NULL DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
+
OPEN rs;
read_loop: LOOP
FETCH rs INTO vCategoryFk;
-
+
IF vDone THEN
LEAVE read_loop;
END IF;
-
+
INSERT INTO tmp.topSeller
SELECT tsm.itemFk, tsm.typeFk, it.categoryFk, tsm.total
FROM tmp.topSellerMin tsm
INNER JOIN vn.itemType it ON it.id = tsm.typeFk
WHERE it.categoryFk = vCategoryFk
ORDER BY tsm.itemFk ,tsm.total DESC
- LIMIT 5;
+ LIMIT 5;
END LOOP;
CLOSE rs;
-
+
SELECT i.name ,i.id, i.image, i.typeFk, it.categoryFk AS itemCategoryFk,
ic.name AS itemCategoryName, it.name AS itemTypeName, ts.total
FROM tmp.topSeller ts
INNER JOIN vn.item i ON i.id = ts.id
INNER JOIN vn.itemType it ON it.id = ts.typeFk
INNER JOIN vn.itemCategory ic ON ic.id = it.categoryFk;
-
+
DROP TABLE IF EXISTS topSellerMin;
DROP TABLE IF EXISTS tmp.topSeller;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTrash` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61239,8 +61676,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`(
vItemFk INT,
@@ -61286,7 +61721,7 @@ BEGIN
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
SELECT vTicketFk,
vItemFk,
- CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
+ CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
vQuantity
FROM item
WHERE id = vItemFk;
@@ -61301,6 +61736,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemUpdateTag` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61308,8 +61745,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemUpdateTag`(IN vItem BIGINT)
BEGIN
@@ -61335,7 +61770,7 @@ SET tag6 = t.name, value6 = it.value
WHERE it.priority = 2
AND (vItem IS NULL OR vItem = it.itemFk);
-UPDATE item i
+UPDATE item i
JOIN itemTag it ON it.itemFk = i.id
JOIN tag t ON t.id = it.tagFk
SET tag7 = t.name, value7 = it.value
@@ -61355,6 +61790,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_cleanFloramondo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61362,13 +61799,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_cleanFloramondo`()
BEGIN
/**
-* Elimina todos los items repetidos de floramondo
+* Elimina todos los items repetidos de floramondo
* y los sustituye por el que tiene menor id
*/
DECLARE vItemFrom INT;
@@ -61434,7 +61869,7 @@ BEGIN
AND i2.EmbalageCode <=> i.EmbalageCode
AND i2.quality <=> i.quality
JOIN (
- SELECT DISTINCT b.itemFk
+ SELECT DISTINCT b.itemFk
FROM buy b
JOIN item i ON i.id = b.itemFk
WHERE i.isFloramondo
@@ -61442,7 +61877,7 @@ BEGIN
)sub2 ON sub2.itemFk = GREATEST(i.id, i2.id)
WHERE i.isFloramondo
AND i.id <> i2.id;
-
+
DECLARE EXIT HANDLER FOR SQLEXCEPTION SET vDone = TRUE;
BEGIN
SET vDone = TRUE;
@@ -61545,6 +61980,14 @@ BEGIN
SET itemFk = vItemNew
WHERE itemFk = vItemOld;
+ # Mantenemos la imagen si el nuevo no tiene
+ UPDATE vn.item itemNew
+ LEFT JOIN item itemOld ON itemOld.id = vItemOld
+ AND itemOld.image IS NOT NULL
+ SET itemNew.image = itemOld.image
+ WHERE itemNew.id = vItemNew
+ AND itemNew.image IS NULL;
+
# Eliminamos el item sustituido
DELETE FROM item
WHERE id = vItemOld;
@@ -61563,6 +62006,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_deactivateUnused` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61570,8 +62015,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_deactivateUnused`()
BEGIN
@@ -61607,6 +62050,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getAtp` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61614,8 +62059,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getAtp`(vDated DATE)
BEGIN
@@ -61669,6 +62112,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61676,8 +62121,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(
vItemFk INT,
@@ -61688,14 +62131,13 @@ BEGIN
/**
* @vItemFk item a buscar
* @vWarehouseFk almacen donde buscar
- * @vDate Si la fecha es null, muestra el histórico desde el inventario.
+ * @vDate Si la fecha es null, muestra el histórico desde el inventario.
* Si la fecha no es null, muestra histórico desde la fecha pasada.
*/
DECLARE vDateInventory DATETIME;
- DECLARE vInvCalculated INT;
IF vDate IS NULL THEN
- SELECT inventoried INTO vDateInventory
+ SELECT inventoried INTO vDateInventory
FROM config;
ELSE
SELECT mockUtcTime INTO vDateInventory
@@ -61721,7 +62163,7 @@ BEGIN
inventorySupplierFk INT(10)
);
- INSERT INTO tItemDiary
+ INSERT INTO tItemDiary
SELECT tr.landed shipped,
b.quantity `in`,
NULL `out`,
@@ -61742,14 +62184,14 @@ BEGIN
JOIN entry e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
JOIN supplier s ON s.id = e.supplierFk
- JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
+ JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
OR (util.VN_CURDATE() AND tr.isReceived),
- 'DELIVERED',
+ 'DELIVERED',
'FREE')
JOIN entryConfig ec
WHERE tr.landed >= vDateInventory
AND vWarehouseFk = tr.warehouseInFk
- AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
+ AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
AND b.itemFk = vItemFk
AND e.isExcludedFromAvailable = FALSE
AND e.isRaid = FALSE
@@ -61775,14 +62217,14 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
JOIN warehouse w ON w.id = tr.warehouseOutFk
JOIN supplier s ON s.id = e.supplierFk
- JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
+ JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
- 'DELIVERED',
+ 'DELIVERED',
'FREE')
JOIN entryConfig ec
WHERE tr.shipped >= vDateInventory
AND vWarehouseFk = tr.warehouseOutFk
- AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
+ AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
AND b.itemFk = vItemFk
AND e.isExcludedFromAvailable = FALSE
AND w.isFeedStock = FALSE
@@ -61811,12 +62253,12 @@ BEGIN
JOIN client c ON c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
- 'DELIVERED',
+ 'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
'FREE',
IFNULL(ts.code, 'FREE')))
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
- LEFT JOIN saleTracking stk ON stk.saleFk = s.id
+ LEFT JOIN saleTracking stk ON stk.saleFk = s.id
AND stk.stateFk = stPrep.id
LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
WHERE t.shipped >= vDateInventory
@@ -61832,7 +62274,7 @@ BEGIN
`out` DESC;
IF vDate IS NULL THEN
-
+
SET @a := 0;
SET @currentLineFk := 0;
SET @shipped := '';
@@ -61847,9 +62289,9 @@ BEGIN
`in` invalue,
`out`,
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0) balance,
- @currentLineFk := IF (@shipped < util.VN_CURDATE()
+ @currentLineFk := IF (@shipped < util.VN_CURDATE()
OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.`code` >= 'ON_PREPARATION')),
- lineFk,
+ lineFk,
@currentLineFk) lastPreparedLineFk,
isTicket,
lineFk,
@@ -61860,7 +62302,7 @@ BEGIN
LEFT JOIN alertLevel a ON a.id = tItemDiary.alertLevel;
ELSE
- SELECT SUM(`in`) - SUM(`out`) INTO vInvCalculated
+ SELECT SUM(`in`) - SUM(`out`) INTO @a
FROM tItemDiary
WHERE shipped < vDate;
@@ -61871,9 +62313,9 @@ BEGIN
'' reference,
0 clientFk,
'Inventario calculado',
- vInvCalculated invalue,
+ @a invalue,
NULL `out`,
- 0 balance,
+ @a balance,
0 lastPreparedLineFk,
0 isTicket,
0 lineFk,
@@ -61881,25 +62323,25 @@ BEGIN
0 clientType,
0 claimFk
UNION ALL
- SELECT shipped,
- alertlevel,
- stateName,
- origin,
- reference,
- clientFk,
- name, `in`,
- `out`,
- 0,
- 0,
- isTicket,
- lineFk,
- isPicked,
- clientType,
+ SELECT shipped,
+ alertlevel,
+ stateName,
+ origin,
+ reference,
+ clientFk,
+ name, `in`,
+ `out`,
+ @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
+ 0,
+ isTicket,
+ lineFk,
+ isPicked,
+ clientType,
claimFk
FROM tItemDiary
WHERE shipped >= vDate;
END IF;
-
+
DROP TEMPORARY TABLE tItemDiary;
END ;;
DELIMITER ;
@@ -61907,6 +62349,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61914,8 +62358,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT)
BEGIN
@@ -61992,6 +62434,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getLack` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61999,14 +62443,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getLack`(IN vForce BOOLEAN, IN vDays INT)
BEGIN
/**
* Calcula una tabla con el máximo negativo visible para cada producto y almacen
- *
+ *
* @param vForce Fuerza el recalculo del stock
* @param vDays Numero de dias a considerar
**/
@@ -62015,31 +62457,31 @@ BEGIN
CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL);
CALL item_getMinETD();
- SELECT i.id itemFk,
+ SELECT i.id itemFk,
i.longName,
w.id warehouseFk,
- p.`name` producer,
+ p.`name` producer,
i.`size`,
i.category,
- w.name warehouse,
+ w.name warehouse,
SUM(IFNULL(sub.amount,0)) lack,
i.inkFk,
- IFNULL(im.timed, util.midnight()) timed
- FROM (SELECT item_id,
- warehouse_id,
+ IFNULL(im.timed, util.midnight()) timed
+ FROM (SELECT item_id,
+ warehouse_id,
amount
FROM cache.stock
WHERE amount > 0
UNION ALL
- SELECT itemFk,
- warehouseFk,
+ SELECT itemFk,
+ warehouseFk,
amount
FROM tmp.itemMinacum
) sub
JOIN warehouse w ON w.id = sub.warehouse_id
JOIN item i ON i.id = sub.item_id
- LEFT JOIN producer p ON p.id = i.producerFk
- JOIN itemType it ON it.id = i.typeFk
+ LEFT JOIN producer p ON p.id = i.producerFk
+ JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id
WHERE w.isForTicket
@@ -62056,6 +62498,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getMinacum` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62063,8 +62507,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT)
BEGIN
@@ -62148,6 +62590,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getMinETD` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62155,17 +62599,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinETD`()
BEGIN
-
+
/* Devuelve una tabla temporal con la primera ETD, para todos los artículos con salida hoy.
- *
+ *
* @return tmp.itemMinETD(itemFk, timed)
*/
-
+
DECLARE vMidnight DATETIME DEFAULT util.midnight();
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinETD;
@@ -62176,7 +62618,7 @@ BEGIN
SELECT s.itemFk, MIN(TIME(IFNULL(z.`hour`,vMidnight))) timed
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
- LEFT JOIN `zone` z ON z.id = t.zoneFk
+ LEFT JOIN `zone` z ON z.id = t.zoneFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND vMidnight
GROUP BY s.itemFk;
END ;;
@@ -62185,6 +62627,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getSimilar` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62192,8 +62636,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL)
BEGIN
@@ -62206,33 +62648,33 @@ BEGIN
* @param vWarehouseFk warehouse id
* @param vDate fecha para revisar disponible
* @param vIsShowedByType para mostrar solo artículos de ese tipo
- */
+ */
DECLARE vCalcFk INT;
DECLARE vTypeFk INT;
-
+
DECLARE vTag1 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vTag5 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vTag6 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vTag7 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vTag8 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
-
+
DECLARE vValue1 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vValue5 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vValue6 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
-
+
SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
FROM vn.item i
LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
WHERE i.id = vItemFk;
-
+
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDate);
-
+
SELECT i.id itemFk,
i.longName,
i.subName,
@@ -62265,7 +62707,7 @@ BEGIN
ORDER BY counter DESC,
(t1.name = vTag1) DESC,
(it1.value = vValue1) DESC,
- (i.tag6 = vTag6) DESC,
+ (i.tag6 = vTag6) DESC,
(i.value6 = vValue6) DESC,
(i.tag5 = vTag5) DESC,
(i.value5 = vValue5) DESC,
@@ -62274,7 +62716,7 @@ BEGIN
(i.tag8 = vTag8) DESC,
(i.value8 = vValue8) DESC
LIMIT 30;
-
+
END ;;
DELIMITER ;
@@ -62282,6 +62724,93 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `item_getStock` */;
+/*!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_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getStock`(
+ vWarehouseFk SMALLINT,
+ vDated DATE,
+ vItemFk INT
+)
+BEGIN
+/**
+ * Calcula el stock de un artículo de un vWarehouseFk,
+ * desde la fecha del inventario hasta vDated
+ *
+ * @param vWarehouse Warehouse id
+ * @param vDated Max date to filter
+ * @param vItemFk Item id
+ *
+ * @return tmp.itemList(itemFk, stock, visible, available)
+ */
+ DECLARE vIsLogifloraDay BOOL DEFAULT vn.isLogifloraDay(vDated, vWarehouseFk);
+
+ SET vDated = TIMESTAMP(vDated, '00:00:00');
+
+ CREATE OR REPLACE TEMPORARY TABLE tmp.itemList
+ (UNIQUE INDEX i USING HASH (itemFk))
+ ENGINE = MEMORY
+ SELECT itemFk,
+ SUM(quantity) stock,
+ SUM(quantity) visible,
+ SUM(quantity) available
+ FROM (
+ SELECT itemFk, quantity
+ FROM itemTicketOut
+ WHERE shipped >= util.VN_CURDATE()
+ AND shipped < vDated
+ AND warehouseFk = vWarehouseFk
+ AND (vItemFk IS NULL OR itemFk = vItemFk)
+ UNION ALL
+ SELECT iei.itemFk, iei.quantity
+ FROM itemEntryIn iei
+ LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = iei.entryFk
+ JOIN item i ON i.id = iei.itemFk
+ WHERE iei.landed >= util.VN_CURDATE()
+ AND iei.landed < vDated
+ AND iei.warehouseInFk = vWarehouseFk
+ AND (vItemFk IS NULL OR iei.itemFk = vItemFk)
+ AND (wf.entryFk IS NULL OR vIsLogifloraDay)
+ AND NOT (iei.landed > util.VN_CURDATE() AND i.isFloramondo)
+ UNION ALL
+ SELECT ieo.itemFk, ieo.quantity
+ FROM itemEntryOut ieo
+ JOIN item i ON i.id = ieo.itemFk
+ WHERE ieo.shipped >= util.VN_CURDATE()
+ AND ieo.shipped < vDated
+ AND ieo.warehouseOutFk = vWarehouseFk
+ AND (vItemFk IS NULL OR ieo.itemFk = vItemFk)
+ AND NOT (ieo.shipped > util.VN_CURDATE() AND i.isFloramondo)
+ ) sub
+ GROUP BY itemFk
+ HAVING stock;
+
+ CALL cache.stock_refresh(FALSE);
+
+ INSERT INTO tmp.itemList(itemFk, stock, visible, available)
+ SELECT item_id, amount, amount, amount
+ FROM cache.stock
+ WHERE warehouse_id = vWarehouseFk
+ AND (vItemFk IS NULL OR vItemFk = item_id)
+ ON DUPLICATE KEY UPDATE
+ stock = stock + VALUES(stock),
+ visible = visible + VALUES(visible),
+ available = available + VALUES(available);
+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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_GetVisible` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62289,8 +62818,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_GetVisible`(vWarehouse SMALLINT, vItem INT)
BEGIN
@@ -62338,6 +62865,83 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `item_refreshFromTags` */;
+/*!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_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshFromTags`(vSelf INT)
+BEGIN
+/**
+ * Updates item attributes with its corresponding tags.
+ *
+ * @param vSelf The item id
+ */
+ DECLARE vTags JSON;
+ DECLARE vValues JSON;
+ DECLARE vAbbrs JSON;
+ DECLARE vOverwrites JSON;
+
+ SELECT JSON_OBJECTAGG(`priority`, t.`name`),
+ JSON_OBJECTAGG(`priority`, it.`value`),
+ JSON_OBJECTAGG(`priority`, IFNULL(a.abbreviation, it.`value`)),
+ JSON_OBJECTAGG(`overwrite`, it.`value`)
+ INTO vTags, vValues, vAbbrs, vOverwrites
+ FROM itemTag it
+ JOIN tag t ON t.id = it.tagFk
+ LEFT JOIN tagAbbreviation a ON a.`value` = it.`value`
+ AND (a.tagFk IS NULL OR a.tagFk = t.id)
+ WHERE it.itemFk = vSelf;
+
+ UPDATE item i
+ LEFT JOIN ink k ON k.name = JSON_VALUE(vOverwrites, '$.inkFk')
+ LEFT JOIN origin o ON o.name = JSON_VALUE(vOverwrites, '$.originFk')
+ LEFT JOIN producer p ON p.name = JSON_VALUE(vOverwrites, '$.producerFk')
+ SET i.`name` = CONCAT_WS(' ',
+ JSON_VALUE(vAbbrs, '$.1'),
+ JSON_VALUE(vAbbrs, '$.2'),
+ IF(i.isFloramondo, NULL, JSON_VALUE(vAbbrs, '$.3'))
+ ),
+ i.longName = CONCAT_WS(' ',
+ JSON_VALUE(vValues, '$.1'),
+ JSON_VALUE(vValues, '$.2'),
+ JSON_VALUE(vValues, '$.3')
+ ),
+ i.subname = JSON_VALUE(vValues, '$.4'),
+ i.size = JSON_VALUE(vOverwrites, '$.size'),
+ i.stems = JSON_VALUE(vOverwrites, '$.stems'),
+ i.category = JSON_VALUE(vOverwrites, '$.category'),
+ i.tag5 = JSON_VALUE(vTags, '$.5'),
+ i.tag6 = JSON_VALUE(vTags, '$.6'),
+ i.tag7 = JSON_VALUE(vTags, '$.7'),
+ i.tag8 = JSON_VALUE(vTags, '$.8'),
+ i.tag9 = JSON_VALUE(vTags, '$.9'),
+ i.tag10 = JSON_VALUE(vTags, '$.10'),
+ i.value5 = JSON_VALUE(vValues, '$.5'),
+ i.value6 = JSON_VALUE(vValues, '$.6'),
+ i.value7 = JSON_VALUE(vValues, '$.7'),
+ i.value8 = JSON_VALUE(vValues, '$.8'),
+ i.value9 = JSON_VALUE(vValues, '$.9'),
+ i.value10 = JSON_VALUE(vValues, '$.10'),
+ i.producerFk = p.id,
+ i.inkFk = k.id,
+ i.originFk = IFNULL(o.id, i.originFk)
+ WHERE i.id = vSelf;
+
+ CALL item_setGeneric(vSelf);
+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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_refreshTags` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62345,152 +62949,41 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags`()
BEGIN
/**
- * Actualiza la tabla item, los campos "cache" de tags
+ * Update item table, tag "cache" fields
*
- * @param temporary table tmp.item(id) del articulo
- **/
+ * @param temporary table tmp.item(id) of the article
+ */
+ DECLARE vDone BOOL;
+ DECLARE vItemFk INT;
+ DECLARE vCur CURSOR FOR SELECT id FROM tmp.item;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- DECLARE done INT DEFAULT FALSE;
- DECLARE vItemFk INT;
- DECLARE cur1 CURSOR FOR SELECT id FROM tmp.item;
+ OPEN vCur;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
+ l: LOOP
+ SET vDone = FALSE;
+ FETCH vCur INTO vItemFk;
- OPEN cur1;
+ IF vDone THEN
+ LEAVE l;
+ END IF;
- read_loop: LOOP
-
- FETCH cur1 INTO vItemFk;
-
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- UPDATE item i
- LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id
- LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id
- LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id
- SET i.longName = CONCAT_WS(' ', it1.`value`, it2.`value`, IF(it3.`value` = 'A1','',it3.`value`))
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id
- LEFT JOIN tagAbbreviation ta1 ON ta1.`value` = it1.`value`
- LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id
- LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` AND ta2.tagFk IS NULL
- LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id
- LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value`
- SET i.`name` = CONCAT_WS(' ',
- IFNULL(ta1.abbreviation,it1.`value`),
- IFNULL(ta2.abbreviation,it2.`value`),
- IF(i.isFloramondo,'',IFNULL(ta3.abbreviation,it3.`value`)))
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4
- SET i.subName = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag5 = t.name, value5 = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag6 = t.name, value6 = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7
- LEFT JOIN tag t ON t.id = it.tagFk
- SET i.tag7 = t.name, i.value7 = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag8 = t.name, value8 = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag9 = t.name, value9 = it.`value`
- WHERE i.id = vItemFk;
-
- UPDATE item i
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag10 = t.name, value10 = it.`value`
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag color se modifica también el antiguo campo color
- UPDATE item i
- JOIN tag t ON t.overwrite = 'inkFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN ink ON ink.`name` = it.`value`
- SET i.inkFk = ink.id
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag origen se modifica también en la tabla item
- UPDATE item i
- JOIN tag t ON t.overwrite = 'originFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN origin o ON o.`name` = it.`value`
- SET i.originFk = o.id
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag medida se modifica también en la tabla item
- UPDATE item i
- JOIN tag t ON t.overwrite = 'size'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- SET i.size = it.`value`
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag productor se modifica también en la tabla item
- UPDATE item i
- JOIN tag t ON t.overwrite = 'producerFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN producer p ON p.`name` = it.`value`
- SET i.producerFk = p.id
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag tallos se modifica también en la tabla item
- UPDATE item i
- JOIN tag t ON t.overwrite = 'stems'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- SET i.stems = it.`value`
- WHERE i.id = vItemFk;
-
- -- Al insertar el tag categoria se modifica también en la tabla item
- UPDATE item i
- JOIN tag t ON t.overwrite = 'category'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- SET i.category = it.`value`
- WHERE i.id = vItemFk;
-
- -- Comprueba si existe un genérico y lo asigna
- CALL vn.item_setGeneric(vItemFk);
-
- END LOOP;
-
- CLOSE cur1;
+ CALL item_refreshFromTags(vItemFk);
+ END LOOP;
+ CLOSE vCur;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_saveReference` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62498,8 +62991,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150))
BEGIN
@@ -62510,11 +63001,11 @@ BEGIN
* @param vBarcode del item
* @param vReference referencia a actualizar
*/
-
+
DECLARE vItemFk INT;
SELECT barcodeToItem(vBarcode) INTO vItemFk;
-
+
UPDATE item SET comment = vReference WHERE id = vItemFk;
END ;;
@@ -62523,6 +63014,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_setGeneric` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62530,50 +63023,59 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT)
BEGIN
/**
* Asigna el código genérico a un item, salvo que sea un código de item genérico.
- *
+ *
* @param vSelf identificador de vn.item
*/
DECLARE vGenericFk INT;
SELECT itemFk INTO vGenericFk
FROM (
- SELECT itemFk, (sum(matches) = maxMatches) `match`
+ SELECT itemFk, SUM(matches) = maxMatches `match`
FROM (
- SELECT ga.id gaid,
- ga.itemFk,
- (it.value <=> ga.origin)
- + (it.value <=> ga.color)
- + (it.value <=> ga.quality)
- + (it.value <=> ga.numFlores)
- + (it.value <=> ga.category)
- + (it.value <=> ga.productor) matches,
- !ISNULL(ga.origin)
- +!ISNULL(ga.color)
- +!ISNULL(ga.quality)
- +!ISNULL(ga.numFlores)
- +!ISNULL(ga.category)
- +!ISNULL(ga.productor) maxMatches
+ SELECT ga.id gaid, ga.itemFk,
+ CASE
+ WHEN t.code = 'nflowers' THEN
+ it.value <=> ga.numFlores
+ WHEN t.code = 'origin' THEN
+ it.value <=> ga.origin
+ WHEN t.code = 'quality' THEN
+ it.value <=> ga.quality
+ WHEN t.code = 'color' THEN
+ it.value <=> ga.color
+ WHEN t.code = 'category' THEN
+ it.value <=> ga.category
+ WHEN t.code = 'producer' THEN
+ it.value <=> ga.productor
+ ELSE
+ 0
+ END matches,
+ (NOT ISNULL(ga.origin))
+ + (NOT ISNULL(ga.color))
+ + (NOT ISNULL(ga.quality))
+ + (NOT ISNULL(ga.numFlores))
+ + (NOT ISNULL(ga.category))
+ + (NOT ISNULL(ga.productor)) maxMatches
FROM vn.item i
JOIN vn.itemTag it ON it.itemFk = i.id
+ JOIN vn.tag t ON t.id = it.tagFk
JOIN vn.genericAllocation ga
ON (i.typeFk = ga.typeFk OR ga.typeFk IS NULL)
AND (i.longName = ga.longName OR ga.longName IS NULL)
AND (i.`size` = ga.`size` OR ga.`size` IS NULL)
AND i.id != ga.itemFk
WHERE i.id = vSelf
- AND NOT i.isFloramondo) sub
+ AND NOT i.isFloramondo) sub
GROUP BY gaid
- HAVING `match`) sub2;
+ HAVING `match`) sub2
+ LIMIT 1;
- UPDATE vn.item
- SET genericFk = vGenericFk
+ UPDATE vn.item
+ SET genericFk = vGenericFk
WHERE id = vSelf;
END ;;
DELIMITER ;
@@ -62581,6 +63083,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_updatePackingShelve` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62588,29 +63092,29 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingShelve`(vSelf INT, vPacking INT)
BEGIN
-
+
/**
* Actualiza el valor de item.packingShelve
- *
+ *
* @param vSelf Identificador de vn.item
* @param vPacking Cantidad de unidades de venta que caben en una bandeja
*/
-
- UPDATE vn.item i
+
+ UPDATE vn.item i
SET i.packingShelve = vPacking
WHERE i.id = vSelf;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_updatePackingType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62618,8 +63122,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1))
BEGIN
@@ -62637,6 +63139,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62644,8 +63148,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_ValuateInventory`(IN vDated DATE, IN vIsDetailed BOOLEAN)
BEGIN
@@ -62654,9 +63156,9 @@ BEGIN
DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE;
DECLARE vInventoried2 DATE;
DECLARE vDateDayEnd DATETIME;
-
+
SET vDateDayEnd = util.dayEnd(vDated);
-
+
SELECT landed INTO vInventoried
FROM travel tr
JOIN entry E ON E.travelFk = tr.id
@@ -62666,7 +63168,7 @@ BEGIN
LIMIT 1;
SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE);
-
+
IF vHasNotInventory THEN
SELECT landed INTO vInventoried2
@@ -62687,13 +63189,13 @@ BEGIN
CREATE TEMPORARY TABLE inv
(warehouseFk SMALLINT,
Id_Article BIGINT,
- cantidad INT,
+ cantidad INT,
coste DOUBLE DEFAULT 0,
total DOUBLE DEFAULT 0,
Almacen VARCHAR(20),
PRIMARY KEY (Almacen, Id_Article) USING HASH)
ENGINE = MEMORY;
-
+
IF vHasNotInventory = TRUE THEN
INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
@@ -62770,7 +63272,7 @@ BEGIN
AND it.isInventory
ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,0,1);
- END IF;
+ END IF;
-- Mercancia en transito
INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
@@ -62788,7 +63290,7 @@ BEGIN
AND t.isInventory
AND e.isConfirmed
ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity);
-
+
CALL vn.buyUltimate(NULL,vDateDayEnd);
UPDATE inv i
@@ -62803,20 +63305,20 @@ BEGIN
IF vIsDetailed THEN
SELECT inv.warehouseFk,
- i.id itemFk,
- i.longName ,
- i.size,
- inv.Cantidad,
+ i.id itemFk,
+ i.longName ,
+ i.size,
+ inv.Cantidad,
tp.name Tipo,
- ic.name Reino,
- inv.coste,
+ ic.name Reino,
+ inv.coste,
cast(inv.total as decimal(10,2)) total,
almacen
FROM inv
JOIN warehouse w on w.id = warehouseFk
JOIN item i ON i.id = inv.Id_Article
JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
+ JOIN itemCategory ic ON ic.id = tp.categoryFk
WHERE w.valuatedInventory
and inv.total > 0
order by inv.total desc;
@@ -62842,6 +63344,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ledger_doCompensation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62849,8 +63353,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10))
BEGIN
@@ -62863,37 +63365,37 @@ BEGIN
* @param vConcept descripcion
* @param vAmount cantidad que se compensa
* @param vCompany empresa
- * @param vOriginalAccount cuenta contable desde la cual se compensa
- *
- */
+ * @param vOriginalAccount cuenta contable desde la cual se compensa
+ *
+ */
DECLARE vNewBookEntry INT;
DECLARE vIsClientCompensation INT;
DECLARE vClientFk INT;
DECLARE vSupplierFk INT;
DECLARE vIsOriginalAClient BOOL;
DECLARE vPayMethodCompensation INT;
-
+
CALL ledger_next(vNewBookEntry);
SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
- SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
- FROM client
+ SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
+ FROM client
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
-
+
SET @vAmount1:= 0.0;
SET @vAmount2:= 0.0;
- INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
- VALUES ( vNewBookEntry,
- vDated,
- vOriginalAccount,
- vCompensationAccount,
- vConcept,
+ INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
+ VALUES ( vNewBookEntry,
+ vDated,
+ vOriginalAccount,
+ vCompensationAccount,
+ vConcept,
@vAmount1:= IF(
- (vIsOriginalAClient AND vAmount > 0) OR
- (NOT vIsOriginalAClient AND vAmount < 0),
- 0,
+ (vIsOriginalAClient AND vAmount > 0) OR
+ (NOT vIsOriginalAClient AND vAmount < 0),
+ 0,
ABS(vAmount)
),
@vAmount2:= IF(@vAmount1,
@@ -62902,20 +63404,20 @@ BEGIN
),
vCompanyFk
),
- ( vNewBookEntry,
- vDated,
- vCompensationAccount,
- vOriginalAccount,
- vConcept,
+ ( vNewBookEntry,
+ vDated,
+ vCompensationAccount,
+ vOriginalAccount,
+ vConcept,
@vAmount2,
@vAmount1,
vCompanyFk);
-
+
IF vIsClientCompensation THEN
IF vIsOriginalAClient THEN
SET vAmount = -vAmount;
END IF;
- INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate)
+ INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate)
VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE);
ELSE
IF NOT vIsOriginalAClient THEN
@@ -62923,7 +63425,7 @@ BEGIN
END IF;
SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation';
-
+
INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated)
VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE);
END IF;
@@ -62933,6 +63435,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ledger_next` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62940,21 +63444,21 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`(OUT vNewBookEntry INT)
BEGIN
-
+
UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1);
SET vNewBookEntry = LAST_INSERT_ID();
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `logShow` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62962,8 +63466,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `logShow`(vOriginFk INT, vEntity VARCHAR(45))
BEGIN
@@ -62974,15 +63476,15 @@ BEGIN
* @param vEntity Nombre que hace referencia a la tabla.
*/
DECLARE vTableName VARCHAR(45);
-
+
SET vTableName = CONCAT(vEntity, 'Log');
-
+
SET @qryLog := CONCAT(
'SELECT ot.id, ot.originFk, ot.userFk, u.name, ot.action, ot.creationDate, ot.description FROM ', vTableName, ' AS ot',
' INNER JOIN account.user u ON u.id = ot.userFk',
' WHERE ot.originFk = ', vOriginFk, ' ORDER BY ot.creationDate DESC'
);
-
+
PREPARE stmt FROM @qryLog;
EXECUTE stmt;
END ;;
@@ -62991,6 +63493,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `lungSize_generator` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62998,8 +63502,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `lungSize_generator`(vDate DATE)
BEGIN
@@ -63007,9 +63509,9 @@ BEGIN
SET @buildingOrder := 0;
SET @route := 0;
set @cajas := 0;
-
+
UPDATE tmp.sorter
- SET buildingOrder = @buildingOrder := IF(@route = @route := routeFk, @buildingOrder, 0) + 1
+ SET buildingOrder = @buildingOrder := IF(@route = @route := routeFk, @buildingOrder, 0) + 1
where date(created) = vDate
order by routeFk, created, weight DESC;
@@ -63027,23 +63529,23 @@ set @cajas := 0;
UPDATE tmp.sorter
SET lungGrow = IF(palletOrder = 0, -13, lungGrow);
-
+
DELETE FROM tmp.lungSize WHERE dia = vDate;
-
+
INSERT INTO tmp.lungSize(dia, hora,size)
select vDate,hora, @cajas := @cajas + cajas as size
from
(
select IF(lungGrow BETWEEN -12 AND -1, ETD,time_format(created,"%H:%i")) as hora, sum(if(lungGrow <= 0, lungGrow, 1)) as cajas, @cajas := 0
- from tmp.sorter
+ from tmp.sorter
where date(created) = vDate
group by hora
) sub;
-
+
SELECT * FROM tmp.lungSize
WHERE dia = vDate;
-
-
+
+
END ;;
@@ -63052,6 +63554,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63059,34 +63563,34 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
-
+
/**
* Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas
* @param vPlate número de matrícula
- * @param vWorkerFk id del worker
- *
-*/
- UPDATE vn.machineWorker mw
- JOIN vn.machine m ON m.id = mw.machineFk
+ * @param vWorkerFk id del worker
+ *
+*/
+ UPDATE vn.machineWorker mw
+ JOIN vn.machine m ON m.id = mw.machineFk
SET mw.outTimed = util.VN_NOW()
WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate)
AND ISNULL(mw.outTimed);
-
+
INSERT INTO machineWorker (machineFk, workerFk)
SELECT m.id, vWorkerFk
FROM machine m
- WHERE m.plate= vPlate;
+ WHERE m.plate= vPlate;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_getHistorical` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63094,33 +63598,33 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
BEGIN
/**
- * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
+ * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
* si es jefe de producción muestra el historial completo.
- *
+ *
* @param vPlate número de matrícula
- * @param vWorkerFk id del trabajador
- *
+ * @param vWorkerFk id del trabajador
+ *
*/
DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk);
- SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
+ SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
FROM machineWorker mw
JOIN machine m ON m.plate = vPlate
WHERE mw.machineFk = m.id
AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk)
- ORDER BY mw.inTimed DESC;
+ ORDER BY mw.inTimed DESC;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63128,18 +63632,16 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
-
+
/**
- * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate,
- *
+ * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate,
+ *
* @param vPlate número de matrícula
- * @param vWorkerFk id del trabajador
- *
+ * @param vWorkerFk id del trabajador
+ *
*/
DECLARE vMachineFk INT(10);
@@ -63148,30 +63650,32 @@ BEGIN
SELECT m.id INTO vMachineFk
FROM machine m
WHERE m.plate = vPlate;
-
+
SELECT maxHours INTO vMaxHours
FROM machineWorkerConfig;
- IF (SELECT COUNT(*)
+ IF (SELECT COUNT(*)
FROM machineWorker m
WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN
-
+ AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN
+
UPDATE machineWorker m
SET m.outTimed = CURRENT_TIMESTAMP()
- WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW())
+ WHERE m.workerFk = vWorkerFk
+ AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW())
AND ISNULL(m.outTimed)
AND m.machineFk = vMachineFk;
-
+
END IF;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `machine_getWorkerPlate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63179,8 +63683,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT)
BEGIN
@@ -63201,6 +63703,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `mail_insert` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63208,8 +63712,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mail_insert`(
vReceiver VARCHAR(255),
@@ -63220,12 +63722,12 @@ BEGIN
/**
* Inserta en la tabla vn.mail
*
- * @param vReceiver Receptor del correo
+ * @param vReceiver Receptor del correo
* @param vReplyTo A quién contestar el correo
* @param vSubject Título del correo
* @param vBody Cuerpo del correo
*/
-
+
DECLARE vIsRepeated BOOLEAN;
SELECT COUNT(*) INTO vIsRepeated
@@ -63252,6 +63754,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `makeNewItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63259,19 +63763,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `makeNewItem`()
BEGIN
DECLARE newItemFk INT;
-
+
SELECT getNewItemId() INTO newItemFk;
-
+
INSERT INTO item(id,name,typeFk,originFk)
SELECT newItemFk, 'Nuevo artículo', 78,39;
-
+
SELECT newItemFk;
@@ -63281,6 +63783,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `makePCSGraf` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63288,8 +63792,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `makePCSGraf`(vDated DATE)
BEGIN
@@ -63299,40 +63801,42 @@ BEGIN
DECLARE vMinute INT DEFAULT 0;
DECLARE vBoxes INT;
-
+
DROP TEMPORARY TABLE IF EXISTS vn.pcsDay;
CREATE TEMPORARY TABLE vn.pcsDay
SELECT 0 as hh, 0 as mm, 0 as boxes;
-
+
-- Creamos una tabla soporte para acumular las cajas a lo largo del dia
WHILE vHour < 24 DO
-
+
WHILE vMinute < 59 DO
-
+
SET vMinute = vMinute + 1;
-
+
INSERT INTO vn.pcsDay(hh,mm) VALUES(vHour, vMinute);
-
+
END WHILE;
-
+
SET vMinute = -1;
SET vHour = vHour + 1;
-
+
END WHILE;
-
+
-- Acumulamos
UPDATE vn.pcsDay pd
LEFT JOIN (SELECT * FROM vn.pcs_graf WHERE dia = vDated) pg USING(hh,mm)
SET pd.boxes = pd.boxes + pg.box;
-
+
SELECT * FROM vn.pcsDay;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `manaSpellersRequery` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63340,8 +63844,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER)
BEGIN
@@ -63349,7 +63851,7 @@ 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,util.VN_CURDATE());
@@ -63358,32 +63860,32 @@ BEGIN
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
+ SELECT id INTO vMana
FROM `component` WHERE code = 'mana';
-
- SELECT id INTO vAutoMana
+
+ SELECT id INTO vAutoMana
FROM `component` WHERE code = 'autoMana';
-
- SELECT id INTO vClaimMana
+
+ SELECT id INTO vClaimMana
FROM `component` WHERE code = 'manaClaim';
-
- SELECT id INTO vManaBank
+
+ SELECT id INTO vManaBank
FROM `bank` WHERE code = 'mana';
-
- SELECT id INTO vManaGreugeType
+
+ SELECT id INTO vManaGreugeType
FROM `greugeType` WHERE code = 'mana';
- SELECT max(dated) INTO vFromDated
+ SELECT max(dated) INTO vFromDated
FROM clientManaCache;
-
+
REPLACE workerMana (workerFk, amount)
- SELECT vWorkerFk, sum(mana) FROM
+ SELECT vWorkerFk, sum(mana) FROM
(
SELECT s.quantity * sc.value as mana
FROM ticket t
@@ -63404,8 +63906,8 @@ BEGIN
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 < util.VN_CURDATE()
- UNION ALL
+ AND g.shipped > vFromDated and g.shipped < util.VN_CURDATE()
+ UNION ALL
SELECT cc.mana
FROM clientManaCache cc
JOIN client c ON c.id = cc.clientFk
@@ -63418,6 +63920,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `mysqlConnectionsSorter_kill` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63425,27 +63929,25 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlConnectionsSorter_kill`()
BEGIN
/**
- * Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre
- */
-
+ * Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre
+ */
+
DECLARE vDone INT DEFAULT 0;
DECLARE vProcesId INT;
DECLARE vCursor CURSOR FOR
- SELECT p.id
+ SELECT p.id
FROM information_schema.processlist p
- WHERE USER = 'sorter'
+ WHERE USER = 'sorter'
AND TIME >= 30;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
+
OPEN vCursor;
l: LOOP
@@ -63468,6 +63970,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `mysqlPreparedCount_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63475,14 +63979,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlPreparedCount_check`()
BEGIN
DECLARE vPreparedCount INTEGER;
- SELECT VARIABLE_VALUE INTO vPreparedCount
+ SELECT VARIABLE_VALUE INTO vPreparedCount
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME LIKE '%prepared_stmt_count%';
@@ -63490,7 +63992,7 @@ BEGIN
CALL `vn`.`mail_insert`('cau@verdnatura.es',
NULL,
'Problemas BBDD prepared_stmt_count',
- CONCAT('Existen problemas con el servicio de Logiflora, prepared_stmt_count con valor: ',
+ CONCAT('Existen problemas con el servicio de Logiflora, prepared_stmt_count con valor: ',
vPreparedCount,
', está próximo a exceder su límite. \r\n Hay que reiniciar el servicio LF.VMP.Service del servidor a3.')
);
@@ -63502,6 +64004,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `nextShelvingCodeMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63509,45 +64013,43 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nextShelvingCodeMake`()
BEGIN
DECLARE newShelving VARCHAR(3);
DECLARE vCode VARCHAR(3);
-
+
SELECT MAX(code) INTO vCode
FROM vn.shelving
WHERE isPrinted = FALSE;
-
+
SET @a1 := ASCII(MID(vCode,1,1));
SET @a2 := ASCII(MID(vCode,2,1));
SET @a3 := ASCII(MID(vCode,3,1)) + 1;
-
+
IF @a3 > 90 THEN
-
+
SET @a3 = 65;
SET @a2 = @a2 + 1;
-
+
IF @a2 > 90 THEN
-
+
SET @a2 = 65;
SET @a1 = @a1 + 1;
-
+
IF @a1 > 90 THEN
-
+
SET @a1 = 65;
-
+
END IF;
-
+
END IF;
-
+
END IF;
SET newShelving = CHAR(@a1,@a2,@a3 USING utf8);
-
+
INSERT INTO vn.shelving(code) VALUES(newShelving);
END ;;
@@ -63556,6 +64058,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `observationAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63563,8 +64067,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT)
BEGIN
@@ -63576,18 +64078,18 @@ BEGIN
* @param descripcion Texto de la observacion
*/
DECLARE vTableName VARCHAR(45);
-
+
SET vTableName = CONCAT(vTableCode,'Observation');
-
+
IF ISNULL(vTableName) THEN
CALL util.throw('CODE_NOT_FOUND');
END IF;
-
+
SET @qryLog := CONCAT(
'INSERT INTO ', vTableName, ' (originFk, userFk, description)',
' VALUES (', vOriginFk, ', ', account.myUser_getId(), ', "', vDescription, '")'
);
-
+
PREPARE stmt FROM @qryLog;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@@ -63597,6 +64099,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `orderCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63604,8 +64108,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderCreate`(
vLanded DATE,
@@ -63617,15 +64119,15 @@ BEGIN
DECLARE vDeliveryMethod INT;
DECLARE vClient INT;
-
+
SELECT deliveryMethodFk INTO vDeliveryMethod
- FROM vn.agencyMode
+ FROM vn.agencyMode
WHERE id = vAgencyMode;
-
+
SELECT clientFk INTO vClient
FROM vn.address
WHERE id = vAddress;
-
+
INSERT INTO hedera.order(date_send,customer_id,delivery_method_id,agency_id,address_id,source_app)
VALUES( vLanded,vClient ,vDeliveryMethod,vAgencyMode ,vAddress ,vSourceApp);
@@ -63637,6 +64139,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `orderDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63644,20 +64148,20 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderDelete`(IN vId INT)
BEGIN
DELETE FROM hedera.`order` where id = vId;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `orderListCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63665,8 +64169,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListCreate`(
vLanded DATE,
@@ -63678,13 +64180,15 @@ BEGIN
DECLARE vOrderId INT;
CALL vn.orderCreate(vLanded,vAgencyMode,vAddress,vSourceApp,vOrderId);
SELECT vOrderId;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `orderListVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63692,13 +64196,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListVolume`(IN vOrderId INT)
BEGIN
- SELECT
+ SELECT
o.id,
o.itemFk,
i.description,
@@ -63714,6 +64216,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `packageInvoicing` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63721,10 +64225,8 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`(
+CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`(
IN vClient INT,
IN vDate DATE,
IN vCompany INT,
@@ -63743,20 +64245,20 @@ BEGIN
SET vGraceDays = IF(vIsAllInvoiceable ,0, 30);
SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate);
-
- /* Clientes especiales:
+
+ /* Clientes especiales:
3240 MADEFLOR
992 JAVIER FELIU
4 TONI VENDRELL
*/
-
+
IF vClient IN (992, 3240, 4) THEN
-
+
SET vGraceDays = 365;
-
+
END IF;
/* Fin clientes especiales */
-
+
SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY);
DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice;
@@ -63780,22 +64282,22 @@ BEGIN
FROM tmp.packageToInvoice
GROUP BY itemFk
HAVING totalQuantity > 0;
-
+
SELECT COUNT(*)
INTO vIsInvoiceable
FROM tmp.packageToInvoicePositives;
IF vIsInvoiceable THEN
- CALL ticket_add(vClient,
+ CALL ticket_add(vClient,
vDateEnd,
- vWarehouse,
- vCompany,
- NULL,
- NULL,
- NULL,
- vDateEnd,
- account.myUser_getId(),
+ vWarehouse,
+ vCompany,
+ NULL,
+ NULL,
+ NULL,
+ vDateEnd,
+ account.myUser_getId(),
TRUE,
vNewTicket);
@@ -63804,50 +64306,52 @@ BEGIN
packagingFk,
quantity,
pvp)
- SELECT vNewTicket,
- pti.packagingFk,
- - SUM(pti.quantity) AS totalQuantity,
+ SELECT vNewTicket,
+ pti.packagingFk,
+ - SUM(pti.quantity) AS totalQuantity,
pti.price
FROM tmp.packageToInvoice pti
- LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
- WHERE ptip.itemFK IS NOT NULL
+ LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
+ WHERE ptip.itemFK IS NOT NULL
OR vIsAllInvoiceable
GROUP BY packagingFk
HAVING totalQuantity;
INSERT INTO sale(
ticketFk,
- itemFk,
- concept,
- quantity,
+ itemFk,
+ concept,
+ quantity,
price
)
- SELECT vNewTicket,
- pti.itemFk,
- i.name as concept,
- sum(pti.quantity) as totalQuantity,
+ SELECT vNewTicket,
+ pti.itemFk,
+ i.name as concept,
+ sum(pti.quantity) as totalQuantity,
pti.price
FROM tmp.packageToInvoice pti
JOIN item i ON i.id = pti.itemFk
LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
- WHERE ptip.itemFK IS NOT NULL
+ WHERE ptip.itemFK IS NOT NULL
OR vIsAllInvoiceable
GROUP BY pti.itemFk
HAVING totalQuantity;
-
+
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT id, vComponentCost, price
FROM sale
WHERE ticketFk = vNewTicket;
-
+
END IF;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `packingListPrinted` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63855,8 +64359,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListPrinted`(ticketFk INT)
BEGIN
@@ -63867,13 +64369,15 @@ BEGIN
WHERE mm.valor = 1 -- Listo para imprimir
AND mm.stateFk = 9 -- Encajando
AND m.Id_Ticket = ticketFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `packingListSwitch` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63881,23 +64385,21 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListSwitch`(saleFk INT)
BEGIN
DECLARE valueFk INT;
DECLARE encajando INT DEFAULT 9;
-
- SELECT valor INTO valueFk
- FROM vn2008.Movimientos_mark
- WHERE Id_Movimiento = saleFk
+
+ SELECT valor INTO valueFk
+ FROM vn2008.Movimientos_mark
+ WHERE Id_Movimiento = saleFk
AND stateFk = encajando;
-
+
SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3;
-
- REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk)
+
+ REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk)
VALUES(saleFk,valueFk,account.myUser_getId(),encajando);
@@ -63907,52 +64409,72 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `packingSite_startCollection` */;
/*!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_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET character_set_client = utf8mb3 */ ;
+/*!50003 SET character_set_results = utf8mb3 */ ;
+/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packingSite_startCollection`(vSelf INT, vTicketFk INT)
-BEGIN
+proc: BEGIN
/**
* @param vSelf packingSite id
* @param vTicketFk A ticket id from the collection to start
*/
- DECLARE vNewCollectionFk INT;
- DECLARE vOldCollectionFk INT;
- DECLARE vIsPackingByOther BOOL;
+ DECLARE vExists BOOL;
+ DECLARE vIsAdvanced BOOL;
+ DECLARE vNewCollectionFk INT;
+ DECLARE vOldCollectionFk INT;
+ DECLARE vIsPackingByOther BOOL;
- SELECT collectionFk INTO vNewCollectionFk
- FROM ticketCollection WHERE ticketFk = vTicketFk;
+ SELECT id, collectionFk
+ INTO vExists, vOldCollectionFk
+ FROM packingSite
+ WHERE id = vSelf;
- SELECT collectionFk INTO vOldCollectionFk
- FROM packingSite WHERE id = vSelf;
+ IF NOT vExists THEN
+ CALL util.throw('packingSiteNotExists');
+ END IF;
- IF NOT (vOldCollectionFk <=> vNewCollectionFk) THEN
- SELECT COUNT(*) > 0
- INTO vIsPackingByOther
- FROM packingSite
- WHERE id <> vSelf
- AND collectionFk = vOldCollectionFk;
+ SELECT COUNT(*) > 0
+ INTO vIsAdvanced
+ FROM packingSiteAdvanced
+ WHERE ticketFk = vTicketFk;
- IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) AND vSelf IS NOT NULL THEN
- CALL util.throw('cannotChangeCollection');
- END IF;
- END IF;
+ IF vIsAdvanced THEN
+ LEAVE proc;
+ END IF;
- UPDATE packingSite SET collectionFk = vNewCollectionFk
- WHERE id = vSelf;
+ SELECT collectionFk INTO vNewCollectionFk
+ FROM ticketCollection WHERE ticketFk = vTicketFk;
+
+ IF vOldCollectionFk IS NOT NULL
+ AND vOldCollectionFk <> vNewCollectionFk THEN
+ SELECT COUNT(*) > 0
+ INTO vIsPackingByOther
+ FROM packingSite
+ WHERE id <> vSelf
+ AND collectionFk = vOldCollectionFk;
+
+ IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) THEN
+ CALL util.throw('cannotChangeCollection');
+ END IF;
+ END IF;
+
+ UPDATE packingSite SET collectionFk = vNewCollectionFk
+ WHERE id = vSelf;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `parking_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63960,8 +64482,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN)
BEGIN
@@ -63971,34 +64491,34 @@ BEGIN
DECLARE vLetters VARCHAR(26) DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
DECLARE vMaxId INT;
DECLARE vCode VARCHAR(8);
-
+
SET vColumn = vFromColumn;
SET vRow = vFromRow;
SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
+
SELECT MAX(id) INTO vMaxId
FROM vn.parking;
WHILE vColumn <= vToColumn DO
-
+
WHILE vRow <= vToRow DO
-
+
INSERT IGNORE INTO vn.parking(`column`, `row`, sectorFk, `code`, pickingOrder)
VALUES (vColumn, vRow, vSectorFk, vCode, vColumn * 100 + vRow )
ON DUPLICATE KEY UPDATE `code` = vCode;
-
+
SET vRow = vRow + 1;
SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
+
END WHILE;
-
+
SET vRow = vFromRow;
SET vColumn = vColumn + 1;
-
+
SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
+
END WHILE;
-
+
SELECT * FROM vn.parking WHERE `column` BETWEEN vFromColumn AND vToColumn;
END ;;
@@ -64007,6 +64527,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `parking_algemesi` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64014,8 +64536,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT)
BEGIN
@@ -64023,65 +64543,67 @@ BEGIN
DECLARE vRow INT;
DECLARE vCode VARCHAR(8);
DECLARE i INT;
-
+
IF vToRow < vFromRow THEN
-
+
SET vRow = vFromRow;
-
+
WHILE vRow >= vToRow DO
-
+
SET i = 1;
-
+
WHILE i <= vTrolleysByLine DO
-
+
SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i);
-
+
INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder)
VALUES (vSectorFk, vCode, vPickingOrder + (i * 10))
ON DUPLICATE KEY UPDATE `code` = vCode;
-
+
SET i = i + 1;
-
+
END WHILE;
-
+
SET vRow = vRow - 1;
-
+
END WHILE;
ELSE
-
+
SET vRow = vFromRow;
-
+
WHILE vRow <= vToRow DO
-
+
SET i = 1;
-
+
WHILE i <= vTrolleysByLine DO
-
+
SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i);
-
+
INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder)
VALUES (vSectorFk, vCode, vPickingOrder + (i * 10) )
ON DUPLICATE KEY UPDATE `code` = vCode;
-
+
SET i = i + 1;
-
+
END WHILE;
-
+
SET vRow = vRow + 1;
-
+
END WHILE;
-
-
+
+
END IF;
-
-
+
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `parking_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64089,8 +64611,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT)
BEGIN
@@ -64099,34 +64619,36 @@ BEGIN
DECLARE vColumn INT;
DECLARE vLetters VARCHAR(200);
DECLARE vLettersLength INT;
-
+
SET vColumn = vStart;
SET vRow = 1;
SET vLetters = 'ABCDEF';
SET vLettersLength = LENGTH(vLetters);
-
+
WHILE vColumn <= vEnd DO
-
+
REPLACE vn.parking(`column`, `row`, `code`, sectorFk)
VALUES(vColumn, vRow, CONCAT(vColumn,MID(vLetters,vRow,1)), vSectorFk);
-
+
SET vRow = vRow + 1;
-
+
IF vRow > vLettersLength THEN
-
+
SET vRow = 1;
SET vColumn = vColumn + 1;
-
+
END IF;
-
+
END WHILE;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `parking_setOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64134,16 +64656,14 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_setOrder`(vWarehouseFk INT)
BEGIN
-
+
/*
* Ordena el orden de preparacion de los parking de acuerdo con la tabla vn.corridor
*/
-
+
UPDATE vn.parking p
JOIN (
SELECT code,
@@ -64152,21 +64672,23 @@ BEGIN
SELECT c.prepOrder,
p.code,
@orden := 0,
- IF(c.isAscendent, 1,-1) * CAST(SUBSTRING(p.code,3,2) AS DECIMAL(2,0)) subCorridor ,
- CAST(IF(LENGTH(p.code) > 5, SUBSTRING(p.code,6,2), 0) AS DECIMAL(2,0)) ubication
+ IF(c.isAscendent, 1,-1) * CAST(SUBSTRING(p.code,3,2) AS DECIMAL(2,0)) subCorridor ,
+ CAST(IF(LENGTH(p.code) > 5, SUBSTRING(p.code,6,2), 0) AS DECIMAL(2,0)) ubication
FROM vn.parking p
- JOIN vn.sector s ON s.id = p.sectorFk
+ JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.corridor c ON c.code = LEFT(p.code,1) COLLATE utf8_general_ci
- WHERE s.warehouseFk = vWarehouseFk) sub
- ORDER BY sub.prepOrder, subCorridor, ubication) sub2 ON sub2.code = p.code
+ WHERE s.warehouseFk = vWarehouseFk) sub
+ ORDER BY sub.prepOrder, subCorridor, ubication) sub2 ON sub2.code = p.code
SET p.pickingOrder = sub2.po;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `prepareClientList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64174,28 +64696,28 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareClientList`()
BEGIN
-
+
/*
* Require la tabla tmp.ticket(id,clientFk)
*/
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.client;
CREATE TEMPORARY TABLE tmp.client
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT DISTINCT clientFk id
- FROM tmp.ticket;
+ FROM tmp.ticket;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `prepareTicketList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64203,8 +64725,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME)
BEGIN
@@ -64231,6 +64751,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `previousSticker_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64238,8 +64760,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT)
BEGIN
@@ -64302,6 +64822,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `printer_checkSector` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64309,22 +64831,20 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11))
BEGIN
/**
* Comprueba si la impresora pertenece al sector
*
- * @param vLabelerFk id de la impresora
+ * @param vLabelerFk id de la impresora
* @param vSector sector a comprobar
*/
DECLARE isPrinterInNewSector BOOL;
IF vLabelerFk IS NOT NULL THEN
SELECT COUNT(sectorFK) INTO isPrinterInNewSector
- FROM vn.printer p
+ FROM vn.printer p
WHERE id = vLabelerFk AND sectorFk = vSector;
IF !isPrinterInNewSector THEN
@@ -64337,6 +64857,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `productionControl` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64344,11 +64866,9 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`(
- vWarehouseFk INT,
+ vWarehouseFk INT,
vScopeDays INT
)
proc: BEGIN
@@ -64369,7 +64889,7 @@ proc: BEGIN
SELECT isTodayRelative INTO vIsTodayRelative
FROM worker
- WHERE userFk = getUser();
+ WHERE id = getUser();
CALL prepareTicketList( util.VN_CURDATE() - INTERVAL 1 DAY, vEndingDate);
@@ -64449,7 +64969,7 @@ proc: BEGIN
LEFT JOIN parking pk ON pk.id = tp.parkingFk
WHERE t.warehouseFk = vWarehouseFk
AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP');
-
+
UPDATE tmp.productionBuffer pb
JOIN (
SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking
@@ -64457,12 +64977,12 @@ proc: BEGIN
JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
- JOIN parking p ON p.id = sg.parkingFk
+ JOIN parking p ON p.id = sg.parkingFk
GROUP BY pb.ticketFk
) t ON t.ticketFk = pb.ticketFk
SET pb.previaParking = t.previaParking;
- -- Problemas por ticket
+ -- Problemas por ticket
ALTER TABLE tmp.productionBuffer
CHANGE COLUMN `problem` `problem` VARCHAR(255),
ADD COLUMN `collectionH` INT,
@@ -64559,6 +65079,7 @@ proc: BEGIN
AND (sc.itemPackingTypeFk IS NULL
OR (i.itemPackingTypeFk IS NULL AND NOT pb.V)
OR sc.itemPackingTypeFk = i.itemPackingTypeFk)
+ AND s.quantity > 0
GROUP BY pb.ticketFk;
-- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado
@@ -64569,6 +65090,7 @@ proc: BEGIN
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
WHERE sg.parkingFk IS NOT NULL
+ AND s.quantity > 0
GROUP BY pb.ticketFk) sub ON twp.ticketFk = sub.ticketFk
SET twp.salesInParkingCount = sub.salesInParkingCount;
@@ -64589,6 +65111,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `productionSectorList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64596,8 +65120,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `productionSectorList`(vSectorFk INT)
BEGIN
@@ -64710,6 +65232,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `rangeDateInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64717,8 +65241,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rangeDateInfo`(vStarted DATE, vEnded DATE)
BEGIN
@@ -64741,7 +65263,7 @@ BEGIN
`yearMonth` INT
)
ENGINE = MEMORY;
-
+
WHILE vDated <= vEnded DO
INSERT INTO tmp.rangeDate
SET `dated` = vDated,
@@ -64751,7 +65273,7 @@ BEGIN
`day` = DAY(vDated),
`week` = WEEK(vDated, 1),
`yearMonth` = YEAR(vDated) * 100 + MONTH(vDated);
-
+
SET vDated = DATE_ADD(vDated, INTERVAL 1 DAY);
END WHILE;
END ;;
@@ -64760,6 +65282,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `rate_getPrices` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64767,82 +65291,57 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices`(vDated DATE, vWarehouseFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices`(
+ vDated DATE,
+ vWarehouseFk INT
+)
BEGIN
/**
- * Prepara una tabla con las tarifas aplicables en funcion de la fecha y el almacén
+ * Prepara una tabla con las tarifas aplicables
+ * en funcion de la fecha y el almacén.
*
- * @param vDated fecha para la cual calcula la tarifa
- * @param vWarehouseFk warehouse para el cual calcula la tafia
- * @return tmp.rate(rate0, rate1, rate2, rate3)
+ * @param vDated Fecha para la cual calcula la tarifa
+ * @param vWarehouseFk Warehouse para el cual calcula la tarifa
+ * @return tmp.rate (rate0, rate1, rate2, rate3)
*/
- DROP TEMPORARY TABLE IF EXISTS tRate;
- CREATE TEMPORARY TABLE tRate
- SELECT rate0, rate1, rate2, rate3
- FROM vn.rate
- WHERE dated <= vDated
- AND warehouseFk = vWarehouseFk
- ORDER BY dated DESC;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.rate;
- CREATE TEMPORARY TABLE tmp.rate
+ CREATE OR REPLACE TEMPORARY TABLE tmp.rate
ENGINE = MEMORY
- SELECT * FROM
- (
- SELECT * FROM tRate
- UNION ALL
- SELECT rate0, rate1, rate2, rate3 FROM rateConfig
- ) sub2
- LIMIT 1;
- DROP TEMPORARY TABLE tRate;
+ SELECT rate0,
+ rate1,
+ rate2,
+ rate3
+ FROM(
+ (SELECT 1 `order`,
+ rate0,
+ rate1,
+ rate2,
+ rate3
+ FROM rate
+ WHERE dated <= vDated
+ AND warehouseFk = vWarehouseFk
+ ORDER BY dated DESC
+ LIMIT 1
+ )
+ UNION
+ (SELECT 2,
+ rate0,
+ rate1,
+ rate2,
+ rate3
+ FROM rateConfig
+ )
+ ORDER BY `order` ASC
+ LIMIT 1
+ )sub;
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 `rate_getPrices2` */;
-/*!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_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices2`(vLanded DATE, vWarehouseFk INT)
-BEGIN
-
- -- Prepara una tabla con las tarifas aplicables en funcion de la fecha y el almacén
- DROP TEMPORARY TABLE IF EXISTS tRate;
- CREATE TEMPORARY TABLE tRate
- SELECT rate0, rate1, rate2, rate3
- FROM vn.rate
- WHERE dated <= vLanded
- AND warehouseFk = vWarehouseFk
- ORDER BY dated DESC;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.rate;
- CREATE TEMPORARY TABLE tmp.rate
- ENGINE = MEMORY
- SELECT * FROM
- (
- SELECT * FROM tRate
- UNION ALL
- SELECT rate0, rate1, rate2, rate3 FROM rateConfig
- ) sub2
- LIMIT 1;
- DROP TEMPORARY TABLE tRate;
-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 `recipe_Cook` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64850,8 +65349,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Cook`(vItemFk INT, vBunchesQuantity INT, vDate DATE)
BEGIN
@@ -64865,7 +65362,7 @@ BEGIN
CALL cache.available_refresh(vCalc, FALSE, vWarehouseFk, vDate);
DROP TEMPORARY TABLE IF EXISTS tmp.recipeCook;
-
+
CREATE TEMPORARY TABLE tmp.recipeCook
SELECT *,
@counter := IF(@element = element COLLATE utf8_general_ci , @counter + 1, 1) as counter,
@@ -64883,22 +65380,22 @@ BEGIN
IFNULL((i.inkFk = r.inkFk ) ,0)
+ IFNULL((i.size = r.size) ,0)
+ IFNULL((i.name LIKE CONCAT('%',r.name,'%')) ,0)
- + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0)
+ + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0)
+ IFNULL((i.typeFk = r.typeFk),0) as matches,
i.typeFk,
rl.previousSelected
- FROM vn.recipe r
+ FROM vn.recipe r
JOIN vn.item i ON (IFNULL(i.name LIKE CONCAT('%',r.name,'%'), 0)
OR IFNULL(i.longName LIKE CONCAT('%',r.longName,'%'),0))
OR i.typeFk <=> r.typeFk
JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalc
LEFT JOIN (SELECT recipe_ItemFk, element as log_element, selected_ItemFk, count(*) as previousSelected
FROM vn.recipe_log
- GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk
+ GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk
AND rl.log_element = r.element
AND rl.selected_ItemFk = i.id
WHERE r.itemFk = vItemFk
- AND a.available > vBunchesQuantity * r.quantity
+ AND a.available > vBunchesQuantity * r.quantity
UNION ALL
SELECT 100 itemFk,
CONCAT('? ',r.element,' ',IFNULL(r.size,''),' ',IFNULL(r.inkFk,'')) as longName,
@@ -64915,21 +65412,23 @@ BEGIN
WHERE r.itemFk = vItemFk
GROUP BY r.element
) sub
-
+
ORDER BY element, matches DESC, previousSelected DESC;
-
- SELECT *
+
+ SELECT *
FROM tmp.recipeCook
WHERE counter < 6
- OR itemFk = 100
+ OR itemFk = 100
;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `recipe_Plaster` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64937,8 +65436,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT)
BEGIN
@@ -64948,71 +65445,71 @@ BEGIN
DECLARE vShipped DATE;
DECLARE vEntryFk INT;
DECLARE vTravelFk INT;
-
+
CALL cache.last_buy_refresh(FALSE);
-
- SELECT warehouseFk, shipped
+
+ SELECT warehouseFk, shipped
INTO vWarehouseFk, vShipped
- FROM vn.ticket
+ FROM vn.ticket
WHERE id = vTicketFk;
UPDATE vn.ticket t
JOIN vn.item i ON i.id = vItemFk
SET t.nickname = CONCAT(vQuantity,' ',i.longName)
WHERE t.id = vTicketFk;
-
+
SELECT b.buyingValue INTO vLastCost
FROM vn.buy b
JOIN cache.last_buy lb ON lb.buy_id = b.id
WHERE lb.item_id = vItemFk
ORDER BY (lb.warehouse_id = vWarehouseFk) DESC
LIMIT 1;
-
+
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)
SELECT vTicketFk, 98, - vQuantity, i.longName, vLastCost
FROM vn.item i
WHERE i.id = vItemFk;
- /*
+ /*
SELECT tr.id INTO vTravelFk
FROM vn.travel tr
JOIN vn.warehouse w ON w.id = tr.warehouseOutFk
WHERE tr.warehouseInFk = vWarehouseFk
AND tr.landed = vShipped
AND w.name = 'Confeccion';
-
+
IF IFNULL(vTravelFk,0) = 0 THEN
-
+
INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyFk)
SELECT vShipped, vShipped, vWarehouseFk, w.id, am.id
- FROM vn.warehouse w
- JOIN vn.agencyMode am
+ FROM vn.warehouse w
+ JOIN vn.agencyMode am
WHERE w.name = 'Confeccion'
AND am.name = 'DIRECTO PROVEEDOR';
-
+
SET vTravelFk = LAST_INSERT_ID();
-
- END IF;
-
+
+ END IF;
+
SELECT e.id INTO vEntryFk
FROM vn.entry e
JOIN vn.supplier s ON s.id = supplierFk
WHERE e.travelFk = vTravelFk
AND s.name = 'Confeccion Natural'
AND e.isRaid = FALSE;
-
+
IF IFNULL(vEntryFk,0) = 0 THEN
-
+
INSERT INTO vn.entry(supplierFk, evaNotes, travelFk, companyFk)
SELECT s.id, t.nickname, vTravelFk, c.id
FROM vn.supplier s
JOIN vn.ticket t ON t.id = vTicketFk
- JOIN vn.company c ON c.code = 'VNL'
+ JOIN vn.company c ON c.code = 'VNL'
WHERE s.name = 'Confeccion Natural';
-
+
SET vEntryFk = LAST_INSERT_ID();
-
+
END IF;
-
+
INSERT INTO vn.buy(entryFk, itemFk, quantity, buyingValue, packageFk, packing, grouping)
SELECT vEntryFk, b.itemFk, vQuantity, b.buyingValue, b.packageFk, b.packing, b.grouping
FROM cache.last_buy lb
@@ -65027,6 +65524,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `reportLabelCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65034,8 +65533,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(
vParam INT,
@@ -65095,6 +65592,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `report_print` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65102,8 +65601,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `report_print`(
vReportName VARCHAR(100),
@@ -65114,7 +65611,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `report_print`(
)
BEGIN
/**
- * Inserts in the print queue the report to be printed and the necessary parameters for this
+ * Inserts in the print queue the report to be printed and the necessary parameters for this
* one taking into account the paper size of both the printer and the report.
*
* @param vReportName the report to be printed.
@@ -65157,11 +65654,11 @@ BEGIN
END IF;
IF vReportFk IS NULL THEN
- CALL util.throw('reportNotExists');
+ CALL util.throw('reportNotExists');
END IF;
IF vReportSize <> vPrinteSize THEN
- CALL util.throw('incorrectSize');
+ CALL util.throw('incorrectSize');
END IF;
START TRANSACTION;
@@ -65170,7 +65667,7 @@ BEGIN
priorityFk = vPriorityFk,
reportFk = vReportFk,
workerFk = vUserFk;
-
+
SET vPrintQueueFk = LAST_INSERT_ID();
WHILE vI < vLength DO
@@ -65191,6 +65688,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `riskAllClients` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65198,21 +65697,19 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `riskAllClients`(maxRiskDate DATE)
BEGIN
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
CREATE TEMPORARY TABLE tmp.client_list
(PRIMARY KEY (Id_Cliente))
ENGINE = MEMORY
SELECT id Id_Cliente, null grade FROM vn.client;
-
+
CALL vn2008.risk_vs_client_list(maxRiskDate);
-
- SELECT
+
+ SELECT
c.RazonSocial,
c.Id_Cliente,
c.Credito,
@@ -65224,7 +65721,7 @@ BEGIN
JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
GROUP BY c.Id_cliente;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
END ;;
@@ -65233,6 +65730,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `routeGuessPriority` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65240,8 +65739,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGuessPriority`(IN vRuta INT)
BEGIN
@@ -65266,6 +65763,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `routeInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65273,8 +65772,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeInfo`(vRouteFk INT)
BEGIN
@@ -65283,25 +65780,25 @@ BEGIN
DECLARE vM3 INT;
DECLARE vKg INT;
DECLARE vMatricula varchar(50);
-
+
SELECT sum(packages) as bultos
INTO vPackages
- FROM vn.ticket t
+ FROM vn.ticket t
WHERE routeFk = vRouteFk;
-
+
SELECT SUM(sv.physicalVolume), SUM(sv.physicalWeight)
INTO vM3, vKg
FROM vn.saleVolume sv
WHERE sv.routeFk = vRouteFk;
-
+
SELECT v.numberPlate as matricula
INTO vMatricula
- FROM vn.route r
+ FROM vn.route r
JOIN vn.vehicle v ON r.vehicleFk = v.id
WHERE r.id = vRouteFk;
-
+
SELECT vRouteFk as Ruta,
- vPackages as Bultos,
+ vPackages as Bultos,
vM3 as m3,
vKg as Kg,
vMatricula as Matricula;
@@ -65312,6 +65809,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `routeMonitor_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65319,8 +65818,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`(
vDate DATE,
@@ -65366,7 +65863,7 @@ BEGIN
) sub ON sub.routeFk = rm.routeFk
SET rm.ticketFree = sub.ticketFree;
- UPDATE routesMonitor rm
+ UPDATE routesMonitor rm
JOIN(
SELECT t.routeFk, COUNT(*) AS ticketPacked
FROM vn.ticket t
@@ -65439,6 +65936,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `routeSetOk` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65446,23 +65945,23 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeSetOk`(
vRouteFk INT)
BEGIN
-
+
UPDATE vn.route r
SET r.isOk = 1
WHERE r.id = vRouteFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `routeUpdateM3` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65470,8 +65969,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeUpdateM3`(vRoute INT)
BEGIN
@@ -65485,6 +65982,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `route_calcCommission` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65492,8 +65991,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_calcCommission`(vSelf INT)
proc: BEGIN
@@ -65521,17 +66018,17 @@ proc: BEGIN
IF vIsFreelance THEN
INSERT INTO routeCommission (
- routeFk,
- workCenterFk,
- freelanceYearlyM3,
- cat4m3,
+ routeFk,
+ workCenterFk,
+ freelanceYearlyM3,
+ cat4m3,
cat5m3
)
SELECT vSelf,
r.commissionWorkCenterFk,
rc.freelanceM3 * IF(
- IFNULL(r.m3, 0) >= rc.freelanceMinM3,
- IFNULL(r.m3, 0),
+ IFNULL(r.m3, 0) >= rc.freelanceMinM3,
+ IFNULL(r.m3, 0),
0),
rc.distributionCat4M3 * IFNULL(r.m3, 0),
rc.distributionCat5M3 * IFNULL(r.m3, 0)
@@ -65543,20 +66040,20 @@ proc: BEGIN
AND r.commissionWorkCenterFk;
ELSE
INSERT INTO routeCommission (
- routeFk,
- workCenterFk,
- km,
- m3,
- yearlyKm,
- yearlyM3,
- cat4m3,
+ routeFk,
+ workCenterFk,
+ km,
+ m3,
+ yearlyKm,
+ yearlyM3,
+ cat4m3,
cat5m3
)
SELECT vSelf,
r.commissionWorkCenterFk,
- (r.kmEnd - r.kmStart) *
+ (r.kmEnd - r.kmStart) *
IF(v.isKmTruckRate, rc.kmHeavy, rc.kmLight),
- IFNULL(r.m3, 0) *
+ IFNULL(r.m3, 0) *
IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
(r.kmEnd - r.kmStart) * rc.kmYearly,
IFNULL(r.m3, 0) * rc.m3Yearly,
@@ -65578,6 +66075,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `route_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65585,15 +66084,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_doRecalc`()
proc: BEGIN
/**
* Recalculates modified route.
*/
-
+
DECLARE vDone BOOL;
DECLARE vRouteFk INT;
@@ -65602,7 +66099,7 @@ proc: BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
-
+
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
DO RELEASE_LOCK('vn.route_doRecalc');
@@ -65639,6 +66136,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `route_getTickets` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65646,8 +66145,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_getTickets`(vRouteFk INT)
BEGIN
@@ -65678,7 +66175,8 @@ SELECT *
wm.mediaValue SalePersonPhone,
tob.description Note,
t.isSigned Signed,
- t.priority
+ t.priority,
+ t.cmrFk
FROM ticket t
JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id
@@ -65720,6 +66218,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `route_updateM3` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65727,8 +66227,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`(vRoute INT)
BEGIN
@@ -65747,187 +66245,8 @@ 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 `rutasAnalyze` */;
-/*!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_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT)
-BEGIN
-
-/**
- * Analiza los costes de las rutas de reparto y lo almacena en la tabla Rutas_Master
- *
- * PAK 15/4/2019
- */
-
- DELETE FROM bi.rutasBoard
- WHERE year = vYear AND month = vMonth;
-
- -- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales"
- INSERT INTO bi.rutasBoard(year,
- month,
- warehouse_id,
- Id_Ruta,
- Id_Agencia,
- km,
- Dia,
- Fecha,
- m3,
- bultos,
- Matricula,
- Tipo,
- Terceros)
- SELECT YEAR(r.created),
- MONTH(r.created),
- IFNULL(GREATEST(1,a.warehouseFk), 0),
- r.id,
- r.agencyModeFk,
- IFNULL(r.kmEnd, 0) - IFNULL(r.kmStart, 0),
- DAYNAME(r.created),
- r.created,
- SUM(r.m3),
- SUM(sv.volume / ebv.m3),
- v.numberPlate,
- IF(ISNULL(`r`.`cost`), 'P', 'A'),
- IFNULL(r.cost,0)
- FROM route r
- JOIN ticket t ON t.routeFk = r.id
- LEFT JOIN zone z ON z.id = t.zoneFk
- LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
- LEFT JOIN agency a ON a.id = am.agencyFk
- LEFT JOIN vehicle v ON v.id = r.vehicleFk
- JOIN saleVolume sv ON sv.ticketFk = t.id
- JOIN expeditionBoxVol ebv ON ebv.boxFk = 71
- WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
- AND z.isVolumetric
- GROUP BY r.id;
- -- Rellenamos la tabla con los datos de las rutas NO VOLUMETRICAS, especialmente con los bultos "virtuales"
- INSERT INTO bi.rutasBoard(year,
- month,
- warehouse_id,
- Id_Ruta,
- Id_Agencia,
- km,
- Dia,
- Fecha,
- m3,
- Bultos,
- Matricula,
- Tipo,
- Terceros)
- SELECT YEAR(r.created),
- MONTH(r.created),
- IFNULL(GREATEST(1,a.warehouseFk), 0),
- r.id,
- r.agencyModeFk,
- IFNULL(r.kmEnd, 0) - IFNULL(r.kmStart,0),
- DAYNAME(r.created),
- r.created,
- SUM(r.m3),
- SUM(t.packages),
- v.numberPlate,
- IF(ISNULL(`r`.`cost`), 'P', 'A'),
- IFnULL(r.cost,0)
- FROM route r
- JOIN ticket t ON t.routeFk = r.id
- LEFT JOIN zone z ON z.id = t.zoneFk
- LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
- LEFT JOIN agency a ON a.id = am.agencyFk
- LEFT JOIN vehicle v ON v.id = r.vehicleFk
- WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
- AND z.isVolumetric = FALSE
- GROUP BY r.id
- ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
-
- -- Coste REAL de cada bulto "virtual", de acuerdo con el valor apuntado a mano en la ruta
- UPDATE bi.rutasBoard r
- INNER JOIN vn2008.Rutas_Master rm ON rm.año = r.year AND rm.mes = r.month AND rm.warehouse_id = r.warehouse_id
- SET r.coste_bulto = IF(r.Tipo ='A', r.Terceros, r.km * rm.coste_km ) / r.Bultos
- WHERE r.Bultos > 0
- AND rm.año = vYear
- AND rm.mes = vMonth;
-
- -- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta
- UPDATE bi.rutasBoard r
- JOIN (
- SELECT t.routeFk, sum(s.quantity * sc.value) practicoTotal
- FROM route r
- JOIN time tm ON tm.dated = r.created
- JOIN ticket t ON t.routeFk = r.id
- JOIN sale s ON s.ticketFk = t.id
- JOIN saleComponent sc ON sc.saleFk = s.id
- JOIN component c ON c.id = sc.componentFk
- JOIN componentType ct ON ct.id = c.typeFk
- WHERE ct.type = 'agencia'
- AND tm.year = vYear
- AND tm.month = vMonth
- GROUP BY r.id
- ) sub ON sub.routeFk = r.Id_Ruta
- SET r.practico = IFNULL(sub.practicoTotal / r.Bultos, 0);
-
- -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc
- UPDATE bi.rutasBoard r
- JOIN (
- SELECT t.routeFk,
- SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio
- FROM ticket t
- JOIN route r ON r.id = t.routeFk
- JOIN time tm ON tm.dated = r.created
- JOIN expedition e ON e.ticketFk = t.id
- JOIN expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
- JOIN address ad ON ad.id = t.addressFk
- JOIN client c ON c.id = ad.clientFk
- LEFT JOIN zone z ON z.id = t.zoneFk
- WHERE tm.year = vYear
- AND tm.month = vMonth
- AND z.isVolumetric = FALSE
- GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
- SET r.teorico = IFNULL(sub.BultoTeoricoMedio, 0);
-
- -- Coste VOLUMETRICO TEORICO de una caja "virtual" para cada ruta
- UPDATE bi.rutasBoard r
- JOIN (
- SELECT t.routeFk,
- SUM(freight) AS BultoTeoricoMedio
- FROM ticket t
- JOIN route r ON r.id = t.routeFk
- JOIN time tm ON tm.dated = r.created
- JOIN saleVolume sf ON sf.ticketFk = t.id
- JOIN client c ON c.id = t.clientFk
- JOIN zone z ON z.id = t.zoneFk
- WHERE tm.year = vYear
- AND tm.month = vMonth
- AND z.isVolumetric != FALSE
- GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
- SET r.teorico = IFNULL(sub.BultoTeoricoMedio / r.Bultos, 0);
-
- -- La diferencia entre el teorico y el practico se deberia de cobrar en greuges, cada noche
- UPDATE bi.rutasBoard r
- JOIN (
- SELECT t.routeFk,
- Sum(g.amount) AS greuge
- FROM ticket t
- JOIN route r ON r.id = t.routeFk
- JOIN time tm ON tm.dated = r.created
- JOIN greuge g ON g.ticketFk = t.id
- JOIN greugeType gt ON gt.id = g.greugeTypeFk
- WHERE tm.year = vYear
- AND tm.month = vMonth
- AND gt.name = 'Diferencia portes'
- GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
- SET r.greuge = sub.greuge / r.Bultos;
-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 `saleBuy_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65935,38 +66254,38 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT)
BEGIN
-
+
/* Añade un registro a la tabla saleBuy en el caso de que sea posible mantener la trazabilidad
- *
+ *
* @param vSaleFk clave primaria de vn.sale
* @param vBuyFk clave primaria de vn.buy
*/
- /*IF (SELECT COUNT(*)
+ /*IF (SELECT COUNT(*)
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
WHERE s.id = vSaleFk
AND ic.code = 'fruit') THEN */
-
- IF (SELECT COUNT(*) FROM vn.buy WHERE id = vBuyFk AND itemOriginalFk) THEN
-
+
+ IF (SELECT COUNT(*) FROM vn.buy WHERE id = vBuyFk AND itemOriginalFk) THEN
+
INSERT INTO vn.saleBuy (saleFk, buyFk)
VALUES(vSaleFk, vBuyFk);
-
+
END IF;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleGroup_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65974,8 +66293,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT)
BEGIN
@@ -65984,7 +66301,7 @@ BEGIN
*
* @param vSectorFk Identificador de vn.sector
*/
- INSERT INTO vn.saleGroup(userFk, sectorFk)
+ INSERT INTO vn.saleGroup(userFk, sectorFk)
VALUES (account.myUser_getId(), vSectorFk);
SELECT LAST_INSERT_ID();
@@ -65994,6 +66311,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleGroup_setParking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66001,8 +66320,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT)
proc: BEGIN
@@ -66024,6 +66341,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleMistake_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66031,8 +66350,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT)
BEGIN
@@ -66046,6 +66363,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `salePreparingList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66053,8 +66372,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salePreparingList`(IN vTicketFk BIGINT)
BEGIN
@@ -66105,6 +66422,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sales_merge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66112,42 +66431,51 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sales_merge`(vTicketFk INT)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS salesToPreserve;
- CREATE TEMPORARY TABLE salesToPreserve
- SELECT s.id, s.itemFk, sum(s.quantity) as newQuantity
- FROM vn.sale s
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- WHERE s.ticketFk = vTicketFk
- AND it.isMergeable
- GROUP BY s.itemFk, s.price, s.discount;
-
- UPDATE vn.sale s
- JOIN salesToPreserve stp ON stp.id = s.id
- SET quantity = newQuantity
- WHERE s.ticketFk = vTicketFk;
-
- DELETE s.*
- FROM vn.sale s
- LEFT JOIN salesToPreserve stp ON stp.id = s.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- WHERE s.ticketFk = vTicketFk
- AND stp.id IS NULL
- AND it.isMergeable;
-
- DROP TEMPORARY TABLE salesToPreserve;
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
+ SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE s.ticketFk = vTicketFk
+ AND it.isMergeable
+ GROUP BY s.itemFk, s.price, s.discount;
+
+ START TRANSACTION;
+
+ UPDATE sale s
+ JOIN tSalesToPreserve stp ON stp.id = s.id
+ SET quantity = newQuantity
+ WHERE s.ticketFk = vTicketFk;
+
+ DELETE s.*
+ FROM sale s
+ LEFT JOIN tSalesToPreserve stp ON stp.id = s.id
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE s.ticketFk = vTicketFk
+ AND stp.id IS NULL
+ AND it.isMergeable;
+
+ COMMIT;
+
+ DROP TEMPORARY TABLE tSalesToPreserve;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sales_mergeByCollection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66155,8 +66483,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sales_mergeByCollection`(vCollectionFk INT)
BEGIN
@@ -66176,17 +66502,17 @@ BEGIN
OPEN cCur;
myLoop: LOOP
-
+
SET vDone = FALSE;
-
+
FETCH cCur INTO vTicketFk;
IF vDone THEN
LEAVE myLoop;
END IF;
-
+
CALL vn.sales_merge(vTicketFk);
-
+
END LOOP;
CLOSE cCur;
@@ -66197,6 +66523,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66204,8 +66532,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_add`(vSaleGroupFk INT)
BEGIN
@@ -66232,6 +66558,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPreparedSaleGroup` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66239,8 +66567,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT)
BEGIN
@@ -66260,6 +66586,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPrevOK` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66267,8 +66595,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPrevOK`(vSectorCollectionFk INT)
BEGIN
@@ -66298,6 +66624,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_del` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66305,8 +66633,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50))
BEGIN
@@ -66317,15 +66643,17 @@ BEGIN
DELETE st.*
FROM vn.saleTracking st
JOIN vn.state s ON s.id = st.stateFk
- WHERE st.saleFk = vSaleFk
+ WHERE st.saleFk = vSaleFk
AND s.code = vState COLLATE utf8_unicode_ci;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66333,15 +66661,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`(
- vSaleFK INT,
- vIsChecked BOOLEAN,
- vOriginalQuantity INT,
- vWorkerFk INT,
- vAction VARCHAR(50),
+CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`(
+ vSaleFK INT,
+ vIsChecked BOOLEAN,
+ vOriginalQuantity INT,
+ vWorkerFk INT,
+ vAction VARCHAR(50),
vState VARCHAR(50),
vIsScanned BOOLEAN)
BEGIN
@@ -66357,12 +66683,12 @@ BEGIN
* @param vIsScanned Identificador si se ha escaneado automáticamente o manual
*/
- REPLACE vn.saleTracking(saleFk,
- isChecked,
- originalQuantity,
- workerFk,
+ REPLACE vn.saleTracking(saleFk,
+ isChecked,
+ originalQuantity,
+ workerFk,
stateFk,
- isScanned)
+ isScanned)
SELECT vSaleFK,
vIsChecked,
vOriginalQuantity,
@@ -66377,6 +66703,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_updateIsChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66384,32 +66712,30 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL)
BEGIN
-
+
/**
* Actualiza el estado del campo vn.saleTracking.isChecked y elimina las lineas de vn.itemShelving
* si procede, en el caso de las preparaciones previas, por usuario
- *
+ *
* @param vSaleFk Identificador de vn.sale
* @param vIsChecked Estado del registro
*/
-
+
UPDATE vn.saleTracking st
JOIN vn.state s ON s.id = st.stateFk AND s.code = 'PREVIOUS_PREPARATION'
SET st.isChecked = vIsChecked,
st.isScanned = vIsScanned
WHERE st.saleFk = vSaleFK
AND st.workerFk = account.myUser_getId();
-
+
IF vIsChecked = FALSE THEN
-
- DELETE FROM vn.itemShelvingSale
+
+ DELETE FROM vn.itemShelvingSale
WHERE saleFk = vSaleFK;
-
+
END IF;
END ;;
@@ -66418,6 +66744,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_calculateComponent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66425,8 +66753,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSelf INT, vOption INT)
proc: BEGIN
@@ -66435,14 +66761,14 @@ proc: BEGIN
*
* @param vSelf Id de la venta
* @param vOption indica en que componente pone el descuadre, NULL en casos habituales
- */
+ */
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
SELECT s.id
FROM sale s
WHERE s.id = vSelf;
-
+
CALL sale_recalcComponent(vOption);
-
+
DROP TEMPORARY TABLE tmp.recalculateSales;
END ;;
DELIMITER ;
@@ -66450,6 +66776,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_checkNoComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66457,8 +66785,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
BEGIN
@@ -66489,7 +66815,7 @@ BEGIN
GROUP BY s.id;
DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET v_done = TRUE;
+ SET v_done = TRUE;
DROP TEMPORARY TABLE IF EXISTS tmp.coste;
@@ -66497,7 +66823,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.coste
(PRIMARY KEY (id)) ENGINE = MEMORY
SELECT s.id
- FROM sale s
+ FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemType tp ON tp.id = i.typeFk
JOIN itemCategory ic ON ic.id = tp.categoryFk
@@ -66516,23 +66842,25 @@ BEGIN
IF v_done THEN
LEAVE l;
END IF;
-
+
SELECT ticketFk, concept
INTO vTicketFk, vConcept
FROM sale
WHERE id = vSaleFk;
-
+
CALL sale_calculateComponent(vSaleFk, 1);
END LOOP;
CLOSE vCur;
- DROP TEMPORARY TABLE tmp.coste;
+ DROP TEMPORARY TABLE tmp.coste;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_getFromTicketOrCollection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66540,8 +66868,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT)
BEGIN
@@ -66612,29 +66938,29 @@ DECLARE vIsCollection BOOL;
TRIM(CONCAT(LPAD(s.concept,30,' '), ' ',
RPAD(IFNULL(i.size,''),5,' '))) line1,
'' cel1,
- TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) line2,
+ TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) line2,
IF(s.quantity MOD IFNULL(b.packing,s.quantity + 1),
CONCAT(CAST(s.quantity/IFNULL(b.`grouping`,1) AS DECIMAL(10,0)),' x ',IFNULL(b.`grouping`,1)),
CONCAT(CAST(s.quantity / IFNULL(b.packing,1) AS DECIMAL(10,0)),' pack de ',IFNULL(b.packing,1))) cel2,
TRIM(CONCAT(ic.color)) line3,
p.code cel3,
s.isAdded,
- sub2.originalQuantity startQuantity, -- eliminar cuando tengamos la nueva apk
IF(c.workerFk IS NULL, getUser(), c.workerFk) workerFk,
IF(SUM(iss.quantity) IS NULL, 0, SUM(iss.quantity)) pickedQuantity,
i.packingShelve,
MIN(iss.created) picked,
- IF(sm.id, TRUE, FALSE) hasMistake
+ IF(sm.id, TRUE, FALSE) hasMistake,
+ sg.sectorFk
FROM tmp.ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN ticket tt ON tt.id = t.id
LEFT JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = tt.warehouseFk
- LEFT JOIN buy b ON b.id = lb.buy_id
+ LEFT JOIN buy b ON b.id = lb.buy_id
JOIN item i ON i.id = s.itemFk
LEFT JOIN ticketCollection tc ON tc.ticketFk = t.id
LEFT JOIN collection c ON c.id = tc.collectionFk
- LEFT JOIN (SELECT sub.saleFk, sub.isChecked, sub.stateFk, sub.originalQuantity
- FROM (SELECT DISTINCT st.id, st.saleFk, st.isChecked, st.stateFk, st.originalQuantity
+ LEFT JOIN (SELECT sub.saleFk, sub.isChecked, sub.stateFk, sub.originalQuantity
+ FROM (SELECT DISTINCT st.id, st.saleFk, st.isChecked, st.stateFk, st.originalQuantity
FROM tmp.ticket2 t
JOIN sale s ON s.ticketFk = t.id
JOIN saleTracking st ON st.saleFk = s.id
@@ -66646,7 +66972,7 @@ DECLARE vIsCollection BOOL;
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN itemProductor ip ON ip.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk
- LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
+ LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
LEFT JOIN parking p ON p.id = sg.parkingFk
LEFT JOIN saleMistake sm ON sm.saleFk = s.id
@@ -66661,6 +66987,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_getProblems` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66668,8 +66996,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1))
BEGIN
@@ -66698,8 +67024,8 @@ BEGIN
DELETE tt.*
FROM tmp.sale_getProblems tt
JOIN vn.ticketObservation tto ON tto.ticketFk = tt.ticketFk
- JOIN vn.observationType ot ON ot.id = tto.observationTypeFk
- WHERE ot.code = 'administrative'
+ JOIN vn.observationType ot ON ot.id = tto.observationTypeFk
+ WHERE ot.code = 'administrative'
AND tto.description = 'Miriam';
CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems (
@@ -66731,7 +67057,7 @@ BEGIN
-- Too Little
INSERT INTO tmp.sale_problems(ticketFk, isTooLittle)
- SELECT tp.ticketFk, TRUE
+ SELECT tp.ticketFk, TRUE
FROM tmp.sale_getProblems tp
JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN (SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat
@@ -66762,6 +67088,7 @@ BEGIN
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE dm.code IN('AGENCY','DELIVERY','PICKUP')
+ AND s.quantity > 0
GROUP BY s.id
LIMIT 10000000000000000) sub
WHERE sub.hasComponentLack;
@@ -66817,25 +67144,25 @@ BEGIN
-- Disponible: no va a haber suficiente producto para preparar todos los pedidos
CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, vDate);
-
- -- Faltas: visible, disponible y ubicado son menores que la cantidad vendida
+
+ -- Faltas: visible, disponible y ubicado son menores que la cantidad vendida
CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk)
SELECT ticketFk, problem, saleFk
FROM (
- SELECT tl.ticketFk,
- LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem,
+ SELECT tl.ticketFk,
+ LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem,
s.id AS saleFk
FROM tmp.ticket_list tl
JOIN vn.ticket t ON t.id = tl.ticketFk
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it on it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) < s.quantity
AND IFNULL(av.available ,0) < s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
@@ -66848,7 +67175,7 @@ BEGIN
AND t.warehouseFk = vWarehouseFk
GROUP BY tl.ticketFk) sub
ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk;
-
+
-- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida
INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk)
SELECT ticketFk, problem, saleFk
@@ -66861,7 +67188,7 @@ BEGIN
JOIN vn.itemType it on it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) >= s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
AND s.quantity > 0
@@ -66874,7 +67201,7 @@ BEGIN
AND t.warehouseFk = vWarehouseFk
GROUP BY tl.ticketFk) sub
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
-
+
-- Retraso: Disponible suficiente, pero no visible ni ubicado
INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk)
SELECT ticketFk, problem, saleFk
@@ -66888,7 +67215,7 @@ BEGIN
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) < s.quantity
AND IFNULL(av.available ,0) >= s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
@@ -66908,13 +67235,13 @@ BEGIN
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
SELECT ticketFk, problem, saleFk
FROM (
- SELECT
- tl.ticketFk,
+ SELECT
+ tl.ticketFk,
s.id saleFk ,
- LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem,
+ LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem,
MOD(s.quantity, b.`grouping`) hasRounding
FROM tmp.ticket_list tl
- JOIN ticket t ON t.id = tl.ticketFk
+ JOIN ticket t ON t.id = tl.ticketFk
AND t.warehouseFk = vWarehouseFk
JOIN sale s ON s.ticketFk = tl.ticketFk
JOIN item i ON i.id = s.itemFk
@@ -66922,12 +67249,12 @@ BEGIN
JOIN buy b ON b.id = bu.buyFk
GROUP BY tl.ticketFk
HAVING hasRounding
- ) sub
+ ) sub
ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk;
END LOOP;
CLOSE vCursor;
-
+
INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked)
SELECT DISTINCT tl.ticketFk, FALSE
FROM tmp.ticket_list tl
@@ -66944,6 +67271,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_getProblemsByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66951,22 +67280,20 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1))
BEGIN
/**
- * Calcula los problemas de cada venta
+ * Calcula los problemas de cada venta
* para un conjunto de tickets.
*
* @return Problems result
*/
DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems;
- CREATE TEMPORARY TABLE tmp.sale_getProblems
+ CREATE TEMPORARY TABLE tmp.sale_getProblems
(INDEX (ticketFk))
ENGINE = MEMORY
- SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped
+ SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped
FROM ticket t
WHERE t.id = vTicketFk;
@@ -66983,6 +67310,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_PriceFix` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66990,12 +67319,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT)
BEGIN
-
+
DELETE sc.*
FROM vn.saleComponent sc
JOIN vn.sale s ON s.id = sc.saleFk
@@ -67018,6 +67345,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_recalcComponent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67025,58 +67354,56 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption INT)
proc: BEGIN
/**
- * Este procedimiento recalcula los componentes de un conjunto de sales,
+ * Este procedimiento recalcula los componentes de un conjunto de sales,
* eliminando los componentes existentes e insertandolos de nuevo
*
* @param vOption si no se quiere forzar llamar con NULL
* @table tmp.recalculateSales (id)
- */
- DECLARE vShipped DATE;
+ */
+ DECLARE vShipped DATE;
DECLARE vWarehouseFk SMALLINT;
DECLARE vAgencyModeFk INT;
DECLARE vAddressFk INT;
DECLARE vTicketFk INT;
- DECLARE vLanded DATE;
+ DECLARE vLanded DATE;
DECLARE vIsEditable BOOLEAN;
DECLARE vZoneFk INTEGER;
DECLARE vDone BOOL DEFAULT FALSE;
-
+
DECLARE vCur CURSOR FOR
SELECT DISTINCT s.ticketFk
FROM tmp.recalculateSales rs
JOIN vn.sale s ON s.id = rs.id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
OPEN vCur;
l: LOOP
SET vDone = FALSE;
- FETCH vCur INTO vTicketFk;
-
+ FETCH vCur INTO vTicketFk;
+
IF vDone THEN
LEAVE l;
END IF;
- SELECT (hasToRecalcPrice OR ts.alertLevel IS NULL) AND t.refFk IS NULL,
- t.zoneFk,
- t.warehouseFk,
- t.shipped,
- t.addressFk,
- t.agencyModeFk,
+ SELECT (hasToRecalcPrice OR ts.alertLevel IS NULL) AND t.refFk IS NULL,
+ t.zoneFk,
+ t.warehouseFk,
+ t.shipped,
+ t.addressFk,
+ t.agencyModeFk,
t.landed
- INTO vIsEditable,
- vZoneFk,
- vWarehouseFk,
- vShipped,
- vAddressFk,
- vAgencyModeFk,
+ INTO vIsEditable,
+ vZoneFk,
+ vWarehouseFk,
+ vShipped,
+ vAddressFk,
+ vAgencyModeFk,
vLanded
FROM ticket t
LEFT JOIN ticketState ts ON t.id = ts.ticket
@@ -67084,31 +67411,31 @@ proc: BEGIN
WHERE t.id = vTicketFk;
CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
-
- IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN
- CALL util.throw('There is no zone for these parameters');
+
+ IF NOT EXISTS (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN
+ CALL util.throw(CONCAT('There is no zone for these parameters ', vTicketFk));
END IF;
-
+
IF vLanded IS NULL OR vZoneFk IS NULL THEN
-
+
UPDATE ticket t
- SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
+ SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
WHERE t.id = vTicketFk AND t.landed IS NULL;
-
+
IF vZoneFk IS NULL THEN
SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
UPDATE ticket t
SET t.zoneFk = vZoneFk
WHERE t.id = vTicketFk AND t.zoneFk IS NULL;
END IF;
-
+
END IF;
-
+
DROP TEMPORARY TABLE tmp.zoneGetLanded;
-
- -- rellena la tabla buyUltimate con la ultima compra
- CALL buyUltimate (vWarehouseFk, vShipped);
-
+
+ -- rellena la tabla buyUltimate con la ultima compra
+ CALL buyUltimate (vWarehouseFk, vShipped);
+
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouseFk warehouseFk
@@ -67116,7 +67443,7 @@ proc: BEGIN
JOIN tmp.recalculateSales rs ON s.id = rs.id
WHERE s.ticketFk = vTicketFk;
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticketLot
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketLot
SELECT vWarehouseFk warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk
FROM sale s
JOIN tmp.recalculateSales rs ON s.id = rs.id
@@ -67130,15 +67457,15 @@ proc: BEGIN
IF vOption IS NULL THEN
SET vOption = IF(vIsEditable, 1, 6);
END IF;
-
- CALL ticketComponentUpdateSale(vOption);
+
+ CALL ticketComponentUpdateSale(vOption);
CALL catalog_componentPurge();
-
+
DROP TEMPORARY TABLE tmp.buyUltimate;
DROP TEMPORARY TABLE tmp.sale;
-
+
END LOOP;
- CLOSE vCur;
+ CLOSE vCur;
END ;;
DELIMITER ;
@@ -67146,6 +67473,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollectionSaleGroup_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67153,28 +67482,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT)
BEGIN
/**
- * Inserta un nuevo registro en vn.sectorCollectionSaleGroup
+ * Inserta un nuevo registro en vn.sectorCollectionSaleGroup
* Actualiza el usuario en vn.saleGroup y reemplaza los registros de vn.saleTracking
- *
+ *
* @param vSaleGroupFk Identificador de vn.saleGroup
* @param vSectorCollectionFk Identificador de vn.sectorCollection
*/
REPLACE sectorCollectionSaleGroup
- SET sectorCollectionFk = vSectorCollectionFk,
+ SET sectorCollectionFk = vSectorCollectionFk,
saleGroupFk = vSaleGroupFk;
-
+
UPDATE saleGroup sg
JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id
JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk
- SET sg.userFk = sc.userFk
+ SET sg.userFk = sc.userFk
WHERE sg.id = vSaleGroupFk;
-
+
INSERT IGNORE saleTracking(
saleFk,
isChecked,
@@ -67186,8 +67513,8 @@ BEGIN
sc.userFk,
s.id
FROM saleGroupDetail sgd
- JOIN sectorCollectionSaleGroup scsg
- ON scsg.saleGroupFk = sgd.saleGroupFk
+ JOIN sectorCollectionSaleGroup scsg
+ ON scsg.saleGroupFk = sgd.saleGroupFk
JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk
JOIN state s ON s.code = 'PREVIOUS_PREPARATION'
WHERE sgd.saleGroupFk = vSaleGroupFk;
@@ -67197,6 +67524,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67204,8 +67533,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`()
BEGIN
@@ -67232,6 +67559,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_getSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67239,8 +67568,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_getSale`(vSelf INT)
BEGIN
@@ -67277,6 +67604,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67284,40 +67613,40 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT)
-BEGIN
-/**
- * Inserta una nueva colección, si el usuario no tiene ninguna vacia.
- * Esto se hace para evitar que por error se generen colecciones sin sentido.
- *
- * @param vSectorFk Identificador de #vn.sector
- */
- DECLARE hasEmptyCollections BOOL;
- DECLARE vUserFk INT;
-
- SET vUserFk = account.myUser_getId();
-
- SELECT (COUNT(sc.id) > 0) INTO hasEmptyCollections
- FROM vn.sectorCollection sc
- LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
- WHERE ISNULL(scsg.id)
- AND sc.userFk = vUserFk
- AND sc.sectorFk = vSectorFk
- AND sc.created >= util.VN_CURDATE();
-
- IF NOT hasEmptyCollections THEN
- INSERT INTO vn.sectorCollection(userFk, sectorFk)
- VALUES(vUserFk, vSectorFk);
- END IF;
+BEGIN
+/**
+ * Inserta una nueva colección, si el usuario no tiene ninguna vacia.
+ * Esto se hace para evitar que por error se generen colecciones sin sentido.
+ *
+ * @param vSectorFk Identificador de #vn.sector
+ */
+ DECLARE hasEmptyCollections BOOL;
+ DECLARE vUserFk INT;
+
+ SET vUserFk = account.myUser_getId();
+
+ SELECT (COUNT(sc.id) > 0) INTO hasEmptyCollections
+ FROM vn.sectorCollection sc
+ LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
+ WHERE ISNULL(scsg.id)
+ AND sc.userFk = vUserFk
+ AND sc.sectorFk = vSectorFk
+ AND sc.created >= util.VN_CURDATE();
+
+ IF NOT hasEmptyCollections THEN
+ INSERT INTO vn.sectorCollection(userFk, sectorFk)
+ VALUES(vUserFk, vSectorFk);
+ END IF;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorProductivity_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67325,8 +67654,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorProductivity_add`()
BEGIN
@@ -67405,6 +67732,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sector_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67412,8 +67741,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_get`()
BEGIN
@@ -67431,6 +67758,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sector_getWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67438,8 +67767,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_getWarehouse`(vSectorFk INT)
BEGIN
@@ -67447,13 +67774,15 @@ BEGIN
SELECT s.warehouseFk
FROM vn.sector s
WHERE s.id = vSectorFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `setParking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67461,8 +67790,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8))
proc: BEGIN
@@ -67528,6 +67855,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelvingChange` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67535,23 +67864,23 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8))
BEGIN
UPDATE vn.itemShelving
- SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci
- WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci;
-
-
+ SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci
+ WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci;
+
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelvingLog_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67559,21 +67888,19 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingLog_get`(shelvingFk VARCHAR(10))
BEGIN
-
+
/* Lista el log de un carro
- *
+ *
* @param shelvingFk matrícula del carro
- *
+ *
*/
-
+
SELECT originFk, name, creationDate, description
FROM shelvingLog sl
- JOIN account.user u ON u.id = sl.userFk
+ JOIN account.user u ON u.id = sl.userFk
WHERE sl.originFk = shelvingFk COLLATE utf8_general_ci
ORDER BY creationDate DESC;
@@ -67583,6 +67910,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelvingParking_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67590,28 +67919,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT)
BEGIN
-
-SELECT s.itemFk,
+
+SELECT s.itemFk,
s.concept,
- CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
- CAST(IFNULL(ist.visible,0) AS DECIMAL(10,0)) as aparcado
+ CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
+ CAST(IFNULL(ist.visible,0) AS DECIMAL(10,0)) as aparcado
FROM vn.sale s
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
- WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk
HAVING sinServir > aparcado;
-
+
END ;;
DELIMITER ;
@@ -67619,6 +67946,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelvingPriority_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67626,8 +67955,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10))
BEGIN
@@ -67640,6 +67967,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelving_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67647,8 +67976,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_clean`()
BEGIN
@@ -67656,12 +67983,12 @@ BEGIN
DELETE FROM vn.shelving
WHERE length(code) > 3
AND parked < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
-
+
DELETE FROM vn.itemShelving
WHERE visible <= 0
AND created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
- DELETE ish.*
+ DELETE ish.*
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
WHERE sh.parkingFk IS NULL
@@ -67669,12 +67996,12 @@ BEGIN
UPDATE vn.shelving sh
LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code`
- SET isPrinted = 0,
+ SET isPrinted = 0,
parkingFk = NULL
WHERE its.id IS NULL
- AND sh.isRecyclable
- AND ( sh.parked IS NULL
- OR
+ AND sh.isRecyclable
+ AND ( sh.parked IS NULL
+ OR
sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())
);
@@ -67684,6 +68011,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelving_getSpam` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67691,8 +68020,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT)
BEGIN
@@ -67781,6 +68108,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelving_setParking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67788,8 +68117,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT)
proc: BEGIN
@@ -67817,6 +68144,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sleep_X_min` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67824,8 +68153,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sleep_X_min`()
BEGIN
@@ -67839,6 +68166,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `solunionRiskRequest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67846,25 +68175,23 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `solunionRiskRequest`()
BEGIN
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
CREATE TEMPORARY TABLE tmp.client_list
(PRIMARY KEY (Id_Cliente))
ENGINE = MEMORY
- SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
+ SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
WHERE dateEnd IS NULL
ORDER BY ci.creationDate DESC
LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
-
+
CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
-
- SELECT
+
+ SELECT
c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo,
cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo,
f.Consumo consumo_anual, c.Vencimiento, ci.grade
@@ -67874,7 +68201,7 @@ BEGIN
JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente
GROUP BY Id_cliente;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
END ;;
@@ -67883,6 +68210,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67890,8 +68219,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorker`(
vDate DATE,
@@ -67942,6 +68269,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockBuyed_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67949,62 +68278,75 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`(vDated DATE)
BEGIN
/**
- * Inserta el volumen de compra por comprador en vn.stockBuyed de acuerdo con la fecha
+ * Inserta el volumen de compra por comprador en stockBuyed de acuerdo con la fecha
*
* @param vDated Fecha de compra
*/
- CALL vn.stockTraslation(vDated);
- DELETE
- FROM vn.stockBuyed
- WHERE `date` = vDated;
+ CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
+ (INDEX (userFk))
+ ENGINE = MEMORY
+ SELECT requested, reserved, userFk
+ FROM stockBuyed
+ WHERE dated = vDated;
- INSERT INTO vn.stockBuyed(`user`, buyed, `date`, description)
+ CALL stockTraslation(vDated);
+
+ INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
SELECT it.workerFk,
- SUM(( ti.amount / b.packing ) * vn.buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed,
+ SUM(( ti.amount / b.packing ) * buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed,
vDated,
u.name
FROM tmp.item ti
- JOIN vn.item i ON i.id = ti.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.warehouse wh ON wh.code = 'VNH'
+ JOIN item i ON i.id = ti.item_id
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ JOIN warehouse wh ON wh.code = 'VNH'
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id
- JOIN vn.buy b ON b.id = bu.buyFk
- JOIN vn.volumeConfig vc
+ JOIN buy b ON b.id = bu.buyFk
+ JOIN volumeConfig vc
JOIN account.`user` u ON u.id = it.workerFk
- WHERE ic.display != 0
+ WHERE ic.display <> 0
GROUP BY it.workerFk;
- INSERT INTO stockBuyed(buyed, `date`, description)
- SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, IF(c.country = 'España',p.name,c.country) destiny
- FROM vn.itemTicketOut ito
- JOIN vn.ticket t ON t.id = ito.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.warehouse wh ON wh.id = t.warehouseFk
- JOIN vn.itemCost ic ON ic.itemFk = ito.itemFk AND ic.warehouseFk = t.warehouseFk
- JOIN vn.volumeConfig vc
+ INSERT INTO stockBuyed(buyed, dated, description)
+ SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000),
+ vDated,
+ IF(c.country = 'España',p.name,c.country) destiny
+ FROM itemTicketOut ito
+ JOIN ticket t ON t.id = ito.ticketFk
+ JOIN `address` a ON a.id = t.addressFk
+ JOIN province p ON p.id = a.provinceFk
+ JOIN country c ON c.id = p.countryFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN itemCost ic ON ic.itemFk = ito.itemFk AND ic.warehouseFk = t.warehouseFk
+ JOIN volumeConfig vc
WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated)
AND wh.code = 'VNH'
GROUP BY destiny;
+ UPDATE stockBuyed s
+ JOIN tStockBuyed ts ON ts.userFk = s.userFk
+ SET s.requested = ts.requested,
+ s.reserved = ts.reserved
+ WHERE s.dated = vDated;
+
DROP TEMPORARY TABLE
tmp.buyUltimate,
- tmp.item;
+ tmp.item,
+ tStockBuyed;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68012,8 +68354,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockTraslation`(vDate DATE)
BEGIN
@@ -68025,7 +68365,7 @@ BEGIN
*/
DECLARE vAuctionWarehouseFk INT;
- DELETE FROM stockBuyed WHERE `date` = vDate;
+ DELETE FROM stockBuyed WHERE dated = vDate;
SELECT warehouseFk INTO vAuctionWarehouseFk
FROM auctionConfig;
@@ -68059,6 +68399,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `subordinateGetList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68066,8 +68408,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `subordinateGetList`(vBossFk INT)
BEGIN
@@ -68076,10 +68416,10 @@ BEGIN
DECLARE vBossId INT;
DECLARE vDone BOOL;
DECLARE workerCur CURSOR FOR
- SELECT workerFk
- FROM tmp.subordinate
+ SELECT workerFk
+ FROM tmp.subordinate
WHERE NOT isChecked;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR 1062 BEGIN
@@ -68087,29 +68427,29 @@ BEGIN
END;
DROP TEMPORARY TABLE IF EXISTS tmp.subordinate;
-
+
CREATE TEMPORARY TABLE tmp.subordinate
(PRIMARY KEY (workerFk))
ENGINE = MEMORY
SELECT vBossFk AS workerFk, 0 AS isChecked;
-
+
WHILE (SELECT COUNT(*) FROM tmp.subordinate WHERE NOT isChecked) > 0 DO
OPEN workerCur;
workerLoop: LOOP
SET vDone = FALSE;
FETCH workerCur INTO vBossId;
-
+
IF vDone THEN
LEAVE workerLoop;
END IF;
-
- INSERT INTO tmp.subordinate
- SELECT id, 0
- FROM worker
+
+ INSERT INTO tmp.subordinate
+ SELECT id, 0
+ FROM worker
WHERE bossFk = vBossId;
-
- UPDATE tmp.subordinate
+
+ UPDATE tmp.subordinate
SET isChecked = 1
WHERE workerFk = vBossId;
END LOOP;
@@ -68122,6 +68462,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplierExpenses` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68129,8 +68471,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierExpenses`(vEnded DATE)
BEGIN
@@ -68149,13 +68489,13 @@ BEGIN
-- Calcula el balance inicial y final de cada proveedor
INSERT INTO openingBalance
SELECT MAX(dueDated),
- supplierFk,
- companyFk,
+ supplierFk,
+ companyFk,
sum(amount) eurAmount,
sum(divisa) foreignAmount
FROM (
SELECT p.dueDated,
- p.supplierFk,
+ p.supplierFk,
p.companyFk,
p.amount,
p.divisa
@@ -68171,7 +68511,7 @@ BEGIN
SELECT iidd.dueDated,
ii.supplierFk,
ii.companyFk,
- - iidd.amount,
+ - iidd.amount,
- iidd.foreignValue
FROM invoiceIn ii
JOIN invoiceInDueDay iidd ON ii.id = iidd.invoiceInFk
@@ -68179,14 +68519,14 @@ BEGIN
JOIN company co ON co.id = ii.companyFk
WHERE iidd.dueDated > '2014-12-31'
AND iidd.dueDated <= vEnded
- AND ii.isBooked AND co.`code` = 'VNL'
+ AND ii.isBooked AND co.`code` = 'VNL'
AND c.`code` <> 'EUR'
UNION ALL
SELECT se.dueDated,
se.supplierFk,
se.companyFk,
- - se.amount,
+ - se.amount,
0
FROM supplierExpense se
JOIN currency c ON c.id = se.currencyFk
@@ -68196,7 +68536,7 @@ BEGIN
AND co.`code` = 'VNL' AND c.`code` <> 'EUR'
) sub
GROUP BY companyFk, supplierFk;
-
+
SELECT ob.dueDated
, ob.supplierFk
, ob.companyFk
@@ -68214,6 +68554,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplierPackaging_ReportSource` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68221,71 +68563,62 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierPackaging_ReportSource`(vFromDated DATE, vSupplierFk INT)
BEGIN
-
/**
- * Selecciona los embalajes de un proveedor a partir de una fecha
- *
- * @param vFromDated Fecha de la que partir
- * @param vSupplierFk Id del proveedor
- */
-
+* Selecciona los embalajes de un proveedor a partir de una fecha
+*
+* @param vFromDated Fecha de la que partir
+* @param vSupplierFk Id del proveedor
+*/
DECLARE vCounter INT DEFAULT 0;
DECLARE vMaxRow INT DEFAULT 0;
DECLARE vItemFk INT DEFAULT 0;
- SET @vRowNumber = 0;
SET @vBalance = 0;
- DROP TEMPORARY TABLE IF EXISTS tmp.supplierPackagingList;
- CREATE TEMPORARY TABLE tmp.supplierPackagingList
- SELECT itemFk,
- @vRowNumber:= @vRowNumber + 1 `row`
+ CREATE OR REPLACE TEMPORARY TABLE tSupplierPackagingList
+ SELECT ROW_NUMBER() OVER(ORDER BY landed) `row`,
+ itemFk,
+ entryFk
FROM (
- SELECT *
- FROM (
- SELECT supplierFk,
- itemFk,
- longName,
- supplier,
- entryFk,
- landed,
- `out`,
- `in`,
- warehouse,
- buyingValue
- FROM supplierPackaging
- WHERE supplierFk = vSupplierFk
- AND landed >= vFromDated
-
- UNION ALL
-
- SELECT vSupplierFk,
- itemFk,
- longName,
- supplier,
- 'previous',
- vFromDated,
- SUM(`out`),
- SUM(`in`),
- NULL,
- buyingValue
- FROM supplierPackaging
- WHERE supplierFk = vSupplierFk
- AND landed < vFromDated
- GROUP BY itemFk) i
+ SELECT supplierFk,
+ itemFk,
+ longName,
+ supplier,
+ entryFk,
+ landed,
+ `out`,
+ `in`,
+ warehouse,
+ buyingValue
+ FROM supplierPackaging
+ WHERE supplierFk = vSupplierFk
+ AND landed >= vFromDated
+ UNION ALL
+ SELECT vSupplierFk,
+ itemFk,
+ longName,
+ supplier,
+ 'previous',
+ vFromDated,
+ SUM(`out`),
+ SUM(`in`),
+ NULL,
+ buyingValue
+ FROM supplierPackaging
+ WHERE supplierFk = vSupplierFk
+ AND landed < vFromDated
GROUP BY itemFk
- ORDER BY landed) i2;
+ ) sub
+ GROUP BY itemFk
+ HAVING entryFk <> 'previous'
+ ORDER BY landed;
- SELECT MAX(`row`)
- INTO vMaxRow
- FROM tmp.supplierPackagingList;
+ SELECT MAX(`row`) INTO vMaxRow
+ FROM tSupplierPackagingList;
- DROP TEMPORARY TABLE IF EXISTS tmp.supplierPackaging;
- CREATE TEMPORARY TABLE tmp.supplierPackaging(
+ CREATE OR REPLACE TEMPORARY TABLE tSupplierPackaging(
supplierFk INT,
itemFk INT,
longName VARCHAR(50),
@@ -68296,24 +68629,23 @@ BEGIN
`out` VARCHAR(50),
warehouse INT,
buyingValue INT,
- balance INT);
+ balance INT
+ );
l1: LOOP
-
+ SET @vBalance = 0;
IF vCounter = vMaxRow THEN
LEAVE l1;
ELSE
SET vCounter = vCounter + 1;
- SET @vBalance = 0;
END IF;
- SELECT itemFk
- INTO vItemFk
- FROM tmp.supplierPackagingList
+ SELECT itemFk INTO vItemFk
+ FROM tSupplierPackagingList
WHERE `row` = vCounter;
- INSERT INTO tmp.supplierPackaging
- SELECT supplierFk,
+ INSERT INTO tSupplierPackaging
+ SELECT supplierFk,
itemFk,
longName,
supplier,
@@ -68325,7 +68657,7 @@ BEGIN
buyingValue,
@vBalance:= (`in` - `out` + @vBalance)
FROM (
- SELECT supplierFk,
+ SELECT supplierFk,
itemFk,
longName,
supplier,
@@ -68339,10 +68671,8 @@ BEGIN
WHERE supplierFk = vSupplierFk
AND landed >= vFromDated
AND itemFk = vItemFk
-
UNION ALL
-
- SELECT vSupplierFk,
+ SELECT vSupplierFk,
itemFk,
longName,
supplier,
@@ -68357,25 +68687,26 @@ BEGIN
AND landed < vFromDated
AND itemFk = vItemFk
GROUP BY itemFk
+ ORDER BY landed
) sub
- WHERE `out` OR `in`
- ORDER BY itemFk, landed;
-
+ WHERE `out` OR `in`;
END LOOP l1;
- SELECT * FROM tmp.supplierPackaging;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.supplierPackagingList;
- DROP TEMPORARY TABLE IF EXISTS tmp.supplierPackaging;
- SET @vRowNumber = 0;
- SET @vBalance = 0;
+ SELECT *
+ FROM tSupplierPackaging
+ ORDER BY itemFk, landed;
+ DROP TEMPORARY TABLE IF EXISTS
+ tSupplierPackaging,
+ tSupplierPackagingList;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplier_checkBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68383,8 +68714,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL)
BEGIN
@@ -68421,7 +68750,7 @@ BEGIN
- SUM(iid.amount) mysql,
0 sage
FROM invoiceInDueDay iid
- JOIN invoiceIn ii ON ii.id = iid.invoiceInFk
+ JOIN invoiceIn ii ON ii.id = iid.invoiceInFk
WHERE IFNULL(ii.bookEntried, ii.issued) BETWEEN vDateFrom AND vDateTo
AND ii.isBooked
GROUP BY ii.id
@@ -68463,6 +68792,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplier_checkIsActive` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68470,8 +68801,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkIsActive`(vSelf INT)
BEGIN
@@ -68493,6 +68822,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplier_disablePayMethodChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68500,8 +68831,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`()
BEGIN
@@ -68529,6 +68858,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `test` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68536,8 +68867,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
@@ -68548,6 +68877,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketBoxesView` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68555,20 +68886,18 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBoxesView`(IN vTicketFk INT)
BEGIN
-
- SELECT s.id,
- s.itemFk,
- s.concept,
- floor(s.quantity / b.packing) as Cajas,
- b.packing,
- s.isPicked,
+
+ SELECT s.id,
+ s.itemFk,
+ s.concept,
+ floor(s.quantity / b.packing) as Cajas,
+ b.packing,
+ s.isPicked,
i.size
- FROM ticket t
+ FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
JOIN cache.last_buy lb on lb.warehouse_id = t.warehouseFk AND lb.item_id = s.itemFk
@@ -68579,13 +68908,15 @@ BEGIN
AND p.isBox
GROUP BY s.itemFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketBuiltTime` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68593,15 +68924,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBuiltTime`(vDate DATE)
BEGIN
DECLARE vDateStart DATETIME DEFAULT DATE(vDate);
DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate);
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketBuiltTime;
CREATE TEMPORARY TABLE tmp.ticketBuiltTime
@@ -68614,7 +68943,7 @@ BEGIN
SELECT ticketFk, builtTime
FROM
(
- SELECT
+ SELECT
ticketFk,
created as builtTime
FROM
@@ -68622,13 +68951,13 @@ BEGIN
WHERE created BETWEEN vDateStart AND vDateEnd
ORDER BY ticketFk, created DESC
LIMIT 10000000000000000000
- ) sub
+ ) sub
GROUP BY ticketFk
) sub2 ON sub2.ticketFk = t.id
WHERE t.shipped BETWEEN vDate AND util.dayEnd(vDate)
AND t.clientFk NOT IN (50,400,200)
AND t.companyFk = 442
-
+
;
END ;;
@@ -68637,6 +68966,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateClon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68644,8 +68975,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
BEGIN
@@ -68657,36 +68986,38 @@ BEGIN
*/
REPLACE INTO orderTicket(orderFk,ticketFk)
- SELECT orderFk, vTicketNew
- FROM orderTicket
+ SELECT orderFk, vTicketNew
+ FROM orderTicket
WHERE ticketFk = vTicketOld;
-
+
-- Bionizamos lineas con Preu = 0
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
(PRIMARY KEY (id)) ENGINE = MEMORY
- SELECT id
+ SELECT id
FROM sale
WHERE ticketFk = vTicketNew AND price = 0;
-
+
CALL sale_recalcComponent(1);
-- Bionizamos lineas con Preu > 0
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
(PRIMARY KEY (id)) ENGINE = MEMORY
- SELECT id
+ SELECT id
FROM sale
WHERE ticketFk = vTicketNew AND price > 0;
-
+
CALL sale_recalcComponent(6);
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateFromType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68694,8 +69025,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded DATE,
vAddressFk INT,
@@ -68703,12 +69032,12 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded D
vTypeFk INT)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.item;
- CREATE TEMPORARY TABLE tmp.item
- (INDEX (itemFk))
- ENGINE = MEMORY
+ CREATE TEMPORARY TABLE tmp.item
+ (INDEX (itemFk))
+ ENGINE = MEMORY
SELECT id itemFk FROM vn.item
WHERE typeFk = vTypeFk;
-
+
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.ticketLot;
@@ -68718,6 +69047,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculatePurge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68725,12 +69056,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculatePurge`()
BEGIN
- DROP TEMPORARY TABLE
+ DROP TEMPORARY TABLE
tmp.ticketCalculateItem,
tmp.ticketComponentPrice,
tmp.ticketComponent,
@@ -68742,6 +69071,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketClon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68749,67 +69080,67 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE)
BEGIN
-
+
DECLARE done INT DEFAULT FALSE;
- DECLARE vNewTicketFk INT;
+ DECLARE vNewTicketFk INT;
DECLARE vOldSaleFk INT;
DECLARE vNewSaleFk INT;
-
+
DECLARE cur1 CURSOR FOR
SELECT id
FROM vn.sale
WHERE ticketFk = vTicketFk;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
+
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
-
+
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
-
- UPDATE vn.ticket
+
+ UPDATE vn.ticket
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
shipped = vNewShipped
WHERE id = vNewTicketFk;
-
+
OPEN cur1;
-
+
read_loop: LOOP
-
+
FETCH cur1 INTO vOldSaleFk;
-
+
IF done THEN
LEAVE read_loop;
END IF;
-
+
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
FROM vn.sale
WHERE id = vOldSaleFk;
-
+
SELECT max(id) INTO vNewSaleFk
FROM vn.sale
WHERE ticketFk = vNewTicketFk;
-
+
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
SELECT vNewSaleFk, componentFk, value, isGreuge
FROM vn.saleComponent
WHERE saleFk = vOldSaleFk;
-
+
END LOOP;
CLOSE cur1;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketClon_OneYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68817,26 +69148,24 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon_OneYear`(vTicketFk INT)
BEGIN
DECLARE vShipped DATE;
DECLARE vMaxDated DATE;
-
- SELECT shipped, TIMESTAMPADD(YEAR,1,shipped)
+
+ SELECT shipped, TIMESTAMPADD(YEAR,1,shipped)
INTO vShipped, vMaxDated
FROM vn.ticket
WHERE id = vTicketFk;
-
+
WHILE vShipped <= vMaxDated DO
-
+
SET vShipped = TIMESTAMPADD(WEEK, 1, vShipped);
-
+
CALL vn.ticketClon(vTicketFk, vShipped);
-
+
END WHILE;
END ;;
@@ -68845,6 +69174,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68852,22 +69183,22 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_get`(vTicketFk INT)
BEGIN
- SELECT tc.collectionFk
+ SELECT tc.collectionFk
FROM vn.ticketCollection tc
WHERE ticketFk = vTicketFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_setUsedShelves` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68875,29 +69206,29 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT)
BEGIN
-
+
/*
* Inserta número de baldas que ocupa un ticket
- *
+ *
* @param vTicketFk Identificador de ticket
* @param vUsedShelves Número de baldas
*/
-
+
UPDATE ticketCollection tc
SET tc.usedShelves = vUsedShelves
WHERE tc.ticketFk = vTicketFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68905,8 +69236,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdate`(
vTicketFk INT,
@@ -68929,18 +69258,18 @@ BEGIN
END;
START TRANSACTION;
-
+
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
-
- UPDATE ticket t
+
+ UPDATE ticket t
JOIN address a ON a.id = vAddressFk
SET t.nickname = a.nickname
WHERE t.id = vTicketFk;
-
+
END IF;
-
+
UPDATE ticket t
- SET
+ SET
t.clientFk = vClientFk,
t.agencyModeFk = vAgencyModeFk,
t.addressFk = vAddressFk,
@@ -68951,12 +69280,12 @@ BEGIN
t.isDeleted = vIsDeleted
WHERE
t.id = vTicketFk;
-
+
IF vHasToBeUnrouted THEN
UPDATE ticket t SET t.routeFk = NULL
WHERE t.id = vTicketFk;
END IF;
-
+
IF vOption <> 8 THEN
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
@@ -68976,6 +69305,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdateSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68983,8 +69314,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdateSale`(vOption INT)
BEGIN
@@ -68998,104 +69327,104 @@ BEGIN
DECLARE vComponentFk INT;
DECLARE vRenewComponents BOOLEAN;
DECLARE vKeepPrices BOOLEAN;
-
+
CASE vOption
- WHEN 1 THEN
+ WHEN 1 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = FALSE;
WHEN 2 THEN
- SELECT id INTO vComponentFk FROM component WHERE `code` = 'debtCollection';
+ SELECT id INTO vComponentFk FROM component WHERE `code` = 'debtCollection';
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
- WHEN 3 THEN
- SELECT id INTO vComponentFk FROM component WHERE `code` = 'mana';
+ WHEN 3 THEN
+ SELECT id INTO vComponentFk FROM component WHERE `code` = 'mana';
+ SET vRenewComponents = TRUE;
+ SET vKeepPrices = TRUE;
+ WHEN 4 THEN
+ SELECT id INTO vComponentFk FROM component WHERE `code` = 'buyerDiscount';
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
- WHEN 4 THEN
- SELECT id INTO vComponentFk FROM component WHERE `code` = 'buyerDiscount';
- SET vRenewComponents = TRUE;
- SET vKeepPrices = TRUE;
- /* WHEN 5 THEN
+ /* WHEN 5 THEN
SET vComponentFk = 35;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;*/
- WHEN 6 THEN
+ WHEN 6 THEN
SELECT id INTO vComponentFk FROM component WHERE `code` = 'imbalance';
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 7 THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3)
+ SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
+ LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
-
+
REPLACE INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3)
+ SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
+ LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
-
+
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
WHEN 8 THEN
- DELETE sc.*
+ DELETE sc.*
FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk;
-
+
REPLACE INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3)
+ SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id;
-
+
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
- WHEN 9 THEN
+ WHEN 9 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
END CASE;
IF vRenewComponents THEN
- DELETE sc.*
- FROM tmp.sale tmps
+ DELETE sc.*
+ FROM tmp.sale tmps
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
JOIN `component` c ON c.id = sc.componentFk
WHERE c.isRenewable;
-
+
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, tc.componentFk, tc.cost
- FROM sale s
+ FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
- AND sc.componentFk = tc.componentFk
- LEFT JOIN `component` c ON c.id = tc.componentFk
+ LEFT JOIN saleComponent sc ON sc.saleFk = s.id
+ AND sc.componentFk = tc.componentFk
+ LEFT JOIN `component` c ON c.id = tc.componentFk
WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE);
-
- -- Añadir componente venta por paquete
+
+ -- Añadir componente venta por paquete
DROP TEMPORARY TABLE IF EXISTS tmp.sale2;
CREATE TEMPORARY TABLE tmp.sale2
(PRIMARY KEY (saleFk))
- ENGINE = MEMORY
+ ENGINE = MEMORY
SELECT * FROM tmp.sale;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent2;
CREATE TEMPORARY TABLE tmp.ticketComponent2
- SELECT * FROM tmp.ticketComponent;
-
- REPLACE INTO saleComponent(saleFk, componentFk, value)
+ SELECT * FROM tmp.ticketComponent;
+
+ REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT t.id, t.componentFk, t.cost
FROM (
SELECT s.id, tc.componentFk, tc.cost, MOD(s.quantity, b.packing) as resto
FROM vn.sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
- JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id
+ JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id
JOIN vn.buy b ON b.id = buy_id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
- JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage'
+ JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage'
LEFT JOIN (
SELECT s.id
FROM vn.sale s
@@ -69106,8 +69435,8 @@ BEGIN
) tp ON tp.id = s.id
WHERE tp.id IS NULL
HAVING resto <> 0) t;
-
- DROP TEMPORARY TABLE IF EXISTS
+
+ DROP TEMPORARY TABLE IF EXISTS
tmp.sale2,
tmp.ticketComponent2;
END IF;
@@ -69125,26 +69454,26 @@ BEGIN
UPDATE sale s
JOIN item i on i.id = s.itemFk
JOIN itemType it on it.id = i.typeFk
- JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
+ JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.price = sumValue / ((100 - s.discount) / 100)
- WHERE it.code != 'PRT' ;
-
+ WHERE it.code != 'PRT' ;
+
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk != 21
- GROUP BY s.id
+ GROUP BY s.id
HAVING ROUND(saleValue, 4) <> 0;
END IF;
-
+
UPDATE sale s
JOIN (
- SELECT SUM(sc.value) sumValue, sc.saleFk
+ SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN `component` c ON c.id = sc.componentFk
@@ -69158,10 +69487,10 @@ BEGIN
JOIN sale s on s.id = sc.saleFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
- WHERE it.code = 'PRT';
-
+ WHERE it.code = 'PRT';
+
INSERT INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, 15, s.price
+ SELECT s.id, 15, s.price
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN item i ON i.id = s.itemFK
@@ -69173,6 +69502,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketDown_PrintableSelection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69180,8 +69511,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketDown_PrintableSelection`(vSectorFk INT)
BEGIN
@@ -69208,6 +69537,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketGetTaxAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69215,8 +69546,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT)
BEGIN
@@ -69228,30 +69557,32 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket
ENGINE = MEMORY
SELECT vTicketFk ticketFk;
-
+
CALL vn.ticket_getTax(NULL);
- SELECT
+ SELECT
tt.ticketFk,
CAST(tt.taxableBase AS DECIMAL(10, 2)) AS taxableBase,
CAST(tt.rate * tt.taxableBase / 100 AS DECIMAL(10, 2)) AS tax,
- pgc.*,
+ pgc.*,
CAST(IF(pe.equFk IS NULL, taxableBase, 0) AS DECIMAL(10, 2)) AS Base,
pgc.rate / 100 as vatPercent
FROM tmp.ticketTax tt
JOIN vn.pgc ON pgc.code = tt.pgcFk
LEFT JOIN vn.pgcEqu pe ON pe.equFk = pgc.code;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketGetTax_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69259,8 +69590,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax_new`()
READS SQL DATA
@@ -69283,29 +69612,29 @@ BEGIN
JOIN ticket t ON t.id = tmpTicket.ticketFk;
CALL addressTaxArea ();
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
CREATE TEMPORARY TABLE tmp.ticketTax
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT tmpTicket.ticketFk,
bp.pgcFk,
- SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2)
+ SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2)
) AS taxableBase,
SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2)
) * pgc.rate / 100 AS tax,
tc.code
-
+
FROM tmp.ticket tmpTicket
JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = tmpTicket.ticketFk
JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
+ JOIN tmp.addressTaxArea ata
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN itemTaxCountry itc
+ JOIN itemTaxCountry itc
ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- JOIN bookingPlanner bp
+ JOIN bookingPlanner bp
ON bp.countryFk = su.countryFk
AND bp.taxAreaFk = ata.areaFk
AND bp.taxClassFk = itc.taxClassFk
@@ -69313,7 +69642,7 @@ BEGIN
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tmpTicket.ticketFk, pgc.code
HAVING taxableBase != 0;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
CREATE TEMPORARY TABLE tmp.ticketAmount
(INDEX (ticketFk))
@@ -69324,13 +69653,15 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketGetTotal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69338,14 +69669,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`(vTaxArea VARCHAR(25))
BEGIN
/**
* Calcula el total con IVA para un conjunto de tickets.
- *
+ *
+ * @param vTaxArea
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
* @return tmp.ticketTotal Total para cada ticket
*/
@@ -69361,7 +69691,7 @@ BEGIN
FROM tmp.ticket t
LEFT JOIN tmp.ticketAmount ta ON t.ticketFk = ta.ticketFk
GROUP BY ticketFk;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
END ;;
@@ -69370,6 +69700,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketGetVisibleAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69377,8 +69709,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetVisibleAvailable`(
vTicket INT)
@@ -69416,6 +69746,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketMissed_List` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69423,8 +69755,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketMissed_List`(vTicketFk INT)
BEGIN
@@ -69433,18 +69763,18 @@ BEGIN
DECLARE vParked DATETIME;
DECLARE vLevel INT;
DECLARE vCollectionFk INT;
-
- SELECT IFNULL(`level`,0), IFNULL(collectionFk,0)
+
+ SELECT IFNULL(`level`,0), IFNULL(collectionFk,0)
INTO vLevel, vCollectionFk
FROM vn.ticketCollection
WHERE ticketFk = vTicketFk
LIMIT 1;
-
- SELECT created, parkingFk
+
+ SELECT created, parkingFk
INTO vParked, vParkingFk
FROM vn.ticketParking
WHERE ticketFk = vTicketFk;
-
+
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk
@@ -69471,13 +69801,15 @@ BEGIN
AND sc.isPackagingArea
AND tp.created < vParked
AND t.packages <=> 0);
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketNotInvoicedByClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69485,14 +69817,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
-
+
CREATE TEMPORARY TABLE tmp.ticket
SELECT id ticketFk
FROM ticket
@@ -69502,7 +69832,7 @@ BEGIN
CALL vn.ticketGetTotal(NULL);
- SELECT c.id,
+ SELECT c.id,
c.name as Cliente,
t.shipped as Fecha,
t.id as Id_Ticket,
@@ -69513,7 +69843,7 @@ BEGIN
DROP TEMPORARY TABLE
tmp.ticket,
- tmp.ticketTotal;
+ tmp.ticketTotal;
END ;;
DELIMITER ;
@@ -69521,6 +69851,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketObservation_addNewBorn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69528,32 +69860,32 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT)
BEGIN
-
+
/**
* Inserta observaciones para los tickets con clientes nuevos o recuperados
- *
+ *
* @param vTicketFk Identificador de vn.ticket
*/
-
+
DECLARE vDescription VARCHAR(20) DEFAULT '¡Cliente NUEVO! ';
INSERT INTO vn.ticketObservation(ticketFk, observationTypeFk, description)
SELECT vTicketFk, ot.id, vDescription
FROM vn.observationType ot
WHERE ot.hasNewBornMessage
- ON DUPLICATE KEY UPDATE description = CONCAT(vDescription, ticketObservation.description);
-
+ ON DUPLICATE KEY UPDATE description = CONCAT(vDescription, ticketObservation.description);
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketPackaging_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69561,8 +69893,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackaging_add`(
vClientFk INT,
@@ -69587,7 +69917,7 @@ BEGIN
DECLARE vComponentCost INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vClientId INT;
-
+
DECLARE vCursor CURSOR FOR
SELECT DISTINCT clientFk
FROM (
@@ -69604,31 +69934,31 @@ BEGIN
RESIGNAL;
END;
- SELECT id INTO vWarehouseInventory
- FROM warehouse
+ SELECT id INTO vWarehouseInventory
+ FROM warehouse
WHERE `code`= 'inv';
-
- SELECT id INTO vComponentCost
- FROM component
+
+ SELECT id INTO vComponentCost
+ FROM component
WHERE `code`= 'purchaseValue';
-
- SELECT packagingInvoicingDated INTO vDateStart
- FROM ticketConfig;
-
+
+ SELECT packagingInvoicingDated INTO vDateStart
+ FROM ticketConfig;
+
IF vWarehouseInventory IS NULL THEN
CALL util.throw('Warehouse inventory not set');
END IF;
IF vComponentCost IS NULL THEN
CALL util.throw('Component cost not set');
- END IF;
+ END IF;
SET vDateEnd = vDated + INTERVAL 1 DAY;
-
+
IF NOT vWithoutPeriodGrace THEN
SET vGraceDate = vGraceDate -INTERVAL 1 MONTH;
END IF;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.packagingToInvoice;
CREATE TEMPORARY TABLE tmp.packagingToInvoice
(INDEX (clientFk))
@@ -69641,7 +69971,7 @@ BEGIN
t.clientFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
- JOIN ticket t ON t.id = tp.ticketFk
+ JOIN ticket t ON t.id = tp.ticketFk
JOIN client c ON c.id = t.clientFk
WHERE c.isActive
AND (vClientFk IS NULL OR t.clientFk = vClientFk)
@@ -69649,7 +69979,7 @@ BEGIN
AND (tp.quantity < 0 OR (tp.quantity > 0 AND t.shipped < vGraceDate))
AND tp.quantity
AND p.itemFk;
-
+
OPEN vCursor;
l: LOOP
@@ -69662,25 +69992,25 @@ BEGIN
START TRANSACTION;
CALL ticket_add(
- vClientId,
+ vClientId,
vDateEnd,
- vWarehouseInventory,
- vCompanyFk,
- NULL,
- NULL,
- NULL,
- vDateEnd,
- account.myUser_getId(),
+ vWarehouseInventory,
+ vCompanyFk,
+ NULL,
+ NULL,
+ NULL,
+ vDateEnd,
+ account.myUser_getId(),
TRUE,
vNewTicket);
-
+
INSERT INTO ticketPackaging(ticketFk, packagingFk, quantity, pvp)
SELECT vNewTicket, packagingFk, - SUM(quantity) totalQuantity, price
- FROM tmp.packagingToInvoice
+ FROM tmp.packagingToInvoice
WHERE clientFk = vClientId
GROUP BY packagingFk
HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity < 0);
-
+
INSERT INTO sale(ticketFk, itemFk, concept, quantity, price)
SELECT vNewTicket, pti.itemFk, i.name, SUM(pti.quantity) totalQuantity, pti.price
FROM tmp.packagingToInvoice pti
@@ -69688,12 +70018,12 @@ BEGIN
WHERE pti.clientFk = vClientId
GROUP BY pti.itemFk
HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity > 0);
-
+
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT id, vComponentCost, price
FROM sale
WHERE ticketFk = vNewTicket;
-
+
COMMIT;
END LOOP;
CLOSE vCursor;
@@ -69705,6 +70035,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketParking_findSkipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69712,42 +70044,40 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1))
BEGIN
-
+
/**
* Averigua los tickets que se han saltado por un error en el proceso encajado
* @param vTicketFk Ticket
* @param vItemPackingTypeFk Modo de encajado
* @return un select con los tickets afectados
- */
+ */
DECLARE vParkingFk INT;
DECLARE vParked DATETIME;
DECLARE vLevel INT;
DECLARE vWagon INT;
DECLARE vCollectionFk INT;
-
- SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0)
+
+ SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0)
INTO vLevel, vWagon, vCollectionFk
FROM vn.ticketCollection tc
JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk
WHERE ticketFk = vTicketFk
ORDER BY c.id DESC
LIMIT 1;
-
- SELECT created, parkingFk
+
+ SELECT created, parkingFk
INTO vParked, vParkingFk
FROM vn.ticketParking tp
- JOIN vn.parking p ON p.id = tp.parkingFk
- JOIN vn.sector s ON s.id = p.sectorFk
+ JOIN vn.parking p ON p.id = tp.parkingFk
+ JOIN vn.sector s ON s.id = p.sectorFk
WHERE ticketFk = vTicketFk
AND s.itemPackingTypeFk = vItemPackingTypeFk
AND s.isPackagingArea ;
-
+
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk
@@ -69764,9 +70094,9 @@ BEGIN
AND (
( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked )
OR
- ( tc.collectionFk = vCollectionFk
+ ( tc.collectionFk = vCollectionFk
AND (LEFT(tc.wagon,1) < LEFT(vWagon,1)
- OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1)))
+ OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1)))
)
)
) -- Etiquetas que no se han escaneado y ya estamos con una posterior
@@ -69774,7 +70104,7 @@ BEGIN
(s.alertLevel > 1
AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea
- AND tp.created < vParked
+ AND tp.created < vParked
AND t.packages <=> 0);
END ;;
DELIMITER ;
@@ -69782,6 +70112,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketRefund_beforeUpsert` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69789,8 +70121,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT)
BEGIN
@@ -69813,6 +70143,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketRequest_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69820,17 +70152,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3))
BEGIN
- INSERT INTO vn.ticketRequest(description,
- quantity,
- price,
- ticketFk,
- buyerCode,
+ INSERT INTO vn.ticketRequest(description,
+ quantity,
+ price,
+ ticketFk,
+ buyerCode,
requesterFk)
VALUES(vDescription,
vQuantity,
@@ -69838,13 +70168,15 @@ BEGIN
vTicketFk,
vBuyerCode,
vn.getUser());
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69852,31 +70184,29 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
-
+
/* Modifica el estado de un ticket de hoy
- *
+ *
* @param vTicketFk el id del ticket
* @param vStateCode estado a modificar del ticket
- *
+ *
*/
-
+
DECLARE vAlertLevel INT;
-
- SELECT s.alertLevel INTO vAlertLevel
- FROM state s
- JOIN ticketStateToday tst ON tst.state = s.id
+
+ SELECT s.alertLevel INTO vAlertLevel
+ FROM state s
+ JOIN ticketStateToday tst ON tst.state = s.id
WHERE tst.ticket = vTicketFk
LIMIT 1;
-
+
IF vAlertLevel < 2 THEN
-
+
CALL vn.ticket_setState(vTicketFk, vStateCode);
-
+
END IF;
END ;;
@@ -69885,6 +70215,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketStateUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69892,28 +70224,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
-
+
/*
* @deprecated:utilizar ticket_setState
*/
-
+
DECLARE vAlertLevel INT;
- SELECT s.alertLevel INTO vAlertLevel
+ SELECT s.alertLevel INTO vAlertLevel
FROM vn.state s
JOIN vn.ticketState ts ON ts.stateFk = s.id
WHERE ts.ticketFk = vTicketFk;
-
- IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN
-
+
+ IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN
+
INSERT INTO ticketTracking(stateFk, ticketFk, workerFk)
SELECT id, vTicketFk, account.myUser_getId()
- FROM vn.state
+ FROM vn.state
WHERE `code` = vStateCode collate utf8_unicode_ci;
END IF;
@@ -69924,6 +70254,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByAddress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69931,8 +70263,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByAddress`(
vStarted DATE,
@@ -69960,6 +70290,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69967,8 +70299,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByDate`(
vStarted DATE,
@@ -69996,6 +70326,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByRef` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70003,8 +70335,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15))
BEGIN
@@ -70056,6 +70386,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70063,8 +70395,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_add`(
vClientId INT
@@ -70181,6 +70511,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_administrativeCopy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70188,31 +70520,31 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT)
BEGIN
-
+
INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed)
- SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed
+ SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed
FROM vn.ticket t
JOIN vn.warehouse w ON w.name = 'INVENTARIO'
WHERE t.id = vOriginalTicket;
-
+
SELECT LAST_INSERT_ID() INTO vNewTicket;
INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, price, discount)
- SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount
+ SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount
FROM vn.sale s
WHERE s.ticketFk = vOriginalTicket;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_canAdvance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70220,8 +70552,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
BEGIN
@@ -70351,6 +70681,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_canbePostponed` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70358,8 +70690,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
BEGIN
@@ -70436,6 +70766,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70443,14 +70775,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
BEGIN
/**
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
- *
+ *
* @param vDated Fecha en cuestión
* @param vScopeDays Dias en el futuro a sondear
* @param vLitersMax Volumen máximo de los tickets a catapultar
@@ -70514,6 +70844,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_checkNoComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70521,8 +70853,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME)
BEGIN
@@ -70531,10 +70861,10 @@ BEGIN
* Comprueba que los tickets entre un rango de fechas tienen componentes
* y recalcula sus componentes
*
- * @param vShippedFrom rango inicial de fecha
+ * @param vShippedFrom rango inicial de fecha
* @param vShippedTo rango final de fecha
*/
-
+
CREATE OR REPLACE TEMPORARY TABLE tmp.coste
(primary key (id)) ENGINE = MEMORY
SELECT s.id
@@ -70563,15 +70893,17 @@ BEGIN
AND ic.merchandise;
CALL vn.sale_recalcComponent(1);
-
+
DROP TEMPORARY TABLE tmp.recalculateSales;
- DROP TEMPORARY TABLE tmp.coste;
+ DROP TEMPORARY TABLE tmp.coste;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_Clone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70579,8 +70911,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT)
BEGIN
@@ -70646,6 +70976,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneWeekly` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70653,10 +70985,8 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(vWeek INT)
BEGIN
DECLARE vIsDone BOOL;
DECLARE vLanding DATE;
@@ -70670,56 +71000,67 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vNewTicket INT;
DECLARE vYear INT;
+ DECLARE vSalesPersonFK INT;
+ DECLARE vItemPicker INT;
DECLARE rsTicket CURSOR FOR
- SELECT tt.ticketFk, tt.weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tt.agencyModeFk
- FROM vn.ticketWeekly tt
- JOIN vn.ticket t ON tt.ticketFk = t.id;
+ SELECT tt.ticketFk,
+ tt.weekDay,
+ t.clientFk,
+ t.warehouseFk,
+ t.companyFk,
+ t.addressFk,
+ tt.agencyModeFk
+ FROM ticketWeekly tt
+ JOIN ticket t ON tt.ticketFk = t.id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
- SET vYear = YEAR(util.VN_CURDATE()) + IF(vWeek < WEEK(util.VN_CURDATE()),1, 0);
+ SET vYear = YEAR(util.VN_CURDATE()) + IF(vWeek < WEEK(util.VN_CURDATE()),1, 0);
OPEN rsTicket;
myLoop: LOOP
BEGIN
DECLARE vSalesPersonEmail VARCHAR(150);
- DECLARE vMailSent BOOL;
+ DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
-
+
SET vIsDone = FALSE;
FETCH rsTicket INTO vTicketFk, vWeekDay, vClientFk, vWarehouseFk, vCompanyFk, vAddressFk, vAgencyModeFk;
IF vIsDone THEN
LEAVE myLoop;
END IF;
-
- SELECT dated INTO vShipment
+
+ SELECT dated INTO vShipment
FROM `time`
WHERE `year` = vYear AND `week` = vWeek
AND WEEKDAY(dated) = vWeekDay;
-- busca si el ticket ya ha sido clonado
- IF (SELECT COUNT(*) FROM vn.ticket tOrig
- JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk
- JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id
- JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk
- JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk
- WHERE tOrig.id = vTicketFk AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) > 0
+ IF EXISTS (SELECT TRUE FROM ticket tOrig
+ JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk
+ JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id
+ JOIN sale saleClon ON saleClon.id = sc.saleClonedFk
+ JOIN ticket tClon ON tClon.id = saleClon.ticketFk
+ WHERE tOrig.id = vTicketFk
+ AND tClon.isDeleted = FALSE
+ AND DATE(tClon.shipped) = vShipment)
THEN
ITERATE myLoop;
END IF;
IF vAgencyModeFk IS NULL THEN
- SELECT agencyModeFk INTO vAgencyModeFk
+ SELECT agencyModeFk INTO vAgencyModeFk
FROM address
- WHERE clientFk = vClientFk AND isDefaultAddress;
+ WHERE clientFk = vClientFk
+ AND isDefaultAddress;
END IF;
- CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE);
+ CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE);
SET vLanding = NULL;
- SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1;
+ SELECT landed INTO vLanding FROM tmp.zoneGetLanded LIMIT 1;
CALL ticket_add(
vClientFk,
@@ -70734,72 +71075,127 @@ BEGIN
FALSE,
vNewTicket);
- UPDATE ticket
- SET clonedFrom = vTicketFk
+ UPDATE ticket
+ SET clonedFrom = vTicketFk
WHERE id = vNewTicket;
- IF (vLanding IS NULL) THEN
-
- SELECT e.email INTO vSalesPersonEmail
- FROM vn.client c
- JOIN vn.worker sp ON sp.id = c.salesPersonFk
- JOIN account.emailUser e ON e.userFk = sp.userFk
- WHERE c.id = vClientFk;
-
- SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicketFk,
- ' para el dia: ', vShipment);
- SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicketFk,
- ' para el dia: ', vShipment,
- ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket,
- ' pero ha que revisar las fechas y la agencia');
-
- SELECT COUNT(*) INTO vMailSent
- FROM vn.mail
- WHERE receiver = vSalesPersonEmail
- AND subject = vSubject;
-
- IF NOT vMailSent THEN
- CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage);
- END IF;
- CALL vn.ticketStateUpdate (vNewTicket, 'FIXING');
- END IF;
-
- INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed)
- SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed
- FROM vn.sale saleOrig
+ INSERT INTO sale (ticketFk, itemFk, concept, quantity, price,
+ discount, priceFixed, isPriceFixed)
+ SELECT vNewTicket,
+ saleOrig.itemFk,
+ saleOrig.concept,
+ saleOrig.quantity,
+ saleOrig.price,
+ saleOrig.discount,
+ saleOrig.priceFixed,
+ saleOrig.isPriceFixed
+ FROM sale saleOrig
WHERE saleOrig.ticketFk = vTicketFk;
- INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk)
+ INSERT IGNORE INTO saleCloned(saleOriginalFk, saleClonedFk)
SELECT saleOriginal.id, saleClon.id
- FROM vn.sale saleOriginal
- JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity
- WHERE saleOriginal.ticketFk = vTicketFk AND saleClon.ticketFk = vNewTicket;
+ FROM sale saleOriginal
+ JOIN sale saleClon ON saleOriginal.itemFk = saleClon.itemFk
+ AND saleOriginal.quantity = saleClon.quantity
+ WHERE saleOriginal.ticketFk = vTicketFk
+ AND saleClon.ticketFk = vNewTicket;
- INSERT INTO ticketRequest (description,ordered,shipped,quantity,price,itemFk,clientFk,response,
- total,buyed,requesterFk,attenderFk,ticketFk)
- SELECT description,ordered,shipped,quantity,price,itemFk,clientFk,response,
- total,buyed,requesterFk,attenderFk,vNewTicket
+ INSERT INTO ticketRequest (description,
+ ordered,
+ shipped,
+ quantity,
+ price,
+ itemFk,
+ clientFk,
+ response,
+ total,
+ buyed,
+ requesterFk
+ ,attenderFk,
+ ticketFk)
+ SELECT description,
+ ordered,
+ shipped,
+ quantity,
+ price,
+ itemFk,
+ clientFk,
+ response,
+ total,
+ buyed,
+ requesterFk,
+ attenderFk,
+ vNewTicket
FROM ticketRequest
WHERE ticketFk =vTicketFk;
- INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicketFk))
- ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' ');
+ SELECT id INTO vSalesPersonFK
+ FROM observationType
+ WHERE code = 'salesPerson';
- INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,1,'ATENCION: Contiene lineas de TURNO')
- ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' ');
+ SELECT id INTO vItemPicker
+ FROM observationType
+ WHERE code = 'itemPicker';
+
+ INSERT INTO ticketObservation(
+ ticketFk,
+ observationTypeFk,
+ description)
+ VALUES(
+ vNewTicket,
+ vSalesPersonFK,
+ CONCAT('turno desde ticket: ',vTicketFk))
+ ON DUPLICATE KEY UPDATE description =
+ CONCAT(ticketObservation.description,VALUES(description),' ');
+
+ INSERT INTO ticketObservation(ticketFk,
+ observationTypeFk,
+ description)
+ VALUES(
+ vNewTicket,
+ vItemPicker,
+ 'ATENCION: Contiene lineas de TURNO')
+ ON DUPLICATE KEY UPDATE description =
+ CONCAT(ticketObservation.description,VALUES(description),' ');
+
+ IF (vLanding IS NULL) THEN
+
+ SELECT e.email INTO vSalesPersonEmail
+ FROM client c
+ JOIN account.emailUser e ON e.userFk = c.salesPersonFk
+ WHERE c.id = vClientFk;
+
+ SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ',
+ vTicketFk,' para el dia: ', vShipment);
+ SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicketFk,
+ ' para el dia: ', vShipment,
+ ' porque no hay una zona de envío disponible. Se ha creado el ticket: ',
+ vNewTicket, ' pero ha que revisar las fechas y la agencia');
+
+ SELECT COUNT(*) INTO vIsDuplicateMail
+ FROM mail
+ WHERE receiver = vSalesPersonEmail
+ AND subject = vSubject;
+
+ IF NOT vIsDuplicateMail THEN
+ CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage);
+ END IF;
+ CALL ticketStateUpdate (vNewTicket, 'FIXING');
+ ELSE
+ CALL ticketCalculateClon(vNewTicket, vTicketFk);
+ END IF;
- CALL vn.ticketCalculateClon(vNewTicket, vTicketFk);
END;
END LOOP;
-
CLOSE rsTicket;
-
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_close` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70807,13 +71203,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_close`()
BEGIN
/**
- * Realiza el cierre de todos los
+ * Realiza el cierre de todos los
* tickets de la tabla tmp.ticket_close.
*
* @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar
@@ -70831,7 +71225,7 @@ BEGIN
DECLARE cur CURSOR FOR
SELECT ticketFk FROM tmp.ticket_close;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
RESIGNAL;
@@ -70841,7 +71235,7 @@ BEGIN
proc: LOOP
SET vDone = FALSE;
-
+
FETCH cur INTO vCurTicketFk;
IF vDone THEN
@@ -70858,12 +71252,12 @@ BEGIN
c.hasToInvoice
INTO vClientFk,
vIsTaxDataChecked,
- vCompanyFk,
+ vCompanyFk,
vShipped,
vHasDailyInvoice,
vWithPackage,
vHasToInvoice
- FROM ticket t
+ FROM ticket t
JOIN `client` c ON c.id = t.clientFk
JOIN province p ON p.id = c.provinceFk
LEFT JOIN autonomy a ON a.id = p.autonomyFk
@@ -70873,22 +71267,22 @@ BEGIN
INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity)
(SELECT vCurTicketFk, p.id, COUNT(*)
- FROM expedition e
+ FROM expedition e
JOIN packaging p ON p.itemFk = e.freightItemFk
WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
AND vWithPackage
GROUP BY p.itemFk);
-- No retornables o no catalogados
- INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed)
+ INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed)
(SELECT e.freightItemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.freightItemFk, vClientFk), 1
- FROM expedition e
+ FROM expedition e
JOIN item i ON i.id = e.freightItemFk
LEFT JOIN packaging p ON p.itemFk = i.id
WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0
AND getSpecialPrice(e.freightItemFk, vClientFk) > 0
GROUP BY e.freightItemFk);
-
+
IF(vHasDailyInvoice) AND vHasToInvoice THEN
-- Facturacion rapida
@@ -70896,10 +71290,10 @@ BEGIN
-- Facturar si está contabilizado
IF vIsTaxDataChecked THEN
CALL invoiceOut_newFromClient(
- vClientFk,
- (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')),
- vShipped,
- vCompanyFk,
+ vClientFk,
+ (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')),
+ vShipped,
+ vCompanyFk,
NULL,
NULL,
vNewInvoiceId);
@@ -70916,6 +71310,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_closeByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70923,8 +71319,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int)
BEGIN
@@ -70956,6 +71350,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_componentMakeUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70963,29 +71359,27 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`(
- vTicketFk INT,
+ vTicketFk INT,
vClientFk INT,
- vNickname VARCHAR(50),
+ vNickname VARCHAR(50),
vAgencyModeFk INT,
- vAddressFk INT,
- vZoneFk INT,
+ vAddressFk INT,
+ vZoneFk INT,
vWarehouseFk INT,
- vCompanyFk INT,
+ vCompanyFk INT,
vShipped DATETIME,
- vLanded DATE,
+ vLanded DATE,
vIsDeleted BOOLEAN,
- vHasToBeUnrouted BOOLEAN,
+ vHasToBeUnrouted BOOLEAN,
vOption INT)
BEGIN
-
+
/**
* Modifica en el ticket los campos que se le pasan por parámetro
* y cambia sus componentes
- *
+ *
* @param vTicketFk Id del ticket a modificar
* @param vClientFk nuevo cliente
* @param vNickname nuevo alias
@@ -71000,29 +71394,29 @@ BEGIN
* @param vHasToBeUnrouted si se le elimina la ruta al ticket
* @param vOption opcion para el case del proc ticketComponentUpdateSale
*/
-
+
DECLARE vPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2);
CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
-
- UPDATE ticket t
+
+ UPDATE ticket t
JOIN address a ON a.id = vAddressFk
SET t.nickname = a.nickname
WHERE t.id = vTicketFk;
-
+
END IF;
CALL zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, TRUE);
- SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
+ SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
FROM tmp.zoneGetShipped
WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1;
-
+
UPDATE ticket t
- SET
+ SET
t.clientFk = vClientFk,
t.nickname = vNickname,
t.agencyModeFk = vAgencyModeFk,
@@ -71037,12 +71431,12 @@ BEGIN
t.isDeleted = vIsDeleted
WHERE
t.id = vTicketFk;
-
+
IF vHasToBeUnrouted THEN
UPDATE ticket t SET t.routeFk = NULL
WHERE t.id = vTicketFk;
END IF;
-
+
IF vOption <> 8 THEN
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
@@ -71068,6 +71462,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_componentPreview` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71075,12 +71471,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentPreview`(
vTicketFk INT,
- vLanded DATE,
+ vLanded DATE,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk SMALLINT)
@@ -71096,7 +71490,7 @@ BEGIN
*
* @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost)
*/
- DECLARE vHasDataChanged BOOL DEFAULT FALSE;
+ DECLARE vHasDataChanged BOOL DEFAULT FALSE;
DECLARE vHasAddressChanged BOOL;
DECLARE vHasZoneChanged BOOL DEFAULT FALSE;
DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE;
@@ -71107,8 +71501,8 @@ BEGIN
DECLARE vHasChangeAll BOOL DEFAULT FALSE;
- SELECT DATE(landed) <> vLanded,
- addressFk <> vAddressFk,
+ SELECT DATE(landed) <> vLanded,
+ addressFk <> vAddressFk,
zoneFk <> vZoneFk,
warehouseFk <> vWarehouseFk
INTO
@@ -71131,15 +71525,15 @@ BEGIN
SET vAgencyModeTypeRateFk = 6;
END IF;
- SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
+ SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
FROM zone
WHERE id = vZoneFk;
-
+
CALL buyUltimate(vWarehouseFk, vShipped);
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
- SELECT
+ CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
+ SELECT
vWarehouseFk AS warehouseFk,
NULL AS available,
s.itemFk,
@@ -71159,9 +71553,9 @@ BEGIN
JOIN sale s ON s.id = sc.saleFk
JOIN ticket t ON t.id = s.ticketFk
JOIN `component` c ON c.id = sc.componentFk
- WHERE s.ticketFk = vTicketFk
- AND (c.isRenewable = FALSE
- OR
+ WHERE s.ticketFk = vTicketFk
+ AND (c.isRenewable = FALSE
+ OR
(NOT vHasChangeAll
AND (NOT (c.typeFk <=> vAddressTypeRateFk
OR c.typeFk <=> vAgencyModeTypeRateFk))));
@@ -71182,6 +71576,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_DelayTruck` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71189,8 +71585,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT)
BEGIN
@@ -71229,6 +71623,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_DelayTruckSplit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71236,57 +71632,55 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruckSplit`(vTicketFk INT)
BEGIN
-
+
/*
* Splita las lineas de ticket que no estan ubicadas
- *
+ *
*/
-
+
DECLARE vNewTicketFk INT;
DECLARE vTotalLines INT;
DECLARE vLinesToSplit INT;
DROP TEMPORARY TABLE IF EXISTS tmp.SalesToSplit;
-
+
SELECT COUNT(*) INTO vTotalLines
- FROM vn.sale
+ FROM vn.sale
WHERE ticketFk = vTicketFk;
-
+
CREATE TEMPORARY TABLE tmp.SalesToSplit
SELECT s.id saleFk
FROM vn.ticket t
- JOIN vn.sale s ON t.id = s.ticketFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = s.itemFk AND issw.warehouseFk = t.warehouseFk
+ JOIN vn.sale s ON t.id = s.ticketFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = s.itemFk AND issw.warehouseFk = t.warehouseFk
WHERE s.quantity > IFNULL(issw.visible, 0)
AND s.quantity > 0
AND s.isPicked = FALSE
AND s.reserved = FALSE
AND t.id = vTicketFk;
-
+
SELECT COUNT(*) INTO vLinesToSplit
FROM tmp.SalesToSplit;
-
+
IF vLinesToSplit = vTotalLines AND vLinesToSplit > 0 THEN
-
+
SET vNewTicketFk = vTicketFk;
-
+
ELSE
-
+
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
-
- UPDATE vn.sale s
- JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id
+
+ UPDATE vn.sale s
+ JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id
SET s.ticketFk = vNewTicketFk;
-
+
END IF;
-
+
CALL vn.ticketStateUpdate(vNewTicketFk, 'FIXING');
-
+
DROP TEMPORARY TABLE tmp.SalesToSplit;
END ;;
@@ -71295,6 +71689,110 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticket_doCmr` */;
+/*!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_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doCmr`(vSelf INT)
+BEGIN
+/**
+* Crea u actualiza la información del CMR asociado con
+* un ticket específico en caso de que sea necesario.
+*
+* @param vSelf El id del ticket
+*/
+ DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT;
+ SELECT cmrFk INTO vCmrFk
+ FROM ticket
+ WHERE id = vSelf;
+
+ CREATE OR REPLACE TEMPORARY TABLE tTicket
+ SELECT wo.firstName,
+ v.numberPlate,
+ com.id companyFk,
+ a.id addressFk,
+ c2.defaultAddressFk,
+ su.id supplierFk,
+ t.landed
+ FROM ticket t
+ JOIN ticketState ts ON ts.ticketFk = t.id
+ JOIN `state` s ON s.id = ts.stateFk
+ JOIN alertLevel al ON al.id = s.alertLevel
+ JOIN client c ON c.id = t.clientFk
+ JOIN `address` a ON a.id = t.addressFk
+ JOIN province p ON p.id = a.provinceFk
+ JOIN country co ON co.id = p.countryFk
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
+ JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN company com ON com.id = t.companyFk
+ JOIN client c2 ON c2.id = com.clientFk
+ JOIN supplierAccount sa ON sa.id = com.supplierAccountFk
+ JOIN supplier su ON su.id = sa.supplierFk
+ LEFT JOIN route r ON r.id = t.routeFk
+ LEFT JOIN worker wo ON wo.id = r.workerFk
+ LEFT JOIN vehicle v ON v.id = r.vehicleFk
+ WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE())
+ AND al.code IN ('PACKED', 'DELIVERED')
+ AND co.code <> 'ES'
+ AND am.name <> 'ABONO'
+ AND w.code = 'ALG'
+ AND dm.code = 'DELIVERY'
+ AND t.id = vSelf
+ GROUP BY t.id;
+
+ START TRANSACTION;
+
+ IF vCmrFk THEN
+ UPDATE cmr c
+ JOIN tTicket t
+ SET c.senderInstruccions = t.firstName,
+ c.truckPlate = t.numberPlate,
+ c.companyFk = t.companyFk,
+ c.addressToFk = t.addressFk,
+ c.addressFromFk = t.defaultAddressFk,
+ c.supplierFk = t.supplierFk,
+ c.ead = t.landed
+ WHERE id = vCmrFk;
+ ELSE
+ SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
+
+ INSERT INTO cmr (
+ senderInstruccions,
+ truckPlate,
+ companyFk,
+ addressToFk,
+ addressFromFk,
+ supplierFk,
+ ead
+ )
+ SELECT * FROM tTicket;
+
+ SELECT MAX(id) INTO vCurrentCmrFk FROM cmr;
+
+ IF vPreviousCmrFk <> vCurrentCmrFk THEN
+ UPDATE ticket
+ SET cmrFk = vCurrentCmrFk
+ WHERE id = vSelf;
+ END IF;
+ END IF;
+
+ COMMIT;
+ DROP TEMPORARY TABLE tTicket;
+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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71302,8 +71800,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRecalc`()
proc: BEGIN
@@ -71361,6 +71857,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getFromFloramondo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71368,8 +71866,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE)
BEGIN
@@ -71501,6 +71997,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getMovable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71508,8 +72006,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
BEGIN
@@ -71521,43 +72017,45 @@ BEGIN
* @param vTicketFk -> Ticket
* @param vDatedNew -> Nueva fecha
* @return Sales con Movible
-*/
+*/
DECLARE vDatedOld DATETIME;
SET vDatedNew = DATE_ADD(vDatedNew, INTERVAL 1 DAY);
SELECT t.shipped INTO vDatedOld
- FROM ticket t
+ FROM ticket t
WHERE t.id = vTicketFk;
- CALL itemStock(vWarehouseFk, vDatedNew, NULL);
+ CALL item_getStock(vWarehouseFk, vDatedNew, NULL);
CALL item_getMinacum(vWarehouseFk, vDatedNew, DATEDIFF(DATE_SUB(vDatedOld, INTERVAL 1 DAY), vDatedNew), NULL);
-
- SELECT s.id,
- s.itemFk,
- s.quantity,
- s.concept,
- s.price,
+
+ SELECT s.id,
+ s.itemFk,
+ s.quantity,
+ s.concept,
+ s.price,
s.reserved,
- s.discount,
- i.image,
- i.subName,
+ s.discount,
+ i.image,
+ i.subName,
il.stock + IFNULL(im.amount, 0) AS movable
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
+ JOIN item i ON i.id = s.itemFk
LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk AND im.warehouseFk = vWarehouseFk
LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk
WHERE t.id = vTicketFk;
DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
- DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
-
+ DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getProblems` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71565,8 +72063,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1))
BEGIN
@@ -71580,10 +72076,10 @@ BEGIN
CALL sale_getProblems(vIsTodayRelative);
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems;
- CREATE TEMPORARY TABLE tmp.ticket_problems
+ CREATE TEMPORARY TABLE tmp.ticket_problems
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
- SELECT
+ SELECT
ticketFk,
MAX(p.isFreezed) isFreezed,
MAX(p.risk) risk,
@@ -71601,7 +72097,7 @@ BEGIN
GROUP BY ticketFk;
UPDATE tmp.ticket_problems tp
- SET tp.totalProblems =
+ SET tp.totalProblems =
(
(tp.isFreezed) +
IF(tp.risk, TRUE, FALSE) +
@@ -71623,6 +72119,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getSplitList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71630,8 +72128,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT)
BEGIN
@@ -71655,17 +72151,17 @@ BEGIN
(saleFk INT PRIMARY KEY,
ticketFk INT,
problem VARCHAR(1)) ENGINE = MEMORY;
-
+
INSERT INTO tmp.salesToSplit(saleFk, ticketFk, problem)
SELECT s.id, s.ticketFk, 'F'
FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it on it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) < s.quantity
AND IFNULL(av.available ,0) < s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
@@ -71675,16 +72171,16 @@ BEGIN
AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
-
+
INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem)
SELECT s.id, s.ticketFk, 'I'
- FROM vn.ticket t
+ FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it on it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) >= s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
AND s.quantity > 0
@@ -71694,7 +72190,7 @@ BEGIN
AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
-
+
INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem)
SELECT s.id, s.ticketFk, 'R'
FROM vn.ticket t
@@ -71704,7 +72200,7 @@ BEGIN
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible,0) < s.quantity
AND IFNULL(av.available ,0) >= s.quantity
AND IFNULL(issw.visible, 0) < s.quantity
@@ -71715,7 +72211,7 @@ BEGIN
AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketsToSplit;
CREATE TEMPORARY TABLE tmp.ticketsToSplit
@@ -71736,11 +72232,11 @@ BEGIN
JOIN vn.ticket t ON t.id = ss.ticketFk
JOIN vn.sale s ON s.id = ss.saleFk
JOIN vn.item i ON i.id = s.itemFk
- LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
+ LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
GROUP BY ss.ticketFk;
-
- SELECT
- ts.*,
+
+ SELECT
+ ts.*,
t.id ticketFuture,
st.name state,
zc.`hour` tfEtd,
@@ -71749,23 +72245,23 @@ BEGIN
FROM tmp.ticketsToSplit ts
LEFT JOIN vn.ticketState ts2 ON ts2.ticketFk = ts.ticketFk
LEFT JOIN vn.state st ON st.id = ts2.stateFk
- LEFT JOIN vn.ticket t
- ON t.id != ts.ticketFk
+ LEFT JOIN vn.ticket t
+ ON t.id != ts.ticketFk
AND t.addressFk = ts.addressFk
AND t.shipped BETWEEN vDated AND util.dayend(vDated)
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vDated
LEFT JOIN vn.sale s ON s.ticketFk = t.id
LEFT JOIN vn.item i ON i.id = s.itemFk
- LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
+ LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
LEFT JOIN vn.state st2 ON st2.id = tst.stateFk
- WHERE (t.id IS NULL
+ WHERE (t.id IS NULL
OR (vDated > util.VN_CURDATE())
OR (vDated = util.VN_CURDATE() AND vHour >= zc.`hour`))
AND ts.etd <= vHour
GROUP BY ts.ticketFk, t.id
ORDER BY ts.etd, ts.ticketFk;
-
- DROP TEMPORARY TABLE
+
+ DROP TEMPORARY TABLE
tmp.ticketsToSplit;
END ;;
DELIMITER ;
@@ -71773,6 +72269,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getTax` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71780,8 +72278,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25))
BEGIN
@@ -71802,7 +72298,7 @@ BEGIN
JOIN ticket t ON t.id = tmpTicket.ticketFk;
CALL addressTaxArea ();
-
+
IF vTaxArea IS NOT NULL THEN
UPDATE tmp.addressTaxArea
SET areaFk = vTaxArea;
@@ -71874,8 +72370,8 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticketAmount
(INDEX (ticketFk))
ENGINE = MEMORY
- SELECT ticketFk,
- taxableBase,
+ SELECT ticketFk,
+ taxableBase,
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,
code
FROM tmp.ticketTax
@@ -71889,6 +72385,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getWarnings` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71896,8 +72394,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWarnings`()
BEGIN
@@ -71944,6 +72440,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getWithParameters` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71951,15 +72449,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWithParameters`(
- vClientFk INT,
+ vClientFk INT,
vWarehouseFk INT,
- vShipped DATE,
- vAddressFk INT,
- vCompanyFk INT,
+ vShipped DATE,
+ vAddressFk INT,
+ vCompanyFk INT,
vAgencyModeFk INT,
OUT vTicketFk INT
)
@@ -71973,8 +72469,8 @@ BEGIN
* @param vAddressFk Consignatario
* @param vCompanyFk Empresa
* @param vAgencyModeFk agencia
- */
-
+ */
+
SELECT t.id INTO vTicketFk
FROM vn.ticket t
WHERE t.clientFk <=> vClientFk
@@ -71984,7 +72480,7 @@ BEGIN
AND (t.companyFk <=> vCompanyFk OR vCompanyFk IS NULL)
AND (t.agencyModeFk <=> vAgencyModeFk OR vAgencyModeFk IS NULL)
LIMIT 1;
-
+
IF vTicketFk IS NULL THEN
CALL vn.ticket_add(
vClientFk,
@@ -72006,6 +72502,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_insertZone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72013,8 +72511,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_insertZone`()
BEGIN
@@ -72024,24 +72520,24 @@ BEGIN
DECLARE vAddressFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vWarehouseFk INT;
- DECLARE vCursor CURSOR FOR
+ DECLARE vCursor CURSOR FOR
SELECT id, landed, addressFk, agencyModeFk, warehouseFk
FROM vn.ticket WHERE shipped > '2020-01-01' AND zoneFk is null;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET vDone = 1;
-
+
OPEN vCursor;
REPEAT
FETCH vCursor INTO vFechedTicket, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk;
CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE);
-
+
UPDATE vn.ticket t
JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk
SET t.zoneFk = zgs.zoneFk
WHERE t.id = vFechedTicket;
-
+
UNTIL vDone END REPEAT;
DROP TEMPORARY TABLE tmp.zoneGetShipped;
-
+
CLOSE vCursor;
END ;;
DELIMITER ;
@@ -72049,6 +72545,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_priceDifference` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72056,19 +72554,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_priceDifference`(
vTicketFk INT,
- vLanded DATE,
+ vLanded DATE,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk INT)
BEGIN
/**
* Devuelve las diferencias de precio de los movimientos de un ticket.
- *
+ *
* @param vTicketFk Id del ticket
* @param vLanded Fecha de recepcion
* @param vAddressFk Id del consignatario
@@ -72077,26 +72573,26 @@ BEGIN
*/
CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
- SELECT s.itemFk,
- i.name,
- i.size,
- i.category,
- IFNULL(s.quantity, 0) AS quantity,
- IFNULL(s.price, 0) AS price,
+ SELECT s.itemFk,
+ i.name,
+ i.size,
+ i.category,
+ IFNULL(s.quantity, 0) AS quantity,
+ IFNULL(s.price, 0) AS price,
ROUND(SUM(tc.cost), 2) AS newPrice,
s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference,
s.id AS saleFk
FROM sale s
- JOIN item i ON i.id = s.itemFk
- JOIN ticket t ON t.id = s.ticketFk
- LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk
+ JOIN item i ON i.id = s.itemFk
+ JOIN ticket t ON t.id = s.ticketFk
+ LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk
AND tc.warehouseFk = vWarehouseFk
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
+ LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk = tc.componentFk
- LEFT JOIN `component` c ON c.id = tc.componentFk
- WHERE t.id = vTicketFk
- AND IF(sc.componentFk IS NULL
- AND c.classRate IS NOT NULL, FALSE, TRUE)
+ LEFT JOIN `component` c ON c.id = tc.componentFk
+ WHERE t.id = vTicketFk
+ AND IF(sc.componentFk IS NULL
+ AND c.classRate IS NOT NULL, FALSE, TRUE)
GROUP BY s.id ORDER BY s.id;
DROP TEMPORARY TABLE tmp.ticketComponentPreview;
@@ -72106,6 +72602,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_printLabelPrevious` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72113,13 +72611,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_printLabelPrevious`(vTicketFk INT)
BEGIN
/**
- * Calls the report_print procedure and passes it
+ * Calls the report_print procedure and passes it
* the necessary parameters for printing.
*
* @param vTicketFk id ticket to print.
@@ -72127,18 +72623,18 @@ BEGIN
DECLARE vPrinterFk INT;
DECLARE vSaleGroup INT;
DECLARE vUserFk INT DEFAULT account.myUser_getId();
-
- SELECT sg.id, w.labelerFk INTO vSaleGroup, vPrinterFk
+
+ SELECT sg.id, o.labelerFk INTO vSaleGroup, vPrinterFk
FROM saleGroup sg
JOIN sector sc ON sc.id = sg.sectorFk
- JOIN saleGroupDetail sgd ON sg.id = sgd.saleGroupFk
+ JOIN saleGroupDetail sgd ON sg.id = sgd.saleGroupFk
JOIN sale s ON sgd.saleFk = s.id
JOIN ticket t ON s.ticketFk = t.id
- JOIN worker w ON w.id = vUserFk
- WHERE sc.id = w.sectorFk
+ JOIN operator o ON o.workerFk = vUserFk
+ WHERE sc.id = o.sectorFk
AND t.id = vTicketFk
LIMIT 1;
-
+
CALL report_print(
'LabelPrevia',
vPrinterFk,
@@ -72152,6 +72648,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72159,25 +72657,23 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25))
proc:BEGIN
/**
* Calcula y guarda el total con/sin IVA en un ticket.
*
- * @param vTicketId Identificador del ticket
+ * @param vSelf Identificador del ticket
+ * @param vTaxArea
*/
-
DECLARE hasInvoice BOOL;
- SELECT COUNT(*) INTO hasInvoice
- FROM ticket
+ SELECT COUNT(*) INTO hasInvoice
+ FROM ticket
WHERE id = vSelf
AND refFk IS NOT NULL;
-
- IF hasInvoice THEN
+
+ IF hasInvoice THEN
LEAVE proc;
END IF;
@@ -72202,6 +72698,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72209,8 +72707,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(vSelf INT, vOption INT)
proc: BEGIN
@@ -72236,6 +72732,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_requestRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72243,8 +72741,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_requestRecalc`(vSelf INT)
proc: BEGIN
@@ -72264,6 +72760,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_setNextState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72271,8 +72769,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`(vSelf INT)
BEGIN
@@ -72300,6 +72796,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_setParking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72307,8 +72805,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT)
proc: BEGIN
@@ -72355,6 +72851,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_setPreviousState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72362,8 +72860,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setPreviousState`(vTicketFk INT)
BEGIN
@@ -72400,6 +72896,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_setState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72407,68 +72905,72 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci)
-BEGIN
-/**
- * Modifica el estado de un ticket si se cumplen las condiciones necesarias.
- *
- * @param vSelf el id del ticket
- * @param vStateCode estado a modificar del ticket
- */
- DECLARE vticketAlertLevel INT;
- DECLARE vTicketStateCode VARCHAR(255);
- DECLARE vCanChangeState BOOL;
- DECLARE vPackedAlertLevel INT;
- DECLARE vOnPreparationAlertLevel INT;
- DECLARE vNextAlertLevel INT;
- DECLARE vZoneFk INT;
-
- SELECT s.alertLevel, s.`code`, s2.alertLevel, t.zoneFk
- INTO vticketAlertLevel, vTicketStateCode, vNextAlertLevel , vZoneFk
- FROM state s
- JOIN ticketTracking tt ON tt.stateFk = s.id
- JOIN state s2 ON s2.code = vStateCode
- JOIN ticket t ON t.id = tt.ticketFk
- WHERE tt.ticketFk = vSelf
- ORDER BY tt.created DESC
- LIMIT 1;
-
- SELECT id INTO vPackedAlertLevel FROM alertLevel WHERE code = 'PACKED';
- SELECT id INTO vOnPreparationAlertLevel FROM alertLevel WHERE code = 'ON_PREPARATION';
-
- IF vStateCode = 'OK' AND vZoneFk IS NULL THEN
- CALL util.throw('ASSIGN_ZONE_FIRST');
- END IF;
-
- IF vNextAlertLevel > vticketAlertLevel && vticketAlertLevel < vOnPreparationAlertLevel THEN
- UPDATE sale
- SET originalQuantity = quantity
- WHERE ticketFk = vSelf;
- END IF;
-
- SET vCanChangeState = (vStateCode <> 'ON_CHECKING' OR vticketAlertLevel < vPackedAlertLevel)
- AND NOT (
- vTicketStateCode IN ('CHECKED', 'CHECKING')
- AND vStateCode IN ('PREPARED', 'ON_PREPARATION')
- );
-
- IF vCanChangeState THEN
- INSERT INTO ticketTracking (stateFk, ticketFk, workerFk)
- SELECT id, vSelf, account.myUser_getId()
- FROM state
- WHERE `code` = vStateCode COLLATE utf8_unicode_ci;
- ELSE
- CALL util.throw('INCORRECT_TICKET_STATE');
- END IF;
+BEGIN
+/**
+ * Modifica el estado de un ticket si se cumplen las condiciones necesarias.
+ *
+ * @param vSelf el id del ticket
+ * @param vStateCode estado a modificar del ticket
+ */
+ DECLARE vticketAlertLevel INT;
+ DECLARE vTicketStateCode VARCHAR(255);
+ DECLARE vCanChangeState BOOL;
+ DECLARE vPackedAlertLevel INT;
+ DECLARE vOnPreparationAlertLevel INT;
+ DECLARE vNextAlertLevel INT;
+ DECLARE vZoneFk INT;
+
+ SELECT s.alertLevel, s.`code`, s2.alertLevel, t.zoneFk
+ INTO vticketAlertLevel, vTicketStateCode, vNextAlertLevel , vZoneFk
+ FROM state s
+ JOIN ticketTracking tt ON tt.stateFk = s.id
+ JOIN state s2 ON s2.code = vStateCode
+ JOIN ticket t ON t.id = tt.ticketFk
+ WHERE tt.ticketFk = vSelf
+ ORDER BY tt.created DESC
+ LIMIT 1;
+
+ SELECT id INTO vPackedAlertLevel FROM alertLevel WHERE code = 'PACKED';
+ SELECT id INTO vOnPreparationAlertLevel FROM alertLevel WHERE code = 'ON_PREPARATION';
+
+ IF vStateCode = 'OK' AND vZoneFk IS NULL THEN
+ CALL util.throw('ASSIGN_ZONE_FIRST');
+ END IF;
+
+ IF vNextAlertLevel > vticketAlertLevel && vticketAlertLevel < vOnPreparationAlertLevel THEN
+ UPDATE sale
+ SET originalQuantity = quantity
+ WHERE ticketFk = vSelf;
+ END IF;
+
+ SET vCanChangeState = (vStateCode <> 'ON_CHECKING' OR vticketAlertLevel < vPackedAlertLevel)
+ AND NOT (
+ vTicketStateCode IN ('CHECKED', 'CHECKING')
+ AND vStateCode IN ('PREPARED', 'ON_PREPARATION')
+ );
+
+ IF vCanChangeState THEN
+ INSERT INTO ticketTracking (stateFk, ticketFk, workerFk)
+ SELECT id, vSelf, account.myUser_getId()
+ FROM state
+ WHERE `code` = vStateCode COLLATE utf8_unicode_ci;
+
+ IF vStateCode = 'PACKED' THEN
+ CALL ticket_doCmr(vSelf);
+ END IF;
+ ELSE
+ CALL util.throw('INCORRECT_TICKET_STATE');
+ END IF;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_split` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72476,8 +72978,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE)
proc:BEGIN
@@ -72496,40 +72996,40 @@ proc:BEGIN
SELECT COUNT(*) INTO vProblemLines
FROM tmp.salesToSplit
WHERE ticketFk = vTicketFk;
-
+
SELECT count(*) INTO vTotalLines
- FROM vn.sale s
+ FROM vn.sale s
WHERE s.ticketFk = vTicketFk;
-
+
SET vHasFullProblem = (vTotalLines = vProblemLines);
-- Ticket completo
IF vHasFullProblem THEN
-
+
UPDATE vn.ticket
SET landed = vDated + INTERVAL 1 DAY,
shipped = vDated,
nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname )
WHERE id = vTicketFk;
-
+
SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated);
LEAVE proc;
-
+
END IF;
-- Ticket a futuro existe
IF vTicketFutureFk THEN
-
- UPDATE vn.sale s
+
+ UPDATE vn.sale s
JOIN tmp.salesToSplit ss ON s.id = ss.saleFk
SET s.ticketFk = vTicketFutureFk,
s.concept = CONCAT('(s) ', s.concept)
WHERE ss.ticketFk = vTicketFk;
-
- SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
+
+ SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
" al ticket existente ", vTicketFutureFk,"(", vDated,")");
LEAVE proc;
-
+
END IF;
-- Ticket nuevo
@@ -72541,18 +73041,18 @@ proc:BEGIN
t.landed = vDated + INTERVAL 1 DAY,
t.shipped = vDated,
t.agencyModeFk = pc.defautlAgencyMode,
- t.zoneFk = pc.defaultZone
+ t.zoneFk = pc.defaultZone
WHERE t.id = vTicketFutureFk;
-
- UPDATE vn.sale s
- JOIN tmp.salesToSplit sts ON sts.saleFk = s.id
+
+ UPDATE vn.sale s
+ JOIN tmp.salesToSplit sts ON sts.saleFk = s.id
SET s.ticketFk = vTicketFutureFk,
s.concept = CONCAT('(s) ', s.concept)
WHERE sts.ticketFk = vTicketFk;
CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING');
- SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
+ SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
" al nuevo ticket ", vTicketFutureFk,"(", vDated,")");
END ;;
DELIMITER ;
@@ -72560,6 +73060,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_splitItemPackingType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72567,8 +73069,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`(vTicketFk INT, vOriginalItemPackingTypeFk VARCHAR(1))
proc:BEGIN
@@ -72679,6 +73179,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_splitPackingComplete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72686,54 +73188,54 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT)
BEGIN
-
+
DECLARE vNeedToSplit BOOLEAN;
DECLARE vNewTicketFk INT;
-
+
DROP TEMPORARY TABLE IF EXISTS tmpSale;
-
+
CREATE TEMPORARY TABLE tmpSale
SELECT DISTINCT s.id
- FROM vn.ticket t
+ FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.item i ON i.id = s.itemFk
LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = vSectorFk
- JOIN vn.packagingConfig pc
+ JOIN vn.packagingConfig pc
WHERE t.id = vTicketFk
AND ( s.quantity MOD IFNULL(iss.packing,1) != 0
- OR
+ OR
IFNULL(iss.packing,1) = 1
- OR
+ OR
i.`size` <= pc.previousPreparationMinimumSize
);
-
- SELECT COUNT(*)
+
+ SELECT COUNT(*)
INTO vNeedToSplit
- FROM tmpSale;
-
+ FROM tmpSale;
+
IF vNeedToSplit THEN
-
+
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
-
+
UPDATE vn.sale s
- JOIN vn.tmpSale ts ON ts.id = s.id
+ JOIN vn.tmpSale ts ON ts.id = s.id
SET s.ticketFk = vNewTicketFk;
-
+
END IF;
-
+
DROP TEMPORARY TABLE tmpSale;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_WeightDeclaration` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72741,8 +73243,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE)
BEGIN
@@ -72758,7 +73258,7 @@ BEGIN
WHERE ot.description = 'Peso Aduana'
AND t.clientFk = vClientFk
AND t.shipped BETWEEN vDated AND util.dayend(vDated);
-
+
SELECT sum(IF(sv.physicalWeight = 0, sv.weight, sv.physicalWeight)) INTO vTheorycalWeight
FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
@@ -72767,9 +73267,9 @@ BEGIN
JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
WHERE t.clientFk = vClientFk
AND t.shipped BETWEEN vDated AND util.dayend(vDated);
-
+
SET vRatio = vRealWeight / vTheorycalWeight;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketWeight;
CREATE TEMPORARY TABLE tmp.ticketWeight
@@ -72790,13 +73290,15 @@ BEGIN
AND t.shipped BETWEEN vDated AND util.dayend(vDated)
GROUP BY ib.ediBotanic, o.code;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72804,8 +73306,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -72839,7 +73339,7 @@ BEGIN
isAllowedToWork
FROM(SELECT t.dated,
b.id businessFk,
- w.userFk,
+ w.id,
b.departmentFk,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5) ORDER BY bs.started ASC SEPARATOR ' - ')) hourStart ,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) hourEnd,
@@ -72849,18 +73349,19 @@ BEGIN
at2.permissionRate,
at2.discountRate,
ct.hoursWeek hoursWeek,
- at2.isAllowedToWork
+ at2.isAllowedToWork,
+ u.userFk
FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk
- JOIN tmp.`user` u ON u.userFK = w.userFK
+ JOIN tmp.`user` u ON u.userFK = w.id
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
LEFT JOIN calendarType ct ON ct.id = b.calendarTypeFk
LEFT JOIN businessSchedule bs ON bs.businessFk = b.id AND bs.weekday = WEEKDAY(t.dated) + 1
LEFT JOIN calendar c ON c.businessFk = b.id AND c.dated = t.dated
LEFT JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY w.userFk, t.dated
+ GROUP BY w.id, t.dated
)sub;
UPDATE tmp.timeBusinessCalculate t
@@ -72895,6 +73396,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72902,35 +73405,31 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vDatedFrom workerTimeControl
- * @param vDatedTo workerTimeControl
+ * @param vDatedFrom Fecha desde
+ * @param vDatedTo Fecha hasta
*/
- DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
- SELECT userFk
- FROM vn.worker w
- JOIN account.`user` u ON u.id = w.userFk
- WHERE userFk IS NOT NULL;
-
+ CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
+ SELECT w.id userFk
+ FROM vn.worker w;
+
CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72938,27 +73437,25 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vDepartmentFk
+ * @param vDepartmentFk
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
*/
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
+
CREATE TEMPORARY TABLE tmp.`user`
SELECT DISTINCT b.workerFk userFk
- FROM business AS b
- WHERE (b.started BETWEEN vDatedFrom AND vDatedTo
+ FROM business AS b
+ WHERE (b.started BETWEEN vDatedFrom AND vDatedTo
OR IFNULL(b.ended, vDatedTo) BETWEEN vDatedFrom AND vDatedTo
OR (b.started <= vDatedFrom AND b.ended >= vDatedTo)
) AND b.departmentFk = vDepartmentFk
ORDER BY b.ended DESC;
-
+
CALL timeBusiness_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`;
@@ -72969,6 +73466,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72976,26 +73475,24 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vUserFk
+ * @param vUserFk
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
*/
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
+
CREATE TEMPORARY TABLE tmp.`user`
SELECT id userFk
- FROM account.user
- WHERE id = vUserFk;
+ FROM account.user
+ WHERE id = vUserFk;
CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo);
-
+
DROP TEMPORARY TABLE tmp.`user`;
END ;;
@@ -73004,6 +73501,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73011,29 +73510,24 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
* @param vWorkerFk
- * @param vDatedFrom workerTimeControl
- * @param vDatedTo workerTimeControl
+ * @param vDatedFrom Fecha desde
+ * @param vDatedTo Fecha hasta
*/
-
- DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
- CREATE TEMPORARY TABLE tmp.`user`
- SELECT u.id userFk
- FROM account.user u
- JOIN vn.worker w ON w.userFk = u.id
- WHERE w.id = vWorkerFk;
-
- CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo);
-
- DROP TEMPORARY TABLE tmp.`user`;
+
+ CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
+ SELECT w.id userFk
+ FROM worker w
+ WHERE w.id = vWorkerFk;
+
+ CALL timeBusiness_calculate(vDatedFrom, vDatedTo);
+
+ DROP TEMPORARY TABLE tmp.`user`;
END ;;
DELIMITER ;
@@ -73041,6 +73535,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73048,34 +73544,32 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`(
- vDatedFrom DATETIME,
+ vDatedFrom DATETIME,
vDatedTo DATETIME)
BEGIN
/*
* @param vDatedFrom
- * @param vDatedTo
- * Cálculo de horas trabajadas por empleado y día,
+ * @param vDatedTo
+ * Cálculo de horas trabajadas por empleado y día,
* sin tener en cuenta los días con fichadas incorrectas (tabla tmp.timeControlError)
- * En el caso de haber hecho descanso y trabajado un mínimo de tiempo (vTimeToBreakTime),
+ * En el caso de haber hecho descanso y trabajado un mínimo de tiempo (vTimeToBreakTime),
* se añade al tiempo de trabajo efectivo el descanso (vBreakTime)
- * @return tmp.timeControlCalculate
+ * @return tmp.timeControlCalculate
* (workerFk, dated, timeWorkSeconds, timeWorkSexagesimal, timeWorkDecimal, timed)
*/
DECLARE vHourToSeconds INTEGER;
DECLARE vDatedFromYesterday DATETIME;
- DECLARE vDatedToTomorrow DATETIME;
+ DECLARE vDatedToTomorrow DATETIME;
DECLARE vTimeToBreakTime INT;
DECLARE vBreakTime INT;
-
- SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY)
+
+ SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY)
INTO vDatedFromYesterday, vDatedToTomorrow;
-
+
SELECT timeToBreakTime, breakTime INTO vTimeToBreakTime, vBreakTime
- FROM workerTimeControlConfig
+ FROM workerTimeControlConfig
LIMIT 1;
CALL timeControl_getError(vDatedFrom, vDatedTo);
@@ -73084,9 +73578,9 @@ BEGIN
CREATE TEMPORARY TABLE tmp.workerTimeControl
(INDEX (userFk), INDEX (timed))
ENGINE = MEMORY
- SELECT DISTINCT(wtc.id),
- wtc.userFk,
- wtc.timed,
+ SELECT DISTINCT(wtc.id),
+ wtc.userFk,
+ wtc.timed,
wtc.direction,
TRUE isReal
FROM workerTimeControl wtc
@@ -73096,10 +73590,10 @@ BEGIN
AND tce.id IS NULL
ORDER BY wtc.userFk, wtc.timed ASC;
- SELECT MAX(id) INTO @vCont
+ SELECT MAX(id) INTO @vCont
FROM tmp.workerTimeControl;
- DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux;
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux;
CREATE TEMPORARY TABLE tmp.workerTimeControlAux (
`id` int(11) ,
`userFk` int(10) unsigned ,
@@ -73112,14 +73606,14 @@ BEGIN
-- Cambio de dia en medio de un descanso
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
- SELECT @vCont:= @vCont + 1 id,
- userFk,
- util.dayEnd(dated) timed,
+ SELECT @vCont:= @vCont + 1 id,
+ userFk,
+ util.dayEnd(dated) timed,
'middle' direction
FROM(SELECT wtc.userFk,
DATE(@lastTimed) dated,
(@vIsOdd := NOT @vIsOdd) isOdd,
- IF(@vIsOdd AND wtc.direction = 'middle'
+ IF(@vIsOdd AND wtc.direction = 'middle'
AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak,
@lastTimed := wtc.timed
FROM tmp.workerTimeControl wtc
@@ -73132,14 +73626,14 @@ BEGIN
SET @vIsOdd := FALSE;
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
- SELECT @vCont:= @vCont + 1,
- userFk,
- DATE_ADD(sub.dated, INTERVAL 1 DAY),
+ SELECT @vCont:= @vCont + 1,
+ userFk,
+ DATE_ADD(sub.dated, INTERVAL 1 DAY),
'middle'
FROM(SELECT wtc.userFk,
DATE(@lastTimed) dated,
(@vIsOdd := NOT @vIsOdd) isOdd,
- IF(@vIsOdd AND wtc.direction = 'middle'
+ IF(@vIsOdd AND wtc.direction = 'middle'
AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak,
@lastTimed := wtc.timed
FROM tmp.workerTimeControl wtc
@@ -73150,9 +73644,9 @@ BEGIN
-- Cambio de dia
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
- SELECT @vCont:= @vCont + 1 id,
- sub.userFk,
- util.dayEnd(sub.dated) timed,
+ SELECT @vCont:= @vCont + 1 id,
+ sub.userFk,
+ util.dayEnd(sub.dated) timed,
'out' direction
FROM (SELECT MAX(wtc.timed) timed, wtc.userFk, date(wtc.timed) dated
FROM workerTimeControl wtc
@@ -73162,7 +73656,7 @@ BEGIN
AND tce.id IS NULL
GROUP BY wtc.userFk, DATE(wtc.timed)
) sub
- JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed
+ JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed
AND wtc.userFk = sub.userFk
WHERE wtc.direction <> 'out';
@@ -73176,7 +73670,7 @@ BEGIN
AND tce.id IS NULL
GROUP BY wtc.userFk, DATE(wtc.timed)
) sub
- JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed
+ JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed
AND wtc.userFk = sub.userFk
WHERE wtc.direction <> 'out';
@@ -73193,7 +73687,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.workerBreakDays
(INDEX (userFk), INDEX (dated))
ENGINE = MEMORY
- SELECT sub.userFk,
+ SELECT sub.userFk,
sub.dated
FROM (SELECT (@vIsOdd := NOT @vIsOdd),
IF(wtc.direction = 'in', @vIsOdd := TRUE, NULL),
@@ -73202,7 +73696,7 @@ BEGIN
IF(direction='in', @vDated := DATE(wtc.timed), @vDated) dated,
wtc.userFk
FROM tmp.workerTimeControl wtc
- ORDER BY wtc.userFk, wtc.timed, wtc.id
+ ORDER BY wtc.userFk, wtc.timed, wtc.id
LIMIT 10000000000000000000
)sub
GROUP BY sub.userFk, sub.dated
@@ -73213,9 +73707,9 @@ BEGIN
SET @vLastTimed := 0;
DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux2;
- CREATE TEMPORARY TABLE tmp.workerTimeControlAux2
+ CREATE TEMPORARY TABLE tmp.workerTimeControlAux2
SELECT *
- FROM tmp.workerTimeControl
+ FROM tmp.workerTimeControl
WHERE timed BETWEEN vDatedFromYesterday AND vDatedTo
ORDER BY userFk, timed, id;
@@ -73228,7 +73722,7 @@ BEGIN
IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork) timeWorkSeconds,
SEC_TO_TIME(IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork)) timeWorkSexagesimal,
(IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork)) / vHourToSeconds timeWorkDecimal,
- CAST(GROUP_CONCAT(DATE_FORMAT(sub.realTimed, "%H:%i")
+ CAST(GROUP_CONCAT(DATE_FORMAT(sub.realTimed, "%H:%i")
ORDER BY sub.timed ASC SEPARATOR ' - ') AS CHAR(256)) timed
FROM (SELECT (@vIsOdd := NOT @vIsOdd),
IF(direction='in', @vIsOdd := TRUE, 0),
@@ -73255,6 +73749,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73262,35 +73758,31 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vDatedFrom workerTimeControl
- * @param vDatedTo workerTimeControl
+ * @param vDatedFrom Fecha desde
+ * @param vDatedTo Fecha hasta
*/
- DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
- SELECT userFk
- FROM vn.worker w
- JOIN account.`user` u ON u.id = w.userFk
- WHERE userFk IS NOT NULL;
-
+ CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
+ SELECT w.id userFk
+ FROM vn.worker w;
+
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73298,27 +73790,25 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vDepartmentFk
+ * @param vDepartmentFk
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
*/
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
+
CREATE TEMPORARY TABLE tmp.`user`
SELECT DISTINCT b.workerFk userFk
- FROM business AS b
- WHERE (b.started BETWEEN vDatedFrom AND vDatedTo
+ FROM business AS b
+ WHERE (b.started BETWEEN vDatedFrom AND vDatedTo
OR IFNULL(b.ended, vDatedTo) BETWEEN vDatedFrom AND vDatedTo
OR (b.started <= vDatedFrom AND b.ended >= vDatedTo)
) AND b.departmentFk = vDepartmentFk
ORDER BY b.ended DESC;
-
+
CALL timeControl_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`;
@@ -73329,6 +73819,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73336,26 +73828,24 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vUserFk
+ * @param vUserFk
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
*/
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
+
CREATE TEMPORARY TABLE tmp.`user`
SELECT id userFk
- FROM account.user
- WHERE id = vUserFk;
+ FROM account.user
+ WHERE id = vUserFk;
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo);
-
+
DROP TEMPORARY TABLE tmp.`user`;
END ;;
@@ -73364,6 +73854,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73371,28 +73863,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
- * @param vWorkerFk
+ * @param vWorkerFk
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
*/
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
-
+
CREATE TEMPORARY TABLE tmp.`user`
SELECT u.id userFk
FROM account.user u
JOIN vn.worker w ON w.userFk = u.id
WHERE w.id = vWorkerFk;
-
+
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo);
-
+
DROP TEMPORARY TABLE tmp.`user`;
END ;;
@@ -73401,6 +73891,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeControl_getError` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73408,19 +73900,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/*
* @param vDatedFrom
- * @param vDatedTo
+ * @param vDatedTo
* @table tmp.`user`(userFk)
* Fichadas incorrectas de las cuales no se puede calcular horas trabajadas
* @return tmp.timeControlError (id)
*/
- DECLARE vDayMaxTime INTEGER;
+ DECLARE vDayMaxTime INTEGER;
SET @journeyCounter := 0;
SET @lastUserFk := NULL;
@@ -73428,16 +73918,16 @@ BEGIN
SELECT dayMaxTime INTO vDayMaxTime
FROM workerTimeControlConfig LIMIT 1;
- DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
- CREATE TEMPORARY TABLE tmp.timeControl
+ DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
+ CREATE TEMPORARY TABLE tmp.timeControl
(INDEX(id), INDEX(journeyCounter))
ENGINE = MEMORY
SELECT sub.id,
- sub.direction,
+ 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)
+ @lastUserFk := sub.userFk workerFk,
+ IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE)
FROM (
SELECT DISTINCT wtc.id,
wtc.direction,
@@ -73448,42 +73938,44 @@ BEGIN
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;
+
+ 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
+ DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError;
+ CREATE TEMPORARY TABLE tmp.timeControlError
(INDEX(id))
ENGINE = MEMORY
- SELECT id
+ SELECT id
FROM tmp.timeControlAux tca
JOIN (
- SELECT journeyCounter,
+ SELECT journeyCounter,
UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
- SUM(direction = 'in') totalIn,
+ 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
+ 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;
+ DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
+ DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `timeWorkerControl_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73491,8 +73983,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
proc: BEGIN
@@ -73500,13 +73990,15 @@ proc: BEGIN
* deprecated call workerTimeControl_check
*/
CALL vn.workerTimeControl_check(vUserFk,vDated,vTabletFk);
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_checkStatus` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73514,8 +74006,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_checkStatus`()
BEGIN
@@ -73525,25 +74015,27 @@ BEGIN
* trasladados a la ficha del cliente.
*
*/
- INSERT INTO mail (receiver,replyTo,subject,body)
- SELECT 'administracion@verdnatura.es',
+ INSERT INTO mail (receiver, replyTo, subject, body)
+ SELECT 'administracion@verdnatura.es, finanzas@verdnatura.es',
'noreply@verdnatura.es',
- CONCAT('Cobro web no trasladado a la ficha del cliente ', t.clientFk),
- CONCAT('Hay un importe de ', t.amount/100, '€ del cliente ', t.clientFk, ' con fecha ', t.created,
+ CONCAT('Cobro web no trasladado a la ficha del cliente ', clientFk),
+ CONCAT('Hay un importe de ', amount / 100, '€ del cliente ', clientFk, ' con fecha ', created,
', que no se ha trasladado a recibos. Si nos ha llegado el importe al banco confirme el pago en
-
- https://salix.verdnatura.es/#!/client/',t.clientFk,'/web-payment')
- FROM hedera.tpvTransaction t
- WHERE t.receiptFk IS NULL
- AND t.status = 'ok'
- AND t.created < DATE_ADD(util.VN_NOW(),INTERVAL - 2 DAY)
- GROUP BY t.clientFk;
+
+ https://salix.verdnatura.es/#!/client/', clientFk, '/web-payment')
+ FROM hedera.tpvTransaction
+ WHERE receiptFk IS NULL
+ AND status = 'ok'
+ AND created < (util.VN_NOW() - INTERVAL 2 DAY)
+ GROUP BY clientFk;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travelVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73551,17 +74043,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume`(vTravelFk INT)
BEGIN
-
- SELECT w1.name AS ORI,
- w2.name AS DES,
+
+ SELECT w1.name AS ORI,
+ w2.name AS DES,
tr.shipped shipment,
tr.landed landing,
- a.name Agencia,
+ a.name Agencia,
s.name Proveedor,
e.id Id_Entrada,
e.invoiceNumber Referencia,
@@ -73569,24 +74059,26 @@ BEGIN
vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.supplier s ON s.id = e.supplierFk
- JOIN vn.travel tr ON tr.id = e.travelFk
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.supplier s ON s.id = e.supplierFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
JOIN vn.agencyMode a ON a.id = tr.agencyModeFk
- JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk
- JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk
- JOIN vn.volumeConfig vc
- JOIN vn.item i ON i.id = b.itemFk
+ JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk
+ JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk
+ JOIN vn.volumeConfig vc
+ JOIN vn.item i ON i.id = b.itemFk
JOIN vn.itemType it ON it.id = i.typeFk
WHERE tr.id = vTravelFk;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travelVolume_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73594,8 +74086,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT)
BEGIN
@@ -73617,6 +74107,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_checkDates` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73624,8 +74116,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkDates`(vShipped DATE, vLanded DATE)
BEGIN
@@ -73636,17 +74126,19 @@ BEGIN
* @param vShipped The shipment date
* @param vLanded The landing date
*/
-
+
IF vLanded < vShipped THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Landing cannot be lesser than shipment';
- END IF;
+ END IF;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_checkPackaging` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73654,8 +74146,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkPackaging`(vSelf INT)
BEGIN
@@ -73690,6 +74180,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_checkWarehouseIsFeedStock` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73697,14 +74189,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkWarehouseIsFeedStock`(vWarehouseFk INT)
proc: BEGIN
/*
* Check that the warehouse is not Feed Stock
- *
+ *
* @vWarehouseFk param warehouse id
*/
IF vWarehouseFk IS NULL THEN
@@ -73720,6 +74210,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_clone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73727,8 +74219,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT)
BEGIN
@@ -73781,6 +74271,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_cloneWithEntries` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73788,17 +74280,15 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_cloneWithEntries`(
- IN vTravelFk INT,
- IN vDateStart DATE,
+ IN vTravelFk INT,
+ IN vDateStart DATE,
IN vDateEnd DATE,
IN vWarehouseOutFk INT,
- IN vWarehouseInFk INT,
- IN vRef VARCHAR(255),
- IN vAgencyModeFk INT,
+ IN vWarehouseInFk INT,
+ IN vRef VARCHAR(255),
+ IN vAgencyModeFk INT,
OUT vNewTravelFk INT)
BEGIN
/**
@@ -73822,29 +74312,29 @@ BEGIN
FROM entry e
JOIN travel t ON t.id = e.travelFk
WHERE e.travelFk = vTravelFk;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
+ BEGIN
ROLLBACK;
RESIGNAL;
END;
-
+
START TRANSACTION;
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
FROM travel
WHERE id = vTravelFk;
-
+
SET vNewTravelFk = LAST_INSERT_ID();
SET vDone = FALSE;
SET @isModeInventory = TRUE;
OPEN vRsEntry;
-
+
l: LOOP
SET vDone = FALSE;
FETCH vRsEntry INTO vAuxEntryFk;
@@ -73875,6 +74365,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73882,8 +74374,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_doRecalc`()
BEGIN
@@ -73913,11 +74403,11 @@ BEGIN
SELECT COUNT(*) INTO vTotalEntries
FROM entry
WHERE travelFk = vTravelFk;
-
+
UPDATE travel
SET totalEntries = vTotalEntries
WHERE id = vTravelFk;
-
+
DELETE FROM travelRecalc WHERE travelFk = vTravelFk;
END LOOP;
@@ -73928,6 +74418,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_getEntriesMissingPackage` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73935,8 +74427,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_getEntriesMissingPackage`(vSelf INT)
BEGIN
@@ -73948,10 +74438,10 @@ BEGIN
WHERE id = vSelf;
SELECT e.id entryFk
- FROM travel t
- JOIN entry e ON e.travelFk = t.id
- JOIN buy b ON b.entryFk = e.id
- WHERE t.id = vTravelFk
+ FROM travel t
+ JOIN entry e ON e.travelFk = t.id
+ JOIN buy b ON b.entryFk = e.id
+ WHERE t.id = vTravelFk
AND (b.packing IS NULL OR b.packageFk IS NULL);
END ;;
DELIMITER ;
@@ -73959,6 +74449,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_moveRaids` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73966,15 +74458,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_moveRaids`()
BEGIN
/*
* Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores
- *
+ *
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vWorkerName VARCHAR(50);
@@ -73986,7 +74476,7 @@ BEGIN
SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'),
u.name
FROM tmp.travel ttr
- JOIN entry e ON e.travelFk = ttr.id
+ JOIN entry e ON e.travelFk = ttr.id
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
@@ -73994,19 +74484,19 @@ BEGIN
GROUP BY u.name;
DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
+ SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.travel;
CREATE TEMPORARY TABLE tmp.travel
SELECT tr.id,tr.landed
FROM travel tr
- JOIN entry e ON e.travelFk = tr.id
+ JOIN entry e ON e.travelFk = tr.id
WHERE tr.landed = util.tomorrow()
AND e.isRaid
GROUP BY tr.id;
@@ -74044,6 +74534,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_requestRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74051,8 +74543,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_requestRecalc`(vSelf INT)
proc: BEGIN
@@ -74064,7 +74554,7 @@ proc: BEGIN
IF vSelf IS NULL THEN
LEAVE proc;
END IF;
-
+
INSERT IGNORE INTO travelRecalc SET travelFk = vSelf;
END ;;
DELIMITER ;
@@ -74072,6 +74562,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_updatePacking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74079,8 +74571,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_updatePacking`(vItemFk INT, vPacking INT)
BEGIN
@@ -74090,10 +74580,10 @@ BEGIN
* @param vItemFk id del item
* @param vPacking nuevo packing
*/
-
+
DECLARE vAuctionWarehouseFk INT;
DECLARE vMainWarehouseFk INT;
-
+
SELECT warehouseFk INTO vAuctionWarehouseFk
FROM auctionConfig;
@@ -74114,6 +74604,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_weeklyClone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74121,8 +74613,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek INT)
BEGIN
@@ -74153,7 +74643,7 @@ BEGIN
FROM travelClonedWeekly
WHERE travelFk;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SET vCounter = vSinceWeek;
@@ -74200,6 +74690,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `typeTagMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74207,20 +74699,18 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `typeTagMake`(vTypeFk INT)
BEGIN
/*
* Plantilla para modificar reemplazar todos los tags
* por los valores que tienen los articulos
- *
+ *
* @param vTypeFk tipo a modificar
- *
+ *
*/
- DELETE it.*
- FROM itemTag it
+ DELETE it.*
+ FROM itemTag it
JOIN item i ON i.id = it.itemFk
WHERE i.typeFk = vTypeFk;
@@ -74229,40 +74719,40 @@ BEGIN
FROM item i
JOIN tag t ON t.name = 'Longitud' COLLATE utf8_general_ci
WHERE i.typeFk = vTypeFk;
-
+
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, i.category, 5
FROM item i
JOIN tag t ON t.name = 'Categoria' COLLATE utf8_general_ci
WHERE i.typeFk = vTypeFk;
-
+
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, ink.name, 2
FROM item i
JOIN tag t ON t.name = 'Color' COLLATE utf8_general_ci
JOIN ink ON ink.id = i.inkFk
WHERE i.typeFk = vTypeFk;
-
+
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, p.name, 3
FROM item i
JOIN tag t ON t.name = 'Productor' COLLATE utf8_general_ci
JOIN producer p ON p.id = i.producerFk
- WHERE i.typeFk = vTypeFk;
-
+ WHERE i.typeFk = vTypeFk;
+
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, o.name, 4
FROM item i
JOIN tag t ON t.name = 'Origen' COLLATE utf8_general_ci
JOIN origin o ON o.id = i.originFk
WHERE i.typeFk = vTypeFk;
- /*
+ /*
INSERT INTO itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, i.stems, 6
FROM item i
JOIN tag t ON t.name = 'Tallos' COLLATE utf8_general_ci
- WHERE i.typeFk = vTypeFk;
- */
+ WHERE i.typeFk = vTypeFk;
+ */
-- CALL itemTagArrangedUpdate(NULL);
END ;;
@@ -74271,6 +74761,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `updatePedidosInternos` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74278,14 +74770,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `updatePedidosInternos`(vItemFk INT)
BEGIN
UPDATE vn.item SET upToDown = 0 WHERE item.id = vItemFk;
-
+
END ;;
DELIMITER ;
@@ -74293,6 +74783,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `vehicle_checkNumberPlate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74300,8 +74792,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2))
BEGIN
@@ -74313,7 +74803,7 @@ BEGIN
SELECT vp.regex INTO vRegex
FROM vehiclePlateRegex vp
WHERE vp.countryCodeFk = vCountryCodeFk;
-
+
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
CALL util.throw(CONCAT('Error: la matricula ', vNumberPlate, ' no es valida para ',vCountryCodeFk));
END IF;
@@ -74323,6 +74813,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `vehicle_notifyEvents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74330,8 +74822,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vehicle_notifyEvents`()
proc:BEGIN
@@ -74346,7 +74836,7 @@ proc:BEGIN
ROLLBACK;
RESIGNAL;
END;
-
+
SELECT eventEarlyDays INTO vEventEarlyDays
FROM vehicleConfig;
@@ -74364,7 +74854,7 @@ proc:BEGIN
IF NOT vHasEvents THEN
LEAVE proc;
END IF;
-
+
START TRANSACTION;
SELECT util.notification_send('vehicle-event-expired',
@@ -74387,6 +74877,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `visible_getMisfit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74394,26 +74886,24 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_getMisfit`(vSectorFk INT)
BEGIN
-
+
/* Devuelve una tabla temporal con los descuadres entre el visible teórico y lo ubicado en la práctica
- *
+ *
* @param vSectorFk Identificador de vn.sector
- *
+ *
* @return tmp.stockMisfit(itemFk, visible, parked)
*/
-
+
DECLARE vCalcVisibleFk INT;
DECLARE vWarehouseFk INT;
SELECT warehouseFk INTO vWarehouseFk
- FROM vn.sector s
+ FROM vn.sector s
WHERE s.id = vSectorFk;
-
+
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, vWarehouseFk);
DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit;
@@ -74426,17 +74916,17 @@ BEGIN
INSERT INTO tmp.stockMisfit(itemFk, parked)
SELECT iss.itemFk , sum(iss.visible )
- FROM vn.itemShelvingStock iss
- JOIN vn.sector s ON s.id = iss.sectorFk
+ FROM vn.itemShelvingStock iss
+ JOIN vn.sector s ON s.id = iss.sectorFk
WHERE vSectorFk IN (s.id, s.sonFk)
GROUP BY iss.itemFk;
-
+
INSERT INTO tmp.stockMisfit(itemFk, visible)
- SELECT v.item_id , v.visible
- FROM cache.visible v
- WHERE v.calc_id = vCalcVisibleFk
+ SELECT v.item_id , v.visible
+ FROM cache.visible v
+ WHERE v.calc_id = vCalcVisibleFk
ON DUPLICATE KEY UPDATE visible = v.visible;
-
+
DELETE FROM tmp.stockMisfit
WHERE visible = parked;
@@ -74446,6 +74936,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `warehouseFitting` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74453,24 +74945,22 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT)
BEGIN
DECLARE vCacheVisibleOriginFk INT;
DECLARE vCacheVisibleDestinyFk INT;
-
+
CALL cache.visible_refresh(vCacheVisibleOriginFk, FALSE, vWhOrigin);
CALL cache.visible_refresh(vCacheVisibleDestinyFk, FALSE, vWhDestiny);
-
+
SELECT i.id itemFk,
i.longName,
i.size,
i.subName,
vOrigin.visible AS Origen,
vDestiny.visible Destino
-
+
FROM vn.item i
JOIN vn.itemType it ON it.id = i.typeFk
LEFT JOIN cache.visible vOrigin ON vOrigin.calc_id = vCacheVisibleOriginFk AND vOrigin.item_id = i.id
@@ -74484,6 +74974,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `warehouseFitting_byTravel` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74491,27 +74983,27 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting_byTravel`(IN vTravelFk INT)
BEGIN
DECLARE vWhOrigin INT;
DECLARE vWhDestiny INT;
-
+
SELECT warehouseInFk, warehouseOutFk INTO vWhDestiny, vWhOrigin
FROM vn.travel
WHERE id = vTravelFk;
-
+
CALL vn.warehouseFitting(vWhOrigin, vWhDestiny);
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCalculateBoss` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74519,8 +75011,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalculateBoss`(vWorker INT)
BEGIN
@@ -74553,6 +75043,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateBusiness` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74560,8 +75052,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT)
BEGIN
@@ -74569,7 +75059,7 @@ BEGIN
* Calcula los días y horas de vacaciones en función de un contrato y año
*
* @param vYear
- * @param vBusinessFk
+ * @param vBusinessFk
* @return tmp.workerCalendarCalculateBusiness (days, hours, daysEnjoyed, hoursEnjoyed)
*/
DECLARE vStarted DATE;
@@ -74581,17 +75071,17 @@ BEGIN
DECLARE vPayedHolidays DECIMAL(5,2);
DECLARE vDifDays INT;
- SELECT IF(b.started < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.started),
- IF(b.ended IS NULL OR YEAR(b.ended)>vYear , CONCAT(vYear,"-12-31"), b.ended),
+ SELECT IF(b.started < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.started),
+ IF(b.ended IS NULL OR YEAR(b.ended)>vYear , CONCAT(vYear,"-12-31"), b.ended),
IF(wbt.hasHolidayEntitlement, w.days, 0),
c.hoursWeek,
IF(YEAR(b.ended) = vYear, b.payedHolidays, 0) payedHolidays
- INTO vStarted,
- vEnded,
- vDaysHoliday,
+ INTO vStarted,
+ vEnded,
+ vDaysHoliday,
vHoursWeek,
vPayedHolidays
- FROM business b
+ FROM business b
JOIN workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk
JOIN workCenterHoliday w ON w.workcenterFk = b.workcenterFk
LEFT JOIN calendarType c ON c.id = b.calendarTypeFk
@@ -74599,23 +75089,23 @@ BEGIN
AND w.year = vYear;
DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateBusiness;
-
+
IF vStarted < vEnded THEN
SET vDifDays = DAYOFYEAR(vEnded) - DAYOFYEAR(vStarted) + 1;
- SELECT IFNULL(SUM(a.holidayEntitlementRate), 0),
+ SELECT IFNULL(SUM(a.holidayEntitlementRate), 0),
SUM(-(a.discountRate - 1)) + vPayedHolidays
- INTO vDaysToSubtract,
- vDaysHolidayEnjoyed
+ INTO vDaysToSubtract,
+ vDaysHolidayEnjoyed
FROM calendar c
JOIN absenceType a ON a.id = c.dayOffTypeFk
JOIN business b ON b.id = c.businessFk
- WHERE b.id = vBusinessFk
+ WHERE b.id = vBusinessFk
AND YEAR(c.dated) = vYear;
END IF;
- CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness
+ CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness
ENGINE = MEMORY
SELECT @days := IFNULL(ROUND((vDaysHoliday * (vDifDays - vDaysToSubtract) / IF(util.isLeapYear(vYear) , 366, 365)), 1), 0) days,
@days * (vHoursWeek / 5) hours,
@@ -74627,6 +75117,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74634,8 +75126,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT)
BEGIN
@@ -74643,32 +75133,32 @@ BEGIN
/**
* Calcula los días y horas de vacaciones en función de un trabajador y año
*
- * @param vYear
- * @param vWorkerFk
+ * @param vYear
+ * @param vWorkerFk
* @return tmp.workerCalendarCalculateYear (days, hours, daysEnjoyed, hoursEnjoyed)
- */
+ */
DECLARE vDone BOOL;
DECLARE vBusinessFk INT;
DECLARE cur CURSOR FOR
- SELECT b.id
+ SELECT b.id
FROM business b
- WHERE vYear BETWEEN YEAR(b.started) AND IFNULL(YEAR(b.ended), vYear)
+ WHERE vYear BETWEEN YEAR(b.started) AND IFNULL(YEAR(b.ended), vYear)
AND b.workerFk = vWorkerFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
+ SET vDone = TRUE;
+
DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateYear;
CREATE TEMPORARY TABLE tmp.workerCalendarCalculateYear
- (days DEC(5,2),
+ (days DEC(5,2),
hours DEC(5,2),
- daysEnjoyed DEC(5,2),
- hoursEnjoyed DEC(5,2))
+ daysEnjoyed DEC(5,2),
+ hoursEnjoyed DEC(5,2))
ENGINE = MEMORY;
INSERT INTO tmp.workerCalendarCalculateYear VALUES(0, 0, 0, 0);
-
+
OPEN cur;
l: LOOP
@@ -74681,12 +75171,12 @@ BEGIN
CALL workerCalendar_calculateBusiness(vYear, vBusinessFk);
UPDATE tmp.workerCalendarCalculateYear w
- JOIN tmp.workerCalendarCalculateBusiness wc
+ JOIN tmp.workerCalendarCalculateBusiness wc
SET w.days = w.days + wc.days,
w.hours = w.hours + wc.hours,
w.daysEnjoyed = w.daysEnjoyed + wc.daysEnjoyed,
w.hoursEnjoyed = w.hoursEnjoyed + wc.hoursEnjoyed;
-
+
DROP TEMPORARY TABLE tmp.workerCalendarCalculateBusiness;
END LOOP;
@@ -74699,6 +75189,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74706,12 +75198,10 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate`(
vFirstname VARCHAR(50),
- vLastName VARCHAR(50),
+ vLastName VARCHAR(50),
vCode CHAR(3),
vBossFk INT,
vUserFk INT,
@@ -74723,14 +75213,16 @@ BEGIN
* Create new worker
*
*/
- INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk, fi, birth)
- VALUES (vUserFk, vCode, vFirstname, vLastName, vUserFk, vBossFk, vFi, vBirth);
+ INSERT INTO worker(id, code, firstName, lastName, bossFk, fi, birth,userFk)
+ VALUES (vUserFk, vCode, vFirstname, vLastName, vBossFk, vFi, vBirth,vUserFk);
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCreateExternal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74738,8 +75230,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreateExternal`(
vFirstName VARCHAR(50),
@@ -74765,14 +75255,16 @@ BEGIN
SET vSurnames = CONCAT(vSurname1, ' ', vSurname2);
END IF;
- INSERT INTO worker(id, firstName, lastName, code, userFk, isFreelance)
- SELECT vUserId, vFirstName, vSurnames, vWorkerCode, vUserId, true;
+ INSERT INTO worker(id, firstName, lastName, code, isFreelance)
+ SELECT vUserId, vFirstName, vSurnames, vWorkerCode, true;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerDepartmentByDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74780,8 +75272,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDepartmentByDate`(vDate DATE)
BEGIN
@@ -74789,20 +75279,20 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate;
CREATE TEMPORARY TABLE tmp.workerDepartmentByDate
ENGINE = MEMORY
- SELECT w.userFk,
- w.lastName name,
- w.firstName firstname,
- d.name department,
+ SELECT w.id userFk,
+ w.lastName name,
+ w.firstName firstname,
+ d.name department,
d.id departmentFk,
- b.started,
- d.isProduction,
+ b.started,
+ d.isProduction,
CAST(12 * b.amount / ct.hoursWeek / 52 AS DECIMAL(10,2)) costeHora,
w.fi nif
FROM business b
JOIN calendarType ct ON ct.id = b.calendarTypeFk
JOIN department d ON d.id = b.departmentFk
JOIN worker w ON w.id = b.workerFk
- WHERE b.started <= vDate
+ WHERE b.started <= vDate
AND (b.ended > vDate OR b.ended IS NULL);
END ;;
DELIMITER ;
@@ -74810,6 +75300,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerDisable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74817,8 +75309,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int)
mainLabel:BEGIN
@@ -74829,18 +75319,18 @@ mainLabel:BEGIN
DELETE FROM account.account
WHERE id = vUserId;
- UPDATE account.user
+ UPDATE account.user
SET role = 2
- WHERE id = vUserId;
+ WHERE id = vUserId;
- DELETE FROM pbx.sip
- WHERE user_id = vUserId;
+ DELETE FROM pbx.sip
+ WHERE user_id = vUserId;
UPDATE `client` c
JOIN payMethod p ON p.name = 'CONTADO'
SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE
WHERE c.id = vUserId;
-
+
UPDATE `client` c
SET c.salesPersonFk = null
WHERE c.salesPersonFk = vUserId;
@@ -74850,6 +75340,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerDisableAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74857,8 +75349,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisableAll`()
BEGIN
@@ -74869,12 +75359,12 @@ BEGIN
SELECT b.workerFk
FROM business b
JOIN vn.worker w ON w.id = b.workerFk
- JOIN account.account a ON a.id = b.workerFk
- LEFT JOIN (SELECT b.workerFk
+ JOIN account.account a ON a.id = b.workerFk
+ LEFT JOIN (SELECT b.workerFk
FROM business b
WHERE (ended IS NULL OR ended >=util.VN_CURDATE())
)sub ON sub.workerFk = a.id
- LEFT JOIN vn.workerDisableExcluded wd ON wd.workerFk = b.workerFk
+ LEFT JOIN vn.workerDisableExcluded wd ON wd.workerFk = b.workerFk
WHERE sub.workerFk IS NULL
AND wd.workerFk IS NULL
GROUP BY w.id;
@@ -74892,13 +75382,15 @@ BEGIN
END WHILE;
CLOSE rs;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerForAllCalculateBoss` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74906,8 +75398,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerForAllCalculateBoss`()
BEGIN
@@ -74945,6 +75435,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerJourney_replace` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74952,23 +75444,21 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace`(
- vDatedFrom DATE,
- vDatedTo DATE,
+ vDatedFrom DATE,
+ vDatedTo DATE,
vWorkerFk INT)
BEGIN
/**
- * Actualiza la tabla workerJourney para que actue como caché permanente revisable
+ * Actualiza la tabla workerJourney para que actue como caché permanente revisable
* de las jornadas laborales.
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
* @param vWorkerFk, en caso de pasar 0 ó NULL se aplica a todos
- */
+ */
DECLARE vDatedTimeTo DATETIME;
- DECLARE vMaxTimePerDay INT;
+ DECLARE vMaxTimePerDay INT;
DECLARE vMinHoursToBreak DECIMAL(10,2);
DECLARE vBreakHours DECIMAL(10,2);
DECLARE vMonthByYear INT;
@@ -74976,57 +75466,57 @@ BEGIN
DECLARE vMonthsByYear INT DEFAULT 12;
DECLARE vDaysByWeek INT DEFAULT 5;
DECLARE vDatedFromYesterday DATETIME;
- DECLARE vDatedToTomorrow DATETIME;
-
- SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY)
+ DECLARE vDatedToTomorrow DATETIME;
+
+ SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY)
INTO vDatedFromYesterday, vDatedToTomorrow;
SET vDatedTimeTo = util.dayEnd(vDatedTo);
-
- SELECT minHoursToBreak, breakHours, maxTimePerDay
+
+ SELECT minHoursToBreak, breakHours, maxTimePerDay
INTO vMinHoursToBreak, vBreakHours, vMaxTimePerDay
FROM workerTimeControlConfig;
DELETE FROM workerJourney
- WHERE dated BETWEEN vDatedFrom AND vDatedTo
+ WHERE dated BETWEEN vDatedFrom AND vDatedTo
AND NOT isPaid
AND NOT isUpdated
- AND (vWorkerFk IS NULL OR userFK = vWorkerFk);
+ AND (vWorkerFk IS NULL OR userFK = vWorkerFk);
- -- Se inserta todos los días del periodo por worker y business en el rango de fechas.
+ -- Se inserta todos los días del periodo por worker y business en el rango de fechas.
INSERT IGNORE INTO workerJourney(userFk, dated, businessFk)
SELECT b.workerFk, t.dated, b.id
- FROM business b
+ FROM business b
JOIN time t ON t.dated BETWEEN b.started AND IFNULL(b.ended,util.VN_CURDATE())
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
AND (vWorkerFk IS NULL OR b.workerFk = vWorkerFk)
ORDER BY b.workerFk, t.dated, b.id;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
IF vWorkerFk THEN
CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo);
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
- SELECT vWorkerFk userFk;
+ CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
+ SELECT vWorkerFk userFk;
ELSE
CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo);
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
+ CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
SELECT id userFk
FROM worker w;
- END IF;
+ END IF;
UPDATE workerJourney wj
JOIN tmp.timeControlCalculate t ON wj.dated = t.dated AND wj.userFk = t.userFk
- SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak,
- t.timeWorkDecimal - vBreakHours,
+ SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak,
+ t.timeWorkDecimal - vBreakHours,
t.timeWorkDecimal) AS DECIMAL (10,2)),
wj.lunch = IF(t.timeWorkDecimal >= vMinHoursToBreak , vBreakHours , 0)
WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
AND NOT wj.isPaid
AND NOT wj.isUpdated
AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk);
-
- -- NOCTURNIDAD
+
+ -- NOCTURNIDAD
CALL timeControl_getError(vDatedFrom, vDatedTimeTo);
SET @vIsOdd := TRUE;
@@ -75036,9 +75526,9 @@ BEGIN
CREATE TEMPORARY TABLE tmp.workerTimeControl
(INDEX (userFk), INDEX (timed))
ENGINE = MEMORY
- SELECT DISTINCT(wtc.id),
- wtc.userFk,
- wtc.timed,
+ SELECT DISTINCT(wtc.id),
+ wtc.userFk,
+ wtc.timed,
wtc.direction
FROM workerTimeControl wtc
JOIN tmp.`user` w ON w.userFk = wtc.userFk
@@ -75048,10 +75538,10 @@ BEGIN
AND (vWorkerFk IS NULL OR wtc.userFk = vWorkerFk)
ORDER BY wtc.userFk, wtc.timed ASC;
- SELECT MAX(id) INTO @vCont
+ SELECT MAX(id) INTO @vCont
FROM tmp.workerTimeControl;
- DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux;
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux;
CREATE TEMPORARY TABLE tmp.workerTimeControlAux (
`id` int(11) ,
`userFk` int(10) unsigned ,
@@ -75073,9 +75563,9 @@ BEGIN
DATE(@lastTimed) dated,
@lastUserFk lastUserFk,
IF(direction ='middle', @vIsOdd := NOT @vIsOdd, FALSE) isOdd,
- IF(@vIsOdd
- AND @lastDirection = 'middle'
- AND (DATE(@lastTimed) <> date(timed)
+ IF(@vIsOdd
+ AND @lastDirection = 'middle'
+ AND (DATE(@lastTimed) <> date(timed)
OR @lastUserFk <> userFk), TRUE, FALSE) hasBreak,
@lastTimed := wtc.timed,
@lastUserFk := userFk,
@@ -75089,16 +75579,16 @@ BEGIN
SET @lastDirection := NULL;
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
- SELECT @vCont:= @vCont + 1,
- lastUserFk,
- DATE_ADD(sub.dated, INTERVAL 1 DAY),
+ SELECT @vCont:= @vCont + 1,
+ lastUserFk,
+ DATE_ADD(sub.dated, INTERVAL 1 DAY),
'middle'
FROM (SELECT IF(@lastUserFk <> userFk, @vIsOdd := TRUE, NULL),
DATE(@lastTimed) dated,
@lastUserFk lastUserFk,
IF(direction ='middle', @vIsOdd := NOT @vIsOdd, FALSE) isOdd,
- IF(@vIsOdd
- AND @lastDirection = 'middle'
+ IF(@vIsOdd
+ AND @lastDirection = 'middle'
AND (DATE(@lastTimed)<>date(timed)
OR @lastUserFk<>userFk), TRUE, FALSE) hasBreak,
@lastTimed := wtc.timed,
@@ -75111,7 +75601,7 @@ BEGIN
-- Cambio de dia
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
SELECT @vCont:= @vCont + 1,
- wtc.userFk,
+ wtc.userFk,
util.dayEnd(date(wtc.timed)),
'out'
FROM workerTimeControl wtc
@@ -75122,8 +75612,8 @@ BEGIN
GROUP BY wtc.userFk, DATE(wtc.timed);
INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
- SELECT @vCont:= @vCont + 1,
- wtc.userFk,
+ SELECT @vCont:= @vCont + 1,
+ wtc.userFk,
DATE_ADD(date(wtc.timed), INTERVAL 1 DAY),
'in'
FROM workerTimeControl wtc
@@ -75149,8 +75639,8 @@ BEGIN
IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed),
IF(direction='in', @vDated := DATE(wtc.timed), @vDated ) dated,
wtc.userFk,
- IF(UNIX_TIMESTAMP(timed)- @vLastTimed < vMaxTimePerDay,
- workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed),
+ IF(UNIX_TIMESTAMP(timed)- @vLastTimed < vMaxTimePerDay,
+ workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed),
0) NigthlyHours,
@lastUserFk := userFk
FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction
@@ -75163,7 +75653,7 @@ BEGIN
) wtc
ORDER BY wtc.userFk, wtc.timed
)sub
- WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
+ WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY userFk, sub.dated
)night ON night.userFk = wj.userFk AND night.dated = wj.dated
SET wj.nocturn = night.NigthlyHours
@@ -75175,8 +75665,8 @@ BEGIN
UPDATE workerJourney wj
JOIN business b ON b.id = wj.businessFk
JOIN calendarType ct ON ct.id = b.calendarTypeFk
- SET wj.priceOrdinaryHour =
- (vMonthsByYear * b.amount) /
+ SET wj.priceOrdinaryHour =
+ (vMonthsByYear * b.amount) /
(vWeeksByYear * ct.hoursWeek),
wj.contractJourney = ct.hoursWeek / vDaysByWeek
WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
@@ -75184,7 +75674,7 @@ BEGIN
AND NOT wj.isPaid
AND NOT isUpdated;
- -- Precio Extras, Vacaciones y Nocturnas
+ -- Precio Extras, Vacaciones y Nocturnas
UPDATE workerJourney wj
JOIN(SELECT MAX(w.dated), t.dated, w.holidayInc, w.nightInc, w.extraInc
FROM time t
@@ -75208,12 +75698,12 @@ BEGIN
WHERE ct.isPartial
AND wj.dated BETWEEN vDatedFrom AND vDatedTo
AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
+ AND NOT wj.isPaid
AND NOT wj.isUpdated;
-- Ausencias
UPDATE workerJourney wj
- JOIN businessCalendar bc ON bc.businessFk = wj.businessFk
+ JOIN businessCalendar bc ON bc.businessFk = wj.businessFk
AND bc.dated = wj.dated
JOIN absenceType ab ON ab.id = bc.absenceTypeFk
SET wj.permission = ab.permissionRate * wj.contractJourney,
@@ -75228,7 +75718,7 @@ BEGIN
UPDATE workerJourney
SET holiday = IF(DAYNAME(dated)='sábado', 0, total),
contractJourney = 0
- WHERE DAYNAME(dated) IN ('sábado', 'domingo')
+ WHERE DAYNAME(dated) IN ('sábado', 'domingo')
AND dated BETWEEN vDatedFrom AND vDatedTo
AND (vWorkerFk IS NULL OR userFk = vWorkerFk)
AND NOT isPaid
@@ -75237,8 +75727,8 @@ BEGIN
-- Festivos por centro de trabajo
UPDATE workerJourney wj
JOIN calendarHolidays ch ON ch.dated = wj.dated
- JOIN business b ON b.id = wj.businessFk
- AND b.workcenterFk = ch.workcenterFk
+ JOIN business b ON b.id = wj.businessFk
+ AND b.workcenterFk = ch.workcenterFk
SET wj.holiday = wj.total,
wj.permission = wj.contractJourney,
wj.contractJourney = 0
@@ -75248,7 +75738,7 @@ BEGIN
AND NOT wj.isUpdated;
-- Horas extras
- UPDATE workerJourney
+ UPDATE workerJourney
SET extra = lunch + total - contractJourney
WHERE dated BETWEEN vDatedFrom AND vDatedTo
AND (vWorkerFk IS NULL OR userFk = vWorkerFk)
@@ -75266,6 +75756,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerMistakeType_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75273,26 +75765,26 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistakeType_get`()
BEGIN
-
+
/**
* Obtiene los tipos de error para los trabajadores
*/
-
- SELECT code, description
- FROM workerMistakeType
+
+ SELECT code, description
+ FROM workerMistakeType
ORDER BY description;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerMistake_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75300,8 +75792,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10))
BEGIN
@@ -75313,7 +75803,7 @@ BEGIN
*
*/
INSERT INTO vn.workerMistake(userFk, workerMistakeTypeFk)
- VALUES(vWorkerFk, vWorkerMistakeTypeFk);
+ VALUES(vWorkerFk, vWorkerMistakeTypeFk);
END ;;
DELIMITER ;
@@ -75321,6 +75811,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75328,19 +75820,17 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlAdd`(IN vUserFk INT, IN vWarehouseFk INT, IN vDated DATETIME)
BEGIN
/*INSERT INTO workerTimeControl(userFk, timed, manual, warehouseFk)
VALUES(vUserFk, vDated, FALSE, vWarehouseFk);
-
+
CALL vn.workerTimeControlSOWP(vUserFk , vDated);*/
-
+
CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,util.VN_NOW(),FALSE);
-
+
END ;;
DELIMITER ;
@@ -75348,6 +75838,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlPinGenerate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75355,8 +75847,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlPinGenerate`(
vWorkerFk INT)
@@ -75366,14 +75856,16 @@ BEGIN
*
*/
-
-
+
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSetOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75381,8 +75873,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder`()
BEGIN
@@ -75403,6 +75893,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSOWP` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75410,25 +75902,25 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE)
BEGIN
SET @order := 0;
-
- UPDATE workerTimeControl
- SET `order` = @order := @order + 1
- WHERE vUserFk =userFk
+
+ UPDATE workerTimeControl
+ SET `order` = @order := @order + 1
+ WHERE vUserFk =userFk
AND vDated = DATE(timed)
ORDER BY timed;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75436,13 +75928,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL)
BEGIN
-
-
+
+
SELECT workerTimeControl_add(vUserFk,vWarehouseFk,vTimed,vIsManual);
END ;;
DELIMITER ;
@@ -75450,6 +75940,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_calculateOddDays` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75457,8 +75949,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_calculateOddDays`()
BEGIN
@@ -75490,14 +75980,15 @@ BEGIN
LIMIT 10000000000000000000)sub
GROUP BY cont
HAVING cont2 MOD 2 = 1
- )sub2
- JOIN worker w ON w.userFk = sub2.userFk;
+ )sub2;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75505,8 +75996,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
proc: BEGIN
@@ -75531,73 +76020,73 @@ proc: BEGIN
DECLARE vTo VARCHAR(50) DEFAULT NULL;
DECLARE vUserName VARCHAR(50) DEFAULT NULL;
DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
+
+ SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
FROM workerTimeControlParams;
SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
+ FROM workerTimeControl
+ WHERE userFk = vUserFk
AND direction = 'in';
-
+
SELECT MAX(timed) INTO vLastOut
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'out';
+ FROM workerTimeControl
+ WHERE userFk = vUserFk
+ AND direction = 'out';
SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
+ WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
+
SELECT CONCAT(firstName,' ',lastName) INTO vUserName
FROM worker w
WHERE w.id = vUserFk;
IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
+
+ -- VERIFICAR DESCANSO DIARIO
+ IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
SELECT "Descansos 12 h" AS problem;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
LEAVE proc;
- END IF;
-
+ END IF;
+
-- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM workerTimeControl
+ IF (SELECT MOD(COUNT(*),2) -- <>0
+ FROM workerTimeControl
WHERE userFk = vUserFk
AND timed >= vLastIn
- ) THEN
+ ) THEN
SELECT "Dias con fichadas impares" AS problem;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
+ LEAVE proc;
END IF;
-
+
-- VERIFICAR VACACIONES
SELECT at2.name INTO vCalendarStateType
- FROM calendar c
+ FROM calendar c
JOIN business b ON b.id = c.businessFk
JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
WHERE c.dated = util.VN_CURDATE()
AND at2.isAllowedToWork = FALSE
AND b.workerFk = vUserFk
LIMIT 1;
-
+
IF(LENGTH(vCalendarStateType)) THEN
SELECT vCalendarStateType AS problem;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
+ LEAVE proc;
+
END IF;
-
+
-- VERIFICAR CONTRATO EN VIGOR
IF (SELECT COUNT(*)
FROM business b
@@ -75609,44 +76098,44 @@ proc: BEGIN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
+ LEAVE proc;
+
END IF;
-- VERIFICAR DESCANSO SEMANAL
SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
-
+ SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
+
DROP TEMPORARY TABLE IF EXISTS tmp.trash;
CREATE TEMPORARY TABLE tmp.trash
SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
@vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
AND userFk= vUserFk
AND direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
+ ORDER BY timed ASC;
+
+ IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
SELECT "Descansos 36 h" AS problem;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
LEAVE proc;
END IF;
+
+ DROP TEMPORARY TABLE tmp.trash;
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
-
+ ELSE -- DIA ACTUAL
+
-- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
+ SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
FROM workerTimeControl wtc
- WHERE userFk = vUserFk
+ WHERE userFk = vUserFk
AND timed >= vLastIn
ORDER BY timed;
- IF vTimedWorked > vDayWorkMax THEN
+ IF vTimedWorked > vDayWorkMax THEN
SELECT "Jornadas" AS problem;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
@@ -75669,16 +76158,18 @@ proc: BEGIN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
+ LEAVE proc;
END IF;
END IF;*/
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkBreak` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75686,13 +76177,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_checkBreak`(vStarted DATE)
BEGIN
/**
- * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
+ * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
* El sistema verificará el descanso corto en la siguiente semana
* o el largo en las 2 siguientes semanas a partir de la fecha dada
* @param vStarted día inicio de la semana en el que se quiere verificar
@@ -75703,27 +76192,27 @@ BEGIN
DECLARE vShortWeekBreak INT;
DECLARE vLongWeekBreak INT;
- SELECT util.dayEnd(DATE_ADD(vStarted, INTERVAL shortWeekDays DAY)),
+ SELECT util.dayEnd(DATE_ADD(vStarted, INTERVAL shortWeekDays DAY)),
util.dayEnd(DATE_ADD(vStarted, INTERVAL longWeekDays DAY)),
- shortWeekBreak,
+ shortWeekBreak,
longWeekBreak
INTO vShortEnded, vLongEnded, vShortWeekBreak, vLongWeekBreak
FROM workerTimeControlConfig;
-
+
SET @previousTimed:= UNIX_TIMESTAMP(vStarted);
SET @lastUserFk := NULL;
-
+
-- Descanso corto en la semana
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.worker;
CREATE TEMPORARY TABLE tmp.worker
(PRIMARY KEY(workerFk))
ENGINE = MEMORY
SELECT DISTINCT userFk workerFk
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE timed BETWEEN vStarted AND vShortEnded
AND direction IN ('in', 'out');
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.worker2;
CREATE TEMPORARY TABLE tmp.worker2
(PRIMARY KEY(workerFk))
@@ -75736,28 +76225,28 @@ BEGIN
SELECT sub2.userFk workerFk
FROM(SELECT sub.userFk,
IF(sub.userFk <> @lastUserFk,
- @previousTimed:= sub.timed,
+ @previousTimed:= sub.timed,
FALSE),
- IF(sub.timed - @previousTimed >= vShortWeekBreak,
- TRUE,
+ IF(sub.timed - @previousTimed >= vShortWeekBreak,
+ TRUE,
FALSE) hasShortWeekBreak,
@previousTimed:= sub.timed,
@lastUserFk:= sub.userFk
FROM (
SELECT userFk, UNIX_TIMESTAMP(timed) timed
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE timed BETWEEN vStarted AND vShortEnded
AND direction IN ('in', 'out')
- UNION
+ UNION
SELECT w.workerFk,
UNIX_TIMESTAMP(IFNULL(
- MIN(wtc.timed),
+ MIN(wtc.timed),
DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND)))
FROM tmp.worker w
- LEFT JOIN workerTimeControl wtc
- ON wtc.userFk = w.workerFk
- AND wtc.timed BETWEEN vShortEnded
- AND DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND)
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND wtc.timed BETWEEN vShortEnded
+ AND DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND)
GROUP BY w.workerFk
UNION
SELECT w.workerFk,
@@ -75765,10 +76254,10 @@ BEGIN
MAX(wtc.timed),
DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND)))
FROM tmp.worker2 w
- LEFT JOIN workerTimeControl wtc
- ON wtc.userFk = w.workerFk
- AND wtc.timed BETWEEN
- DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND)
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND wtc.timed BETWEEN
+ DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND)
AND vStarted
GROUP BY w.workerFk
ORDER BY userFk, timed
@@ -75778,7 +76267,7 @@ BEGIN
GROUP BY sub2.userFk
HAVING NOT SUM(hasShortWeekBreak);
- -- Descanso largo en las 2 siguientes semanas
+ -- Descanso largo en las 2 siguientes semanas
DROP TEMPORARY TABLE tmp.worker;
CREATE TEMPORARY TABLE tmp.worker
(PRIMARY KEY(workerFk))
@@ -75798,12 +76287,12 @@ BEGIN
(PRIMARY KEY(workerFk))
ENGINE = MEMORY
SELECT sub2.userFk workerFk
- FROM(SELECT userFk,
+ FROM(SELECT userFk,
IF(userFk <> @lastUserFk,
- @previousTimed:= timed,
+ @previousTimed:= timed,
TRUE),
- IF(timed - @previousTimed >= vLongWeekBreak,
- TRUE,
+ IF(timed - @previousTimed >= vLongWeekBreak,
+ TRUE,
FALSE) hasLongWeekBreak,
@previousTimed:= timed,
@lastUserFk:= userFk
@@ -75812,24 +76301,24 @@ BEGIN
JOIN tmp.workerWithoutShortWeekBreak wws ON wws.workerFk = wtc.userFk
WHERE timed BETWEEN vStarted AND vLongEnded
AND direction IN ('in', 'out')
- UNION
+ UNION
SELECT w.workerFk,
- UNIX_TIMESTAMP(IFNULL(MIN(wtc.timed),
+ UNIX_TIMESTAMP(IFNULL(MIN(wtc.timed),
DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND)))
FROM tmp.worker w
- LEFT JOIN workerTimeControl wtc
- ON wtc.userFk = w.workerFk
- AND timed BETWEEN vLongEnded
- AND DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND)
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND timed BETWEEN vLongEnded
+ AND DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND)
GROUP BY w.workerFk
UNION
- SELECT w.workerFk,
- UNIX_TIMESTAMP(IFNULL(MAX(wtc.timed),
+ SELECT w.workerFk,
+ UNIX_TIMESTAMP(IFNULL(MAX(wtc.timed),
DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND)))
FROM tmp.worker2 w
- LEFT JOIN workerTimeControl wtc
- ON wtc.userFk = w.workerFk
- AND timed BETWEEN DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND)
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND timed BETWEEN DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND)
AND vStarted
GROUP BY w.workerFk
ORDER BY userFk, timed
@@ -75846,6 +76335,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_clockIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75853,8 +76344,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_clockIn`(
vWorker INT,
@@ -76190,6 +76679,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_direction` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76197,8 +76688,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME)
BEGIN
@@ -76206,27 +76695,27 @@ BEGIN
* Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada
* @param vWorkerFk Identificador del trabajador
* @return (option1, option2)
- * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out')
+ * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out')
*/
DECLARE vLastIn DATETIME ;
DECLARE vIsMiddleOdd BOOLEAN ;
- IF (vTimed IS NULL) THEN
+ IF (vTimed IS NULL) THEN
SET vTimed = util.VN_NOW();
END IF;
-
+
SELECT timed INTO vLastIn
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE userFk = vWorkerFk
- AND direction = 'in'
+ AND direction = 'in'
AND timed < vTimed
ORDER BY timed DESC
LIMIT 1;
-
+
SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE userFk = vWorkerFk
- AND direction = 'middle'
+ AND direction = 'middle'
AND timed BETWEEN vLastIn AND util.VN_NOW();
DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection;
@@ -76264,6 +76753,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_getClockIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76271,11 +76762,9 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_getClockIn`(
- vUserFk INT,
+ vUserFk INT,
vDated DATE)
BEGIN
/**
@@ -76285,9 +76774,9 @@ BEGIN
* @param vDated Fecha proporcionada
*/
CALL timeControl_calculateByWorker(
- vUserFk,
+ vUserFk,
DATE_SUB(vDated, INTERVAL 6 DAY), util.dayEnd(vDated));
-
+
SET @position := 0;
SET @lastDated := NULL;
@@ -76304,7 +76793,7 @@ BEGIN
MAX(2daysAgoDirection) 2daysAgoDirection,
MAX(1daysAgo) 1daysAgo,
MAX(1daysAgoDirection) 1daysAgoDirection,
- MAX(0daysAgo) 0daysAgo,
+ MAX(0daysAgo) 0daysAgo,
MAX(0daysAgoDirection) 0daysAgoDirection
FROM(SELECT IF(daysAgo = 6, timed, '') 6daysAgo,
IF(daysAgo = 5, timed, '') 5daysAgo,
@@ -76324,7 +76813,7 @@ BEGIN
direction,
position
FROM(SELECT DATEDIFF(vDated, timed) daysAgo,
- TIME_FORMAT(timed,'%H:%i') timed,
+ TIME_FORMAT(timed,'%H:%i') timed,
IF(DATE(timed) <> @lastDated, @position := 0, NULL),
@position := @position+1 position,
@lastDated := DATE(timed),
@@ -76336,18 +76825,18 @@ BEGIN
LIMIT 10000000000000000000
)sub
)sub2
- GROUP BY position) sub3
+ GROUP BY position) sub3
JOIN (SELECT MAX(IF(daysAgo = 6, timeWorkSeconds, 0)) 6daysAgoTotal,
MAX(IF(daysAgo = 5, timeWorkSeconds, 0)) 5daysAgoTotal,
MAX(IF(daysAgo = 4, timeWorkSeconds, 0)) 4daysAgoTotal,
MAX(IF(daysAgo = 3, timeWorkSeconds, 0)) 3daysAgoTotal,
MAX(IF(daysAgo = 2, timeWorkSeconds, 0)) 2daysAgoTotal,
MAX(IF(daysAgo = 1, timeWorkSeconds, 0)) 1daysAgoTotal,
- MAX(IF(daysAgo = 0, timeWorkSeconds, 0)) 0daysAgoTotal
+ MAX(IF(daysAgo = 0, timeWorkSeconds, 0)) 0daysAgoTotal
FROM (SELECT DATEDIFF(vDated, dated) daysAgo,
timeWorkSeconds
FROM tmp.timeControlCalculate) sub4)sub5 ON TRUE;
-
+
DROP TEMPORARY TABLE tmp.timeControlCalculate;
END ;;
DELIMITER ;
@@ -76355,6 +76844,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_login` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76362,8 +76853,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_login`(vWorkerFk VARCHAR(10))
BEGIN
@@ -76394,6 +76883,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_remove` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76401,8 +76892,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME)
BEGIN
@@ -76411,51 +76900,53 @@ BEGIN
DECLARE vDirectionPrevious VARCHAR(6);
DECLARE vTimedPrevious DATETIME;
- SELECT direction INTO vDirectionRemove
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
+ SELECT direction INTO vDirectionRemove
+ FROM vn.workerTimeControl
+ WHERE userFk = vUserFk
AND timed = vTimed ;
IF vDirectionRemove = 'out' THEN
-
+
SELECT timed, direction INTO vTimedPrevious, vDirectionPrevious
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
+ FROM vn.workerTimeControl
+ WHERE userFk = vUserFk
AND timed < vTimed
ORDER BY timed DESC
- LIMIT 1;
-
+ LIMIT 1;
+
IF vDirectionPrevious = "middle" THEN
- UPDATE vn.workerTimeControl
+ UPDATE vn.workerTimeControl
SET direction = "out"
WHERE userFk = vUserFk
AND timed = vTimedPrevious;
END IF;
-
+
ELSE IF vDirectionRemove = 'in' THEN
- UPDATE vn.workerTimeControl
+ UPDATE vn.workerTimeControl
SET direction = "in"
WHERE userFk = vUserFk
AND timed > vTimed
ORDER BY timed ASC
- LIMIT 1;
+ LIMIT 1;
END IF;
-
+
END IF;
-
+
DELETE FROM vn.workerTimeControl
- WHERE userFk = vUserFk
+ WHERE userFk = vUserFk
AND timed = vTimed;
-
+
CALL vn.workerTimeControlSOWP(vUserFk, vTimed);
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_repair` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76463,8 +76954,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_repair`()
proc: BEGIN
@@ -76477,37 +76966,39 @@ proc: BEGIN
UPDATE vn.workerTimeControl SET direction = 'middle';
/*2- poner los out*/
-UPDATE vn.workerTimeControl wtc
- JOIN
+UPDATE vn.workerTimeControl wtc
+ JOIN
(SELECT userFk,MAX(timed) maxTimed FROM
(SELECT id, userFk, timed, date(timed) dated
- FROM vn.workerTimeControl
- ) sub
+ FROM vn.workerTimeControl
+ ) sub
GROUP BY userFk,dated
)sub
SET direction = "out"
- WHERE wtc.userFk = sub.userFk
+ WHERE wtc.userFk = sub.userFk
AND wtc.timed = sub.maxTimed;
-
- /*3- poner los in*/
-UPDATE vn.workerTimeControl wtc
- JOIN
+
+ /*3- poner los in*/
+UPDATE vn.workerTimeControl wtc
+ JOIN
(SELECT userFk,MIN(timed) maxTimed FROM
(SELECT id, userFk, timed, date(timed) dated
- FROM vn.workerTimeControl
- ) sub
+ FROM vn.workerTimeControl
+ ) sub
GROUP BY userFk,dated
)sub
SET direction = "in"
- WHERE wtc.userFk = sub.userFk
- AND wtc.timed = sub.maxTimed ;
-
+ WHERE wtc.userFk = sub.userFk
+ AND wtc.timed = sub.maxTimed ;
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76515,8 +77006,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT)
BEGIN
@@ -76550,10 +77039,10 @@ BEGIN
w.lastName,
w.firstname,
c.fi,
- w.id,
+ w.id userFk,
MONTHNAME(t.dated) mes,
YEAR(t.dated) año,
- w.userFk,
+ w.id,
tm.hoursWeek,
tm.type,
b.started,
@@ -76574,7 +77063,7 @@ BEGIN
AND w.businessFk
GROUP BY tm.userFk,t.dated
ORDER BY tm.userFk,t.dated;
-
+
INSERT INTO vn.mail (receiver, replyTo, subject, body)
SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(vDatedFrom), ' año ', YEAR(vDatedFrom)) ,
CONCAT('
@@ -76650,6 +77139,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartmentLauncher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76657,8 +77148,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`()
BEGIN
@@ -76666,7 +77155,7 @@ BEGIN
IF (DAYNAME(util.VN_CURDATE()) = 'miércoles') THEN
SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo;
-
+
CALL vn.workerTimeControl_sendMailByDepartment(vDatedFrom, vDatedTo, NULL);
END IF;
END ;;
@@ -76675,6 +77164,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_setOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76682,8 +77173,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE)
BEGIN
@@ -76703,6 +77192,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_weekCheckBreak` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76710,15 +77201,13 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE)
BEGIN
/**
- * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
- * El sistema verificará el descanso corto en la siguiente semana
- * o el largo en las 2 siguientes semanas a partir de las fechas dadas
+ * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
+ * El sistema verificará el descanso corto en la siguiente semana
+ * o el largo en las 2 siguientes semanas a partir de las fechas dadas
* @param vStarted día inicio para verificar
* @param vEnded día final para verificar
* @return tmp.workerWithoutWeekBreak (workerFk)
@@ -76740,10 +77229,10 @@ BEGIN
CALL workerTimeControl_checkBreak(vStarted);
INSERT IGNORE INTO tmp.workerWithoutWeekBreakInWeek
- SELECT workerFk
+ SELECT workerFk
FROM tmp.workerWithoutWeekBreak;
DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutWeekBreak;
- SET vStarted = DATE_ADD(vStarted, INTERVAL 1 DAY);
+ SET vStarted = DATE_ADD(vStarted, INTERVAL 1 DAY);
END WHILE;
END ;;
@@ -76752,6 +77241,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerWeekControl` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76759,8 +77250,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100))
BEGIN
@@ -76781,7 +77270,7 @@ BEGIN
DECLARE vDepartmentFk INT;
DECLARE isEnabled BOOLEAN DEFAULT TRUE;
- SELECT COUNT(*) INTO vHasSignedToday
+ SELECT COUNT(*) INTO vHasSignedToday
FROM workerTimeControl WHERE timed >= vDated AND userFk = vUserFk;
SET @day := 0;
@@ -76794,16 +77283,16 @@ BEGIN
SELECT fichada_anterior, fichada_actual, interval_in_minutes, jornadas
FROM
(
- SELECT @lastTimed fichada_anterior,
+ SELECT @lastTimed fichada_anterior,
timed,
CAST(time_to_sec(timediff(timed,@lastTimed )) / 60 AS UNSIGNED) as interval_in_minutes,
IF(day(timed) != @day, 1, 0) as jornadas,
@day := day(timed) dia_del_mes,
- @lastTimed := timed fichada_actual
+ @lastTimed := timed fichada_actual
FROM
(
SELECT day(timed) as dayNumber, dayname(timed) as dayName, timed
- FROM
+ FROM
(SELECT TIMESTAMPADD(DAY, -11, util.VN_NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior
UNION ALL
SELECT timed, userFk
@@ -76811,18 +77300,18 @@ BEGIN
WHERE userFk = vUserFk
AND timed >= TIMESTAMPADD(DAY, -10,vDated)
UNION ALL
- SELECT IF(vHasSignedToday, '2000-01-01 00:00', util.VN_NOW()) as timed, vUserFk
+ SELECT IF(vHasSignedToday, '2000-01-01 00:00', util.VN_NOW()) as timed, vUserFk
) sub4
ORDER BY timed
) sub
-
+
) sub2
WHERE fichada_actual >= TIMESTAMPADD(WEEK, -1, vDated)
) sub3 ;
SELECT IFNULL(SUM(impar),0) into vImpares
FROM (
- SELECT day(timed) as dayNumber,
+ SELECT day(timed) as dayNumber,
count(*) mod 2 as impar
FROM vn.workerTimeControl wtc
WHERE userFk = vUserFk
@@ -76839,29 +77328,29 @@ BEGIN
AND at2.isAllowedToWork = FALSE
AND b.workerFk = vUserFk
LIMIT 1;
-
+
-- Contrato en vigor
SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork
FROM business b
WHERE b.workerFk = vUserFk
AND b.started <= vDated
AND IFNULL(b.ended, vDated) >= vDated;
-
+
-- Departamento si vTabletFk es 0 no hacemos comprobacion (Madrid y Vilassar)
IF vTabletFk <> '0' THEN
-- 1 Obtener el departamento del usuario
SELECT wtcu.departmentFk INTO vDepartmentFk
FROM workerTimeControlUserInfo wtcu
WHERE wtcu.userFk = vUserFk;
- -- 2 Comprobar si la tablet pertenece al departamento
+ -- 2 Comprobar si la tablet pertenece al departamento
SELECT COUNT(td.tabletFk) INTO isEnabled
FROM tabletDepartment td
WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk;
-
+
END IF;
-
+
IF vJornadas IS NOT NULL THEN
-
+
SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
UNION ALL
SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis
@@ -76870,9 +77359,9 @@ BEGIN
UNION ALL
SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis
UNION ALL
- SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
- '' as Cantidad,
- IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
+ SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
+ '' as Cantidad,
+ IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
UNION ALL
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
@@ -76886,7 +77375,7 @@ BEGIN
UNION ALL
SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis
UNION ALL
- SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
+ SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
'' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
UNION ALL
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
@@ -76898,6 +77387,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_getFromHasMistake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76905,8 +77396,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getFromHasMistake`(vDepartmentFk INT)
BEGIN
@@ -76916,11 +77405,11 @@ BEGIN
* @param vDepartmentFk id del departamento
*
*/
-
- SELECT w.id,w.firstName, w.lastName,d.name
- FROM worker w
- JOIN workerDepartment wd ON wd.workerFk = w.id
- JOIN department d ON d.id = wd.departmentFk
+
+ SELECT w.id,w.firstName, w.lastName,d.name
+ FROM worker w
+ JOIN workerDepartment wd ON wd.workerFk = w.id
+ JOIN department d ON d.id = wd.departmentFk
WHERE d.id = vDepartmentFk
ORDER BY firstName;
@@ -76930,6 +77419,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_getHierarchy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76937,8 +77428,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getHierarchy`(vBoss INT)
BEGIN
@@ -76951,7 +77440,7 @@ BEGIN
(PRIMARY KEY (workerFk))
ENGINE = MEMORY
SELECT vBoss AS workerFk;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchyList;
CREATE TEMPORARY TABLE tmp.workerHierarchyList
(PRIMARY KEY (workerFk))
@@ -76962,7 +77451,7 @@ BEGIN
WHILE (SELECT COUNT(*) FROM tmp.workerHierarchyList WHERE NOT isChecked) > 0 DO
INSERT INTO tmp.workerHierarchyList
- SELECT w.id, 0
+ SELECT w.id, 0
FROM worker w
JOIN workerHierarchy wh ON wh.workerFk = w.bossFk;
@@ -76973,12 +77462,12 @@ BEGIN
TRUNCATE workerHierarchy;
INSERT INTO workerHierarchy
- SELECT workerFk
+ SELECT workerFk
FROM tmp.workerHierarchyList
WHERE NOT isChecked;
END WHILE;
-
+
DROP TEMPORARY TABLE IF EXISTS workerHierarchy;
END ;;
DELIMITER ;
@@ -76986,6 +77475,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_getSector` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76993,8 +77484,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getSector`()
BEGIN
@@ -77005,8 +77494,8 @@ BEGIN
SELECT s.id,s.description,s.warehouseFk
FROM sector s
- JOIN worker w ON w.sectorFk = s.id
- WHERE w.id = account.myUser_getId();
+ JOIN operator o ON o.sectorFk = s.id
+ WHERE o.workerFk = account.myUser_getId();
END ;;
DELIMITER ;
@@ -77014,6 +77503,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_updateBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77021,8 +77512,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBalance`(vSelfFk INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2))
BEGIN
@@ -77040,6 +77529,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_updateBusiness` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77047,8 +77538,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBusiness`(vSelf INT)
BEGIN
@@ -77068,6 +77557,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `worker_updateChangedBusiness` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77075,8 +77566,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateChangedBusiness`()
BEGIN
@@ -77090,8 +77579,8 @@ BEGIN
DECLARE vDone BOOL;
DECLARE vCursor CURSOR FOR
- SELECT DISTINCT b.workerFk
- FROM business b
+ SELECT DISTINCT b.workerFk
+ FROM business b
WHERE b.started > vBusinessUpdated AND b.started <= vCurdate
OR b.ended >= vBusinessUpdated AND b.ended < vCurdate;
@@ -77121,33 +77610,8 @@ 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_updateSector` */;
-/*!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_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateSector`(vSectorFk INT)
-BEGIN
-/**
- * Actualiza el sector del usuario conectado y borra la impresora asociada al usuario
- *
- * @param vSectorFk id del sector
- */
- UPDATE worker
- SET sectorFk = vSectorFk,
- labelerFk = NULL
- WHERE id = account.myUser_getId();
-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` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77155,16 +77619,14 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHours`(username varchar(255), logon boolean)
BEGIN
DECLARE userid int(11);
-
+
SELECT vn.getUserId(username) INTO userid;
SELECT username, userid;
- IF userid IS NOT NULL THEN
+ IF userid IS NOT NULL THEN
IF (logon) THEN
CALL vn.workingHoursTimeIn(userid);
ELSE
@@ -77177,6 +77639,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workingHoursTimeIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77184,8 +77648,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11))
BEGIN
@@ -77197,6 +77659,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workingHoursTimeOut` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77204,8 +77668,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11))
BEGIN
@@ -77219,6 +77681,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `wrongEqualizatedClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77226,24 +77690,22 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wrongEqualizatedClient`()
BEGIN
SELECT clientFk, c.name, c.isActive, c.isTaxDataChecked, count(ie) as num
FROM vn.client c
- JOIN
+ JOIN
(
- SELECT DISTINCT
+ SELECT DISTINCT
`a`.`clientFk` ,
a.isEqualizated = 0 as ie
-
+
FROM
`vn`.`address` `a`
) sub ON sub.clientFk = c.id
WHERE c.hasToInvoiceByAddress = FALSE
-
+
GROUP BY clientFk
HAVING num > 1
UNION ALL
@@ -77259,6 +77721,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `XDiario_checkDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77266,8 +77730,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_checkDate`(vDate DATE)
proc: BEGIN
@@ -77296,6 +77758,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneClosure_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77303,8 +77767,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneClosure_recalc`()
proc: BEGIN
@@ -77327,27 +77789,27 @@ proc: BEGIN
SELECT scope INTO vScope
FROM zoneConfig;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
(INDEX (id))
ENGINE = MEMORY
SELECT id FROM zone;
-
+
TRUNCATE TABLE zoneClosure;
-
+
WHILE vCounter <= vScope DO
-
+
CALL zone_getOptionsForShipment(vShipped, TRUE);
-
+
REPLACE zoneClosure(zoneFk, dated, `hour`)
- SELECT zoneFk, vShipped, `hour`
+ SELECT zoneFk, vShipped, `hour`
FROM tmp.zoneOption;
-
+
SET vCounter = vCounter + 1;
SET vShipped = TIMESTAMPADD(DAY, 1, vShipped);
END WHILE;
-
+
-- DROP TEMPORARY TABLE tmp.zone;
DO RELEASE_LOCK('vn.zoneClosure_recalc');
END ;;
@@ -77356,6 +77818,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_calcTree` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77363,8 +77827,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTree`()
BEGIN
@@ -77400,6 +77862,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_calcTreeRec` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77407,8 +77871,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTreeRec`(
vSelf INT,
@@ -77441,7 +77903,7 @@ BEGIN
OR (vSelf IS NOT NULL AND parentFk = vSelf);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
+
SET vSons = 0;
OPEN vChildren;
@@ -77452,11 +77914,11 @@ BEGIN
IF vDone THEN
LEAVE myLoop;
END IF;
-
+
SET vIndex = vIndex + 1;
SET vLft = vIndex;
SET vSons = vSons + 1;
-
+
CALL zoneGeo_calcTreeRec(
vChildFk,
CONCAT(vPath, vChildFk, '/'),
@@ -77482,6 +77944,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_checkName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77489,8 +77953,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255))
BEGIN
@@ -77504,6 +77966,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_delete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77511,8 +77975,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_delete`(vSelf INT)
BEGIN
@@ -77530,6 +77992,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_doCalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77537,8 +78001,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_doCalc`()
proc: BEGIN
@@ -77559,7 +78021,7 @@ proc: BEGIN
SELECT isChanged INTO vIsChanged
FROM zoneGeoRecalc;
-
+
IF vIsChanged THEN
UPDATE zoneGeoRecalc SET isChanged = FALSE;
CALL vn.zoneGeo_calcTree;
@@ -77572,6 +78034,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_setParent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77579,8 +78043,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT)
BEGIN
@@ -77601,6 +78063,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_throwNotEditable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77608,8 +78072,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_throwNotEditable`()
BEGIN
@@ -77621,6 +78083,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_excludeFromGeo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77628,8 +78092,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_excludeFromGeo`(vZoneGeo INT)
BEGIN
@@ -77654,6 +78116,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getAgency` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77661,8 +78125,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE)
BEGIN
@@ -77703,6 +78165,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77710,8 +78174,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE)
BEGIN
@@ -77729,6 +78191,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getClosed` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77736,8 +78200,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`()
proc:BEGIN
@@ -77747,7 +78209,7 @@ proc:BEGIN
* @table tmp.closedZones(zoneFk, warehouseFk);
*/
DROP TEMPORARY TABLE IF EXISTS tmp.closedZones;
-
+
CREATE TEMPORARY TABLE tmp.closedZones (
`zoneFk` int(11) NOT NULL,
`warehouseFk` smallint(6) unsigned NOT NULL,
@@ -77776,6 +78238,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getCollisions` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77783,13 +78247,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getCollisions`()
BEGIN
/**
- * Calcula si para un mismo codigo postal y dia
+ * Calcula si para un mismo codigo postal y dia
* hay mas de una zona configurada y manda correo
*
*/
@@ -77798,16 +78260,16 @@ BEGIN
DECLARE vIsDone INT DEFAULT FALSE;
DECLARE vTableCollisions TEXT;
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
- SELECT z.id
+ SELECT z.id
FROM zone z
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE dm.code IN ('AGENCY','DELIVERY');
+ WHERE dm.code IN ('AGENCY','DELIVERY');
CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
@@ -77822,7 +78284,7 @@ BEGIN
PRIMARY KEY zoneFkk (zoneFk, geoFk),
INDEX(geoFk))
ENGINE = MyISAM;
-
+
OPEN cur1;
cur1Loop: LOOP
SET vIsDone = FALSE;
@@ -77830,40 +78292,40 @@ BEGIN
IF vIsDone THEN
LEAVE cur1Loop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
- myLoop: LOOP
+ myLoop: LOOP
SET vGeoFk = NULL;
- SELECT geoFk INTO vGeoFk
+ SELECT geoFk INTO vGeoFk
FROM tmp.zoneNodes zn
WHERE NOT isChecked
LIMIT 1;
-
+
IF vGeoFk IS NULL THEN
LEAVE myLoop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
UPDATE tmp.zoneNodes
- SET isChecked = TRUE
+ SET isChecked = TRUE
WHERE geoFk = vGeoFk;
END LOOP;
END LOOP;
CLOSE cur1;
- DELETE FROM tmp.zoneNodes
+ DELETE FROM tmp.zoneNodes
WHERE sons > 0;
-
+
DROP TEMPORARY TABLE IF EXISTS geoCollision;
CREATE TEMPORARY TABLE geoCollision
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
FROM tmp.zoneNodes zn
JOIN zone z ON z.id = zn.zoneFk
- JOIN zoneWarehouse zw ON z.id = zw.zoneFk
+ JOIN zoneWarehouse zw ON z.id = zw.zoneFk
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
HAVING count(*) > 1;
-
+
SELECT '
C.Postal
@@ -77873,39 +78335,39 @@ BEGIN
Almacén
Salix
' INTO vTableCollisions;
-
- INSERT INTO mail (receiver,replyTo,subject,body)
+
+ INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'pepe@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
CONCAT(vTableCollisions,
GROUP_CONCAT(sub.td SEPARATOR ''),
'
') td
FROM tmp.zoneNodes zn
JOIN zone z ON z.id = zn.zoneFk
JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
JOIN warehouse w ON w.id = gc.warehouseFk) sub;
-
- DROP TEMPORARY TABLE
- geoCollision,
+
+ DROP TEMPORARY TABLE
+ geoCollision,
tmp.zone,
tmp.zoneNodes;
END ;;
@@ -77914,6 +78376,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getEvents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77921,8 +78385,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getEvents`(
vGeoFk INT,
@@ -77980,7 +78442,7 @@ BEGIN
FROM tZone t
JOIN zoneExclusion e ON e.zoneFk = t.id
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
- JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
+ LEFT JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
JOIN zoneGeo zg2 ON zg2.id = vGeoFk
WHERE eg.zoneExclusionFk IS NULL OR zg2.`path` LIKE CONCAT(zg1.`path`,'%');
@@ -77991,6 +78453,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getFromGeo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77998,8 +78462,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getFromGeo`(vGeoFk INT)
BEGIN
@@ -78012,18 +78474,18 @@ BEGIN
DECLARE vChildFk INT DEFAULT vGeoFk;
DECLARE vParentFk INT;
DECLARE vLevel INT DEFAULT 1;
-
+
DROP TEMPORARY TABLE IF EXISTS tNodes;
CREATE TEMPORARY TABLE tNodes
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT vGeoFk id, vLevel `level`;
-
+
myLoop: LOOP
SELECT parentFk INTO vParentFk
FROM zoneGeo
WHERE id = vChildFk;
-
+
SET vChildFk = vParentFk;
SET vLevel = vLevel + 1;
@@ -78031,7 +78493,7 @@ BEGIN
SELECT vChildFk, vLevel
FROM DUAL
WHERE vChildFk IS NOT NULL;
-
+
IF ROW_COUNT() = 0 THEN
LEAVE myLoop;
END IF;
@@ -78060,6 +78522,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getLanded` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78067,8 +78531,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN)
BEGIN
@@ -78120,6 +78582,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getLeaves` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78127,15 +78591,14 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLeaves`(
- vSelf INT,
- vParentFk INT,
- vSearch VARCHAR(255),
- vHasInsert BOOL
+CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`(
+ vSelf INT,
+ vParentFk INT,
+ vSearch VARCHAR(255),
+ vHasInsert BOOL
)
+<<<<<<< HEAD
BEGIN
/**
* Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk.
@@ -78250,129 +78713,130 @@ BEGIN
END IF;
DROP TEMPORARY TABLE tNodes, tZones;
+=======
+BEGIN
+/**
+ * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk.
+ * @param vSelf Id de la zona
+ * @param vParentFk Id del geo a calcular
+ * @param vSearch Cadena a buscar
+ * @param vHasInsert Indica si inserta en tmp.zoneNodes
+ * Optional @table tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
+ */
+ DECLARE vIsNumber BOOL;
+ DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> '';
+
+ CREATE OR REPLACE TEMPORARY TABLE tNodes
+ (UNIQUE (id))
+ ENGINE = MEMORY
+ SELECT id
+ FROM zoneGeo
+ LIMIT 0;
+
+ IF vIsSearch THEN
+ SET vIsNumber = vSearch REGEXP '^[0-9]+$';
+
+ INSERT INTO tNodes
+ SELECT id
+ FROM zoneGeo
+ WHERE (vIsNumber AND `name` = vSearch)
+ OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%'))
+ LIMIT 1000;
+
+ ELSEIF vParentFk IS NULL THEN
+ INSERT INTO tNodes
+ SELECT geoFk
+ FROM zoneIncluded
+ WHERE zoneFk = vSelf;
+ END IF;
+
+ IF vParentFk IS NULL THEN
+ CREATE OR REPLACE TEMPORARY TABLE tChilds
+ (INDEX(id))
+ ENGINE = MEMORY
+ SELECT id FROM tNodes;
+
+ CREATE OR REPLACE TEMPORARY TABLE tParents
+ (INDEX(id))
+ ENGINE = MEMORY
+ SELECT id FROM zoneGeo LIMIT 0;
+
+ myLoop: LOOP
+ DELETE FROM tParents;
+ INSERT INTO tParents
+ SELECT parentFk id
+ FROM zoneGeo g
+ JOIN tChilds c ON c.id = g.id
+ WHERE g.parentFk IS NOT NULL;
+
+ INSERT IGNORE INTO tNodes
+ SELECT id FROM tParents;
+
+ IF NOT ROW_COUNT() THEN
+ LEAVE myLoop;
+ END IF;
+
+ DELETE FROM tChilds;
+ INSERT INTO tChilds
+ SELECT id FROM tParents;
+ END LOOP;
+
+ DROP TEMPORARY TABLE tChilds, tParents;
+ END IF;
+
+ IF NOT vIsSearch THEN
+ INSERT IGNORE INTO tNodes
+ SELECT id
+ FROM zoneGeo
+ WHERE parentFk <=> vParentFk;
+ END IF;
+
+ CREATE OR REPLACE TEMPORARY TABLE tZones
+ SELECT g.id,
+ g.name,
+ g.parentFk,
+ g.sons,
+ NOT g.sons OR `type` = 'country' isChecked,
+ i.isIncluded selected,
+ g.`depth`,
+ vSelf
+ FROM zoneGeo g
+ JOIN tNodes n ON n.id = g.id
+ LEFT JOIN zoneIncluded i ON i.geoFk = g.id
+ AND i.zoneFk = vSelf
+ ORDER BY g.`depth`, selected DESC, g.name;
+
+ IF vHasInsert THEN
+ INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
+ SELECT id,
+ name,
+ parentFk,
+ sons,
+ isChecked,
+ vSelf
+ FROM tZones
+ WHERE selected
+ OR (selected IS NULL AND vParentFk IS NOT NULL);
+ ELSE
+ SELECT id,
+ name,
+ parentFk,
+ sons,
+ selected
+ FROM tZones
+ ORDER BY `depth`, selected DESC, name;
+ END IF;
+
+ DROP TEMPORARY TABLE tNodes, tZones;
+>>>>>>> 08e97b6a19c411bac7301a28ab1e358d4d546af7
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 `zone_getLeaves2` */;
-/*!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_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves2`(vSelf INT, vParentFk INT, vSearch VARCHAR(255))
-BEGIN
-/**
- * Devuelve los geoFk incluidos en la ruta y que sean hijos de parentFk
- * @param vSelf Id de la zona
- * @param vParentFk Id del geo a calcular
- * @param vSearch cadena a buscar
- *
- * @return tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
- *
- */
- DECLARE vIsNumber BOOL;
- DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != '';
-
- DROP TEMPORARY TABLE IF EXISTS tNodes;
- CREATE TEMPORARY TABLE tNodes
- (UNIQUE (id))
- ENGINE = MEMORY
- SELECT id
- FROM zoneGeo
- LIMIT 0;
-
- IF vIsSearch THEN
- SET vIsNumber = vSearch REGEXP '^[0-9]+$';
-
- INSERT INTO tNodes
- SELECT id
- FROM zoneGeo
- WHERE (vIsNumber AND `name` = vSearch)
- OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%'))
- LIMIT 1000;
-
- ELSEIF vParentFk IS NULL THEN
- INSERT INTO tNodes
- SELECT geoFk
- FROM zoneIncluded
- WHERE zoneFk = vSelf;
- END IF;
-
- IF vParentFk IS NULL THEN
- DROP TEMPORARY TABLE IF EXISTS tChilds;
- CREATE TEMPORARY TABLE tChilds
- (INDEX(id))
- ENGINE = MEMORY
- SELECT id
- FROM tNodes;
-
- DROP TEMPORARY TABLE IF EXISTS tParents;
- CREATE TEMPORARY TABLE tParents
- (INDEX(id))
- ENGINE = MEMORY
- SELECT id
- FROM zoneGeo
- LIMIT 0;
-
- myLoop: LOOP
- DELETE FROM tParents;
- INSERT INTO tParents
- SELECT parentFk id
- FROM zoneGeo g
- JOIN tChilds c ON c.id = g.id
- WHERE g.parentFk IS NOT NULL;
-
- INSERT IGNORE INTO tNodes
- SELECT id
- FROM tParents;
-
- IF ROW_COUNT() = 0 THEN
- LEAVE myLoop;
- END IF;
-
- DELETE FROM tChilds;
- INSERT INTO tChilds
- SELECT id
- FROM tParents;
- END LOOP;
-
- DROP TEMPORARY TABLE tChilds, tParents;
- END IF;
-
- IF !vIsSearch THEN
- INSERT IGNORE INTO tNodes
- SELECT id
- FROM zoneGeo
- WHERE parentFk <=> vParentFk;
- END IF;
-
- INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
- SELECT g.id,
- g.`name`,
- g.parentFk,
- g.sons,
- NOT g.sons OR type = 'country',
- vSelf
- FROM zoneGeo g
- JOIN tNodes n ON n.id = g.id
- LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf
- WHERE i.isIncluded = TRUE
- OR (i.isIncluded IS NULL AND vParentFk IS NOT NULL);
-
- DROP TEMPORARY TABLE tNodes;
-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 `zone_getOptionsForLanding` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78380,8 +78844,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN)
BEGIN
@@ -78391,7 +78853,7 @@ BEGIN
* @table tmp.zone(id) The zones ids
* @param vLanded The delivery date
* @return tmp.zoneOption The computed options
- */
+ */
DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
CREATE TEMPORARY TABLE tmp.zoneOption
ENGINE = MEMORY
@@ -78432,13 +78894,13 @@ BEGIN
END
LIMIT 10000000000000000000
) t
- GROUP BY zoneFk;
-
+ GROUP BY zoneFk;
+
DELETE t FROM tmp.zoneOption t
JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
WHERE eg.zoneExclusionFk IS NULL;
-
+
IF NOT vShowExpiredZones THEN
DELETE FROM tmp.zoneOption
WHERE shipped < util.VN_CURDATE()
@@ -78450,6 +78912,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getOptionsForShipment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78457,8 +78921,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN)
BEGIN
@@ -78470,7 +78932,7 @@ BEGIN
* @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options
*/
DECLARE vHour TIME DEFAULT TIME(util.VN_NOW());
-
+
DROP TEMPORARY TABLE IF EXISTS tLandings;
CREATE TEMPORARY TABLE tLandings
(INDEX (eventFk))
@@ -78538,6 +79000,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getPostalCode` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78545,63 +79009,63 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getPostalCode`(vSelf INT)
-BEGIN
-/**
- * Devuelve los códigos postales incluidos en una zona
- */
- DECLARE vGeoFk INT DEFAULT NULL;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes;
- CREATE TEMPORARY TABLE tmp.zoneNodes (
- geoFk INT,
- name VARCHAR(100),
- parentFk INT,
- sons INT,
- isChecked BOOL DEFAULT 0,
- zoneFk INT,
- PRIMARY KEY zoneNodesPk (zoneFk, geoFk),
- INDEX(geoFk))
- ENGINE = MEMORY;
-
- CALL zone_getLeaves(vSelf, NULL , NULL, TRUE);
-
- UPDATE tmp.zoneNodes zn
- SET isChecked = 0
- WHERE parentFk IS NULL;
-
- myLoop: LOOP
- SET vGeoFk = NULL;
- SELECT geoFk INTO vGeoFk
- FROM tmp.zoneNodes zn
- WHERE NOT isChecked
- LIMIT 1;
-
- CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE);
- UPDATE tmp.zoneNodes
- SET isChecked = TRUE
- WHERE geoFk = vGeoFk;
-
- IF vGeoFk IS NULL THEN
- LEAVE myLoop;
- END IF;
- END LOOP;
-
- DELETE FROM tmp.zoneNodes
- WHERE sons > 0;
-
- SELECT zn.geoFk, zn.name
- FROM tmp.zoneNodes zn
- JOIN zone z ON z.id = zn.zoneFk;
+BEGIN
+/**
+ * Devuelve los códigos postales incluidos en una zona
+ */
+ DECLARE vGeoFk INT DEFAULT NULL;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes;
+ CREATE TEMPORARY TABLE tmp.zoneNodes (
+ geoFk INT,
+ name VARCHAR(100),
+ parentFk INT,
+ sons INT,
+ isChecked BOOL DEFAULT 0,
+ zoneFk INT,
+ PRIMARY KEY zoneNodesPk (zoneFk, geoFk),
+ INDEX(geoFk))
+ ENGINE = MEMORY;
+
+ CALL zone_getLeaves(vSelf, NULL , NULL, TRUE);
+
+ UPDATE tmp.zoneNodes zn
+ SET isChecked = 0
+ WHERE parentFk IS NULL;
+
+ myLoop: LOOP
+ SET vGeoFk = NULL;
+ SELECT geoFk INTO vGeoFk
+ FROM tmp.zoneNodes zn
+ WHERE NOT isChecked
+ LIMIT 1;
+
+ CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE);
+ UPDATE tmp.zoneNodes
+ SET isChecked = TRUE
+ WHERE geoFk = vGeoFk;
+
+ IF vGeoFk IS NULL THEN
+ LEAVE myLoop;
+ END IF;
+ END LOOP;
+
+ DELETE FROM tmp.zoneNodes
+ WHERE sons > 0;
+
+ SELECT zn.geoFk, zn.name
+ FROM tmp.zoneNodes zn
+ JOIN zone z ON z.id = zn.zoneFk;
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getShipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78609,8 +79073,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN)
BEGIN
@@ -78626,7 +79088,7 @@ BEGIN
DECLARE vZoneGeo INT;
SELECT address_getGeo(vAddressFk) INTO vZoneGeo;
-
+
CALL vn.zone_getFromGeo(vZoneGeo);
CALL vn.zone_getOptionsForLanding(vLanded, vShowExpiredZones);
CALL vn.zone_excludeFromGeo(vZoneGeo);
@@ -78646,7 +79108,7 @@ BEGIN
FROM tmp.zoneOption zo
JOIN vn.zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
JOIN vn.`zone` z ON z.id = zo.zoneFk
- LEFT JOIN tmp.closedZones cz
+ LEFT JOIN tmp.closedZones cz
ON cz.warehouseFk = zw.warehouseFk
AND cz.zoneFk = zw.zoneFk
AND zo.shipped = util.VN_CURDATE()
@@ -78666,6 +79128,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78673,16 +79137,14 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE)
BEGIN
/**
* Devuelve las zonas y el estado para la fecha solicitada
- *
+ *
* @param vDated Fecha en cuestión
- */
+ */
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone (
@@ -78696,7 +79158,7 @@ BEGIN
CALL vn.zone_getOptionsForShipment(vDated, TRUE);
CALL vn.zone_getClosed();
-
+
SELECT zo.zoneFk,
zo.`hour`etd,
(zo.`hour` <= TIME(util.VN_NOW())) isLate,
@@ -78706,11 +79168,11 @@ BEGIN
FROM tmp.zoneOption zo
JOIN vn.zone z ON z.id = zo.zoneFk
JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id
- LEFT JOIN tmp.closedZones cz
- ON cz.warehouseFk = zw.warehouseFk
+ LEFT JOIN tmp.closedZones cz
+ ON cz.warehouseFk = zw.warehouseFk
AND cz.zoneFk = zo.zoneFk;
-
- DROP TEMPORARY TABLE
+
+ DROP TEMPORARY TABLE
tmp.closedZones,
tmp.zoneOption,
tmp.zone;
@@ -78721,6 +79183,8 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78728,29 +79192,27 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
BEGIN
/**
* Devuelve el listado de agencias disponibles para la fecha,
* dirección y almacén pasados.
- *
+ *
* @param vAddress
* @param vWarehouse warehouse
* @param vLanded Fecha de recogida
* @select Listado de agencias disponibles
*/
-
+
CALL zone_getFromGeo(address_getGeo(vAddress));
CALL zone_getOptionsForLanding(vLanded, FALSE);
-
- SELECT am.id agencyModeFk,
- am.name agencyMode,
- am.description,
+
+ SELECT am.id agencyModeFk,
+ am.name agencyMode,
+ am.description,
am.deliveryMethodFk,
- TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
+ TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
zw.warehouseFk,
z.id zoneFk
FROM tmp.zoneOption zo
@@ -78760,17 +79222,19 @@ BEGIN
WHERE zw.warehouseFk = vWarehouse
GROUP BY z.agencyModeFk
ORDER BY agencyMode;
-
+
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
-
+
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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_upcomingDeliveries` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78778,14 +79242,12 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_upcomingDeliveries`()
BEGIN
DECLARE vForwardDays INT;
-
+
SELECT forwardDays INTO vForwardDays FROM zoneConfig;
CALL util.time_createTable(util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL vForwardDays DAY));
@@ -78801,7 +79263,7 @@ BEGIN
JOIN zoneEvent e ON e.zoneFk = z.id
JOIN tmp.time ti ON ti.dated BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY, vForwardDays, util.VN_CURDATE());
- DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
+ DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
CREATE TEMPORARY TABLE tmp.zoneOption
ENGINE = MEMORY
SELECT *
@@ -78842,7 +79304,7 @@ BEGIN
JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
WHERE eg.zoneExclusionFk IS NULL;
-
+
SELECT MAX(zo.`hour`) `hour`, zg.`name`, zo.shipped, zo.zoneFk
FROM tmp.zoneOption zo
JOIN `zone` z ON z.id = zo.zoneFk
@@ -78853,7 +79315,7 @@ BEGIN
WHERE dm.code = 'DELIVERY'
GROUP BY shipped, zg.`name`
ORDER BY shipped, zg.`name`;
-
+
DROP TEMPORARY TABLE tmp.time, tLandings;
END ;;
DELIMITER ;
@@ -78872,7 +79334,6 @@ USE `account`;
-- Final view structure for view `accountDovecot`
--
-/*!50001 DROP TABLE IF EXISTS `accountDovecot`*/;
/*!50001 DROP VIEW IF EXISTS `accountDovecot`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78891,7 +79352,6 @@ USE `account`;
-- Final view structure for view `emailUser`
--
-/*!50001 DROP TABLE IF EXISTS `emailUser`*/;
/*!50001 DROP VIEW IF EXISTS `emailUser`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78910,7 +79370,6 @@ USE `account`;
-- Final view structure for view `myRole`
--
-/*!50001 DROP TABLE IF EXISTS `myRole`*/;
/*!50001 DROP VIEW IF EXISTS `myRole`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78929,7 +79388,6 @@ USE `account`;
-- Final view structure for view `myUser`
--
-/*!50001 DROP TABLE IF EXISTS `myUser`*/;
/*!50001 DROP VIEW IF EXISTS `myUser`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78955,7 +79413,6 @@ USE `bs`;
-- Final view structure for view `bajasLaborales`
--
-/*!50001 DROP TABLE IF EXISTS `bajasLaborales`*/;
/*!50001 DROP VIEW IF EXISTS `bajasLaborales`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78974,7 +79431,6 @@ USE `bs`;
-- Final view structure for view `lastIndicators`
--
-/*!50001 DROP TABLE IF EXISTS `lastIndicators`*/;
/*!50001 DROP VIEW IF EXISTS `lastIndicators`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -78993,7 +79449,6 @@ USE `bs`;
-- Final view structure for view `packingSpeed`
--
-/*!50001 DROP TABLE IF EXISTS `packingSpeed`*/;
/*!50001 DROP VIEW IF EXISTS `packingSpeed`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79012,7 +79467,6 @@ USE `bs`;
-- Final view structure for view `s1_ticketDetail`
--
-/*!50001 DROP TABLE IF EXISTS `s1_ticketDetail`*/;
/*!50001 DROP VIEW IF EXISTS `s1_ticketDetail`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79031,7 +79485,6 @@ USE `bs`;
-- Final view structure for view `s21_saleDetail`
--
-/*!50001 DROP TABLE IF EXISTS `s21_saleDetail`*/;
/*!50001 DROP VIEW IF EXISTS `s21_saleDetail`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79050,7 +79503,6 @@ USE `bs`;
-- Final view structure for view `ventas`
--
-/*!50001 DROP TABLE IF EXISTS `ventas`*/;
/*!50001 DROP VIEW IF EXISTS `ventas`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79081,7 +79533,6 @@ USE `edi`;
-- Final view structure for view `ektRecent`
--
-/*!50001 DROP TABLE IF EXISTS `ektRecent`*/;
/*!50001 DROP VIEW IF EXISTS `ektRecent`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79100,7 +79551,6 @@ USE `edi`;
-- Final view structure for view `errorList`
--
-/*!50001 DROP TABLE IF EXISTS `errorList`*/;
/*!50001 DROP VIEW IF EXISTS `errorList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79119,7 +79569,6 @@ USE `edi`;
-- Final view structure for view `supplyOffer`
--
-/*!50001 DROP TABLE IF EXISTS `supplyOffer`*/;
/*!50001 DROP VIEW IF EXISTS `supplyOffer`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79144,7 +79593,6 @@ USE `hedera`;
-- Final view structure for view `mainAccountBank`
--
-/*!50001 DROP TABLE IF EXISTS `mainAccountBank`*/;
/*!50001 DROP VIEW IF EXISTS `mainAccountBank`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79163,7 +79611,6 @@ USE `hedera`;
-- Final view structure for view `messageL10n`
--
-/*!50001 DROP TABLE IF EXISTS `messageL10n`*/;
/*!50001 DROP VIEW IF EXISTS `messageL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79182,7 +79629,6 @@ USE `hedera`;
-- Final view structure for view `myAddress`
--
-/*!50001 DROP TABLE IF EXISTS `myAddress`*/;
/*!50001 DROP VIEW IF EXISTS `myAddress`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79202,7 +79648,6 @@ USE `hedera`;
-- Final view structure for view `myBasketDefaults`
--
-/*!50001 DROP TABLE IF EXISTS `myBasketDefaults`*/;
/*!50001 DROP VIEW IF EXISTS `myBasketDefaults`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79221,7 +79666,6 @@ USE `hedera`;
-- Final view structure for view `myClient`
--
-/*!50001 DROP TABLE IF EXISTS `myClient`*/;
/*!50001 DROP VIEW IF EXISTS `myClient`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79241,7 +79685,6 @@ USE `hedera`;
-- Final view structure for view `myInvoice`
--
-/*!50001 DROP TABLE IF EXISTS `myInvoice`*/;
/*!50001 DROP VIEW IF EXISTS `myInvoice`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79260,7 +79703,6 @@ USE `hedera`;
-- Final view structure for view `myMenu`
--
-/*!50001 DROP TABLE IF EXISTS `myMenu`*/;
/*!50001 DROP VIEW IF EXISTS `myMenu`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79279,7 +79721,6 @@ USE `hedera`;
-- Final view structure for view `myOrder`
--
-/*!50001 DROP TABLE IF EXISTS `myOrder`*/;
/*!50001 DROP VIEW IF EXISTS `myOrder`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79299,7 +79740,6 @@ USE `hedera`;
-- Final view structure for view `myOrderRow`
--
-/*!50001 DROP TABLE IF EXISTS `myOrderRow`*/;
/*!50001 DROP VIEW IF EXISTS `myOrderRow`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79319,7 +79759,6 @@ USE `hedera`;
-- Final view structure for view `myOrderTicket`
--
-/*!50001 DROP TABLE IF EXISTS `myOrderTicket`*/;
/*!50001 DROP VIEW IF EXISTS `myOrderTicket`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79338,7 +79777,6 @@ USE `hedera`;
-- Final view structure for view `myTicket`
--
-/*!50001 DROP TABLE IF EXISTS `myTicket`*/;
/*!50001 DROP VIEW IF EXISTS `myTicket`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79357,7 +79795,6 @@ USE `hedera`;
-- Final view structure for view `myTicketRow`
--
-/*!50001 DROP TABLE IF EXISTS `myTicketRow`*/;
/*!50001 DROP VIEW IF EXISTS `myTicketRow`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79377,7 +79814,6 @@ USE `hedera`;
-- Final view structure for view `myTicketService`
--
-/*!50001 DROP TABLE IF EXISTS `myTicketService`*/;
/*!50001 DROP VIEW IF EXISTS `myTicketService`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79397,7 +79833,6 @@ USE `hedera`;
-- Final view structure for view `myTicketState`
--
-/*!50001 DROP TABLE IF EXISTS `myTicketState`*/;
/*!50001 DROP VIEW IF EXISTS `myTicketState`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79416,7 +79851,6 @@ USE `hedera`;
-- Final view structure for view `myTpvTransaction`
--
-/*!50001 DROP TABLE IF EXISTS `myTpvTransaction`*/;
/*!50001 DROP VIEW IF EXISTS `myTpvTransaction`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79435,7 +79869,6 @@ USE `hedera`;
-- Final view structure for view `orderTicket`
--
-/*!50001 DROP TABLE IF EXISTS `orderTicket`*/;
/*!50001 DROP VIEW IF EXISTS `orderTicket`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79454,7 +79887,6 @@ USE `hedera`;
-- Final view structure for view `order_component`
--
-/*!50001 DROP TABLE IF EXISTS `order_component`*/;
/*!50001 DROP VIEW IF EXISTS `order_component`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79473,7 +79905,6 @@ USE `hedera`;
-- Final view structure for view `order_row`
--
-/*!50001 DROP TABLE IF EXISTS `order_row`*/;
/*!50001 DROP VIEW IF EXISTS `order_row`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79498,7 +79929,6 @@ USE `pbx`;
-- Final view structure for view `cdrConf`
--
-/*!50001 DROP TABLE IF EXISTS `cdrConf`*/;
/*!50001 DROP VIEW IF EXISTS `cdrConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79517,7 +79947,6 @@ USE `pbx`;
-- Final view structure for view `followmeConf`
--
-/*!50001 DROP TABLE IF EXISTS `followmeConf`*/;
/*!50001 DROP VIEW IF EXISTS `followmeConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79536,7 +79965,6 @@ USE `pbx`;
-- Final view structure for view `followmeNumberConf`
--
-/*!50001 DROP TABLE IF EXISTS `followmeNumberConf`*/;
/*!50001 DROP VIEW IF EXISTS `followmeNumberConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79555,7 +79983,6 @@ USE `pbx`;
-- Final view structure for view `queueConf`
--
-/*!50001 DROP TABLE IF EXISTS `queueConf`*/;
/*!50001 DROP VIEW IF EXISTS `queueConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79574,7 +80001,6 @@ USE `pbx`;
-- Final view structure for view `queueMemberConf`
--
-/*!50001 DROP TABLE IF EXISTS `queueMemberConf`*/;
/*!50001 DROP VIEW IF EXISTS `queueMemberConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79593,7 +80019,6 @@ USE `pbx`;
-- Final view structure for view `sipConf`
--
-/*!50001 DROP TABLE IF EXISTS `sipConf`*/;
/*!50001 DROP VIEW IF EXISTS `sipConf`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79608,12 +80033,6 @@ USE `pbx`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Current Database: `postgresql`
---
-
-USE `postgresql`;
-
--
-- Current Database: `sage`
--
@@ -79624,7 +80043,6 @@ USE `sage`;
-- Final view structure for view `clientLastTwoMonths`
--
-/*!50001 DROP TABLE IF EXISTS `clientLastTwoMonths`*/;
/*!50001 DROP VIEW IF EXISTS `clientLastTwoMonths`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79643,7 +80061,6 @@ USE `sage`;
-- Final view structure for view `supplierLastThreeMonths`
--
-/*!50001 DROP TABLE IF EXISTS `supplierLastThreeMonths`*/;
/*!50001 DROP VIEW IF EXISTS `supplierLastThreeMonths`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79668,7 +80085,6 @@ USE `salix`;
-- Final view structure for view `Account`
--
-/*!50001 DROP TABLE IF EXISTS `Account`*/;
/*!50001 DROP VIEW IF EXISTS `Account`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79687,7 +80103,6 @@ USE `salix`;
-- Final view structure for view `Role`
--
-/*!50001 DROP TABLE IF EXISTS `Role`*/;
/*!50001 DROP VIEW IF EXISTS `Role`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79706,7 +80121,6 @@ USE `salix`;
-- Final view structure for view `RoleMapping`
--
-/*!50001 DROP TABLE IF EXISTS `RoleMapping`*/;
/*!50001 DROP VIEW IF EXISTS `RoleMapping`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79725,7 +80139,6 @@ USE `salix`;
-- Final view structure for view `User`
--
-/*!50001 DROP TABLE IF EXISTS `User`*/;
/*!50001 DROP VIEW IF EXISTS `User`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79756,7 +80169,6 @@ USE `util`;
-- Final view structure for view `eventLogGrouped`
--
-/*!50001 DROP TABLE IF EXISTS `eventLogGrouped`*/;
/*!50001 DROP VIEW IF EXISTS `eventLogGrouped`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79781,7 +80193,6 @@ USE `vn`;
-- Final view structure for view `NewView`
--
-/*!50001 DROP TABLE IF EXISTS `NewView`*/;
/*!50001 DROP VIEW IF EXISTS `NewView`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79800,7 +80211,6 @@ USE `vn`;
-- Final view structure for view `__coolerPathDetail`
--
-/*!50001 DROP TABLE IF EXISTS `__coolerPathDetail`*/;
/*!50001 DROP VIEW IF EXISTS `__coolerPathDetail`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79819,7 +80229,6 @@ USE `vn`;
-- Final view structure for view `agencyTerm`
--
-/*!50001 DROP TABLE IF EXISTS `agencyTerm`*/;
/*!50001 DROP VIEW IF EXISTS `agencyTerm`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79838,7 +80247,6 @@ USE `vn`;
-- Final view structure for view `annualAverageInvoiced`
--
-/*!50001 DROP TABLE IF EXISTS `annualAverageInvoiced`*/;
/*!50001 DROP VIEW IF EXISTS `annualAverageInvoiced`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79857,7 +80265,6 @@ USE `vn`;
-- Final view structure for view `awbVolume`
--
-/*!50001 DROP TABLE IF EXISTS `awbVolume`*/;
/*!50001 DROP VIEW IF EXISTS `awbVolume`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79876,7 +80283,6 @@ USE `vn`;
-- Final view structure for view `bank`
--
-/*!50001 DROP TABLE IF EXISTS `bank`*/;
/*!50001 DROP VIEW IF EXISTS `bank`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79895,7 +80301,6 @@ USE `vn`;
-- Final view structure for view `bankPolicy`
--
-/*!50001 DROP TABLE IF EXISTS `bankPolicy`*/;
/*!50001 DROP VIEW IF EXISTS `bankPolicy`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79914,7 +80319,6 @@ USE `vn`;
-- Final view structure for view `businessCalendar`
--
-/*!50001 DROP TABLE IF EXISTS `businessCalendar`*/;
/*!50001 DROP VIEW IF EXISTS `businessCalendar`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79933,7 +80337,6 @@ USE `vn`;
-- Final view structure for view `buyer`
--
-/*!50001 DROP TABLE IF EXISTS `buyer`*/;
/*!50001 DROP VIEW IF EXISTS `buyer`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79952,7 +80355,6 @@ USE `vn`;
-- Final view structure for view `buyerSales`
--
-/*!50001 DROP TABLE IF EXISTS `buyerSales`*/;
/*!50001 DROP VIEW IF EXISTS `buyerSales`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79971,7 +80373,6 @@ USE `vn`;
-- Final view structure for view `clientLost`
--
-/*!50001 DROP TABLE IF EXISTS `clientLost`*/;
/*!50001 DROP VIEW IF EXISTS `clientLost`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -79990,7 +80391,6 @@ USE `vn`;
-- Final view structure for view `clientPhoneBook`
--
-/*!50001 DROP TABLE IF EXISTS `clientPhoneBook`*/;
/*!50001 DROP VIEW IF EXISTS `clientPhoneBook`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80009,7 +80409,6 @@ USE `vn`;
-- Final view structure for view `cmr_list`
--
-/*!50001 DROP TABLE IF EXISTS `cmr_list`*/;
/*!50001 DROP VIEW IF EXISTS `cmr_list`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80028,7 +80427,6 @@ USE `vn`;
-- Final view structure for view `companyL10n`
--
-/*!50001 DROP TABLE IF EXISTS `companyL10n`*/;
/*!50001 DROP VIEW IF EXISTS `companyL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80047,7 +80445,6 @@ USE `vn`;
-- Final view structure for view `defaulter`
--
-/*!50001 DROP TABLE IF EXISTS `defaulter`*/;
/*!50001 DROP VIEW IF EXISTS `defaulter`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80066,7 +80463,6 @@ USE `vn`;
-- Final view structure for view `departmentTree`
--
-/*!50001 DROP TABLE IF EXISTS `departmentTree`*/;
/*!50001 DROP VIEW IF EXISTS `departmentTree`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80085,7 +80481,6 @@ USE `vn`;
-- Final view structure for view `ediGenus`
--
-/*!50001 DROP TABLE IF EXISTS `ediGenus`*/;
/*!50001 DROP VIEW IF EXISTS `ediGenus`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80104,7 +80499,6 @@ USE `vn`;
-- Final view structure for view `ediSpecie`
--
-/*!50001 DROP TABLE IF EXISTS `ediSpecie`*/;
/*!50001 DROP VIEW IF EXISTS `ediSpecie`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80123,7 +80517,6 @@ USE `vn`;
-- Final view structure for view `ektSubAddress`
--
-/*!50001 DROP TABLE IF EXISTS `ektSubAddress`*/;
/*!50001 DROP VIEW IF EXISTS `ektSubAddress`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80142,7 +80535,6 @@ USE `vn`;
-- Final view structure for view `exchangeInsuranceEntry`
--
-/*!50001 DROP TABLE IF EXISTS `exchangeInsuranceEntry`*/;
/*!50001 DROP VIEW IF EXISTS `exchangeInsuranceEntry`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80161,7 +80553,6 @@ USE `vn`;
-- Final view structure for view `exchangeInsuranceIn`
--
-/*!50001 DROP TABLE IF EXISTS `exchangeInsuranceIn`*/;
/*!50001 DROP VIEW IF EXISTS `exchangeInsuranceIn`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80180,7 +80571,6 @@ USE `vn`;
-- Final view structure for view `exchangeInsuranceOut`
--
-/*!50001 DROP TABLE IF EXISTS `exchangeInsuranceOut`*/;
/*!50001 DROP VIEW IF EXISTS `exchangeInsuranceOut`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80199,7 +80589,6 @@ USE `vn`;
-- Final view structure for view `exchangeReportSourcePrevious`
--
-/*!50001 DROP TABLE IF EXISTS `exchangeReportSourcePrevious`*/;
/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80218,7 +80607,6 @@ USE `vn`;
-- Final view structure for view `expeditionCommon`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionCommon`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionCommon`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80237,7 +80625,6 @@ USE `vn`;
-- Final view structure for view `expeditionPallet_Print`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionPallet_Print`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionPallet_Print`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80256,7 +80643,6 @@ USE `vn`;
-- Final view structure for view `expeditionRoute_Monitor`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionRoute_Monitor`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionRoute_Monitor`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80275,7 +80661,6 @@ USE `vn`;
-- Final view structure for view `expeditionRoute_freeTickets`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionRoute_freeTickets`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionRoute_freeTickets`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80294,7 +80679,6 @@ USE `vn`;
-- Final view structure for view `expeditionScan_Monitor`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionScan_Monitor`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionScan_Monitor`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80313,7 +80697,6 @@ USE `vn`;
-- Final view structure for view `expeditionSticker`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionSticker`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionSticker`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80332,7 +80715,6 @@ USE `vn`;
-- Final view structure for view `expeditionTicket_NoBoxes`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionTicket_NoBoxes`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionTicket_NoBoxes`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80351,7 +80733,6 @@ USE `vn`;
-- Final view structure for view `expeditionTimeExpended`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionTimeExpended`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionTimeExpended`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80370,7 +80751,6 @@ USE `vn`;
-- Final view structure for view `expeditionTruck_Control`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionTruck_Control`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80389,7 +80769,6 @@ USE `vn`;
-- Final view structure for view `expeditionTruck_Control_Detail`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionTruck_Control_Detail`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80408,7 +80787,6 @@ USE `vn`;
-- Final view structure for view `expeditionTruck_Control_Detail_Pallet`
--
-/*!50001 DROP TABLE IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/;
/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80427,7 +80805,6 @@ USE `vn`;
-- Final view structure for view `firstTicketShipped`
--
-/*!50001 DROP TABLE IF EXISTS `firstTicketShipped`*/;
/*!50001 DROP VIEW IF EXISTS `firstTicketShipped`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80446,7 +80823,6 @@ USE `vn`;
-- Final view structure for view `floraHollandBuyedItems`
--
-/*!50001 DROP TABLE IF EXISTS `floraHollandBuyedItems`*/;
/*!50001 DROP VIEW IF EXISTS `floraHollandBuyedItems`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80465,7 +80841,6 @@ USE `vn`;
-- Final view structure for view `inkL10n`
--
-/*!50001 DROP TABLE IF EXISTS `inkL10n`*/;
/*!50001 DROP VIEW IF EXISTS `inkL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80484,7 +80859,6 @@ USE `vn`;
-- Final view structure for view `invoiceCorrectionDataSource`
--
-/*!50001 DROP TABLE IF EXISTS `invoiceCorrectionDataSource`*/;
/*!50001 DROP VIEW IF EXISTS `invoiceCorrectionDataSource`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80503,7 +80877,6 @@ USE `vn`;
-- Final view structure for view `itemBotanicalWithGenus`
--
-/*!50001 DROP TABLE IF EXISTS `itemBotanicalWithGenus`*/;
/*!50001 DROP VIEW IF EXISTS `itemBotanicalWithGenus`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80522,7 +80895,6 @@ USE `vn`;
-- Final view structure for view `itemCategoryL10n`
--
-/*!50001 DROP TABLE IF EXISTS `itemCategoryL10n`*/;
/*!50001 DROP VIEW IF EXISTS `itemCategoryL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80541,7 +80913,6 @@ USE `vn`;
-- Final view structure for view `itemColor`
--
-/*!50001 DROP TABLE IF EXISTS `itemColor`*/;
/*!50001 DROP VIEW IF EXISTS `itemColor`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80560,7 +80931,6 @@ USE `vn`;
-- Final view structure for view `itemEntryIn`
--
-/*!50001 DROP TABLE IF EXISTS `itemEntryIn`*/;
/*!50001 DROP VIEW IF EXISTS `itemEntryIn`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80579,7 +80949,6 @@ USE `vn`;
-- Final view structure for view `itemEntryOut`
--
-/*!50001 DROP TABLE IF EXISTS `itemEntryOut`*/;
/*!50001 DROP VIEW IF EXISTS `itemEntryOut`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80598,7 +80967,6 @@ USE `vn`;
-- Final view structure for view `itemInk`
--
-/*!50001 DROP TABLE IF EXISTS `itemInk`*/;
/*!50001 DROP VIEW IF EXISTS `itemInk`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80617,7 +80985,6 @@ USE `vn`;
-- Final view structure for view `itemPlacementSupplyList`
--
-/*!50001 DROP TABLE IF EXISTS `itemPlacementSupplyList`*/;
/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80627,7 +80994,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`userFk` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`userFk` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= `util`.`VN_CURDATE`() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */;
+/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`id` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`id` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= `util`.`VN_CURDATE`() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -80636,7 +81003,6 @@ USE `vn`;
-- Final view structure for view `itemProductor`
--
-/*!50001 DROP TABLE IF EXISTS `itemProductor`*/;
/*!50001 DROP VIEW IF EXISTS `itemProductor`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80655,7 +81021,6 @@ USE `vn`;
-- Final view structure for view `itemSearch`
--
-/*!50001 DROP TABLE IF EXISTS `itemSearch`*/;
/*!50001 DROP VIEW IF EXISTS `itemSearch`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80674,7 +81039,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingAvailable`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingAvailable`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingAvailable`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80693,7 +81057,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingList`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingList`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80712,7 +81075,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingPlacementSupplyStock`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingPlacementSupplyStock`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingPlacementSupplyStock`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80731,7 +81093,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingSaleSum`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingSaleSum`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingSaleSum`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80750,7 +81111,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingStock`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingStock`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingStock`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80769,7 +81129,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingStockFull`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingStockFull`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingStockFull`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80788,7 +81147,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingStockRemoved`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingStockRemoved`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingStockRemoved`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80807,7 +81165,6 @@ USE `vn`;
-- Final view structure for view `itemShelvingStock_byWarehouse`
--
-/*!50001 DROP TABLE IF EXISTS `itemShelvingStock_byWarehouse`*/;
/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_byWarehouse`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80826,7 +81183,6 @@ USE `vn`;
-- Final view structure for view `itemTagged`
--
-/*!50001 DROP TABLE IF EXISTS `itemTagged`*/;
/*!50001 DROP VIEW IF EXISTS `itemTagged`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80845,7 +81201,6 @@ USE `vn`;
-- Final view structure for view `itemTicketOut`
--
-/*!50001 DROP TABLE IF EXISTS `itemTicketOut`*/;
/*!50001 DROP VIEW IF EXISTS `itemTicketOut`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80864,7 +81219,6 @@ USE `vn`;
-- Final view structure for view `itemTypeL10n`
--
-/*!50001 DROP TABLE IF EXISTS `itemTypeL10n`*/;
/*!50001 DROP VIEW IF EXISTS `itemTypeL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80883,7 +81237,6 @@ USE `vn`;
-- Final view structure for view `item_Free_Id`
--
-/*!50001 DROP TABLE IF EXISTS `item_Free_Id`*/;
/*!50001 DROP VIEW IF EXISTS `item_Free_Id`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80902,7 +81255,6 @@ USE `vn`;
-- Final view structure for view `labelInfo`
--
-/*!50001 DROP TABLE IF EXISTS `labelInfo`*/;
/*!50001 DROP VIEW IF EXISTS `labelInfo`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80921,7 +81273,6 @@ USE `vn`;
-- Final view structure for view `lastHourProduction`
--
-/*!50001 DROP TABLE IF EXISTS `lastHourProduction`*/;
/*!50001 DROP VIEW IF EXISTS `lastHourProduction`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80940,7 +81291,6 @@ USE `vn`;
-- Final view structure for view `lastPurchases`
--
-/*!50001 DROP TABLE IF EXISTS `lastPurchases`*/;
/*!50001 DROP VIEW IF EXISTS `lastPurchases`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80959,7 +81309,6 @@ USE `vn`;
-- Final view structure for view `lastTopClaims`
--
-/*!50001 DROP TABLE IF EXISTS `lastTopClaims`*/;
/*!50001 DROP VIEW IF EXISTS `lastTopClaims`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80978,7 +81327,6 @@ USE `vn`;
-- Final view structure for view `mistake`
--
-/*!50001 DROP TABLE IF EXISTS `mistake`*/;
/*!50001 DROP VIEW IF EXISTS `mistake`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -80997,7 +81345,6 @@ USE `vn`;
-- Final view structure for view `mistakeRatio`
--
-/*!50001 DROP TABLE IF EXISTS `mistakeRatio`*/;
/*!50001 DROP VIEW IF EXISTS `mistakeRatio`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81016,7 +81363,6 @@ USE `vn`;
-- Final view structure for view `newBornSales`
--
-/*!50001 DROP TABLE IF EXISTS `newBornSales`*/;
/*!50001 DROP VIEW IF EXISTS `newBornSales`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81035,7 +81381,6 @@ USE `vn`;
-- Final view structure for view `operatorWorkerCode`
--
-/*!50001 DROP TABLE IF EXISTS `operatorWorkerCode`*/;
/*!50001 DROP VIEW IF EXISTS `operatorWorkerCode`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81054,7 +81399,6 @@ USE `vn`;
-- Final view structure for view `originL10n`
--
-/*!50001 DROP TABLE IF EXISTS `originL10n`*/;
/*!50001 DROP VIEW IF EXISTS `originL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81073,7 +81417,6 @@ USE `vn`;
-- Final view structure for view `packageEquivalentItem`
--
-/*!50001 DROP TABLE IF EXISTS `packageEquivalentItem`*/;
/*!50001 DROP VIEW IF EXISTS `packageEquivalentItem`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81092,7 +81435,6 @@ USE `vn`;
-- Final view structure for view `personMedia`
--
-/*!50001 DROP TABLE IF EXISTS `personMedia`*/;
/*!50001 DROP VIEW IF EXISTS `personMedia`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81111,7 +81453,6 @@ USE `vn`;
-- Final view structure for view `phoneBook`
--
-/*!50001 DROP TABLE IF EXISTS `phoneBook`*/;
/*!50001 DROP VIEW IF EXISTS `phoneBook`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81130,7 +81471,6 @@ USE `vn`;
-- Final view structure for view `productionVolume`
--
-/*!50001 DROP TABLE IF EXISTS `productionVolume`*/;
/*!50001 DROP VIEW IF EXISTS `productionVolume`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81149,7 +81489,6 @@ USE `vn`;
-- Final view structure for view `productionVolume_LastHour`
--
-/*!50001 DROP TABLE IF EXISTS `productionVolume_LastHour`*/;
/*!50001 DROP VIEW IF EXISTS `productionVolume_LastHour`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81168,7 +81507,6 @@ USE `vn`;
-- Final view structure for view `role`
--
-/*!50001 DROP TABLE IF EXISTS `role`*/;
/*!50001 DROP VIEW IF EXISTS `role`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81187,7 +81525,6 @@ USE `vn`;
-- Final view structure for view `routesReduced`
--
-/*!50001 DROP TABLE IF EXISTS `routesReduced`*/;
/*!50001 DROP VIEW IF EXISTS `routesReduced`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81206,7 +81543,6 @@ USE `vn`;
-- Final view structure for view `saleCost`
--
-/*!50001 DROP TABLE IF EXISTS `saleCost`*/;
/*!50001 DROP VIEW IF EXISTS `saleCost`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81225,7 +81561,6 @@ USE `vn`;
-- Final view structure for view `saleLabel`
--
-/*!50001 DROP TABLE IF EXISTS `saleLabel`*/;
/*!50001 DROP VIEW IF EXISTS `saleLabel`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81244,7 +81579,6 @@ USE `vn`;
-- Final view structure for view `saleMistakeList`
--
-/*!50001 DROP TABLE IF EXISTS `saleMistakeList`*/;
/*!50001 DROP VIEW IF EXISTS `saleMistakeList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81263,7 +81597,6 @@ USE `vn`;
-- Final view structure for view `saleMistake_list__2`
--
-/*!50001 DROP TABLE IF EXISTS `saleMistake_list__2`*/;
/*!50001 DROP VIEW IF EXISTS `saleMistake_list__2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81282,7 +81615,6 @@ USE `vn`;
-- Final view structure for view `saleSaleTracking`
--
-/*!50001 DROP TABLE IF EXISTS `saleSaleTracking`*/;
/*!50001 DROP VIEW IF EXISTS `saleSaleTracking`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81301,7 +81633,6 @@ USE `vn`;
-- Final view structure for view `saleValue`
--
-/*!50001 DROP TABLE IF EXISTS `saleValue`*/;
/*!50001 DROP VIEW IF EXISTS `saleValue`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81320,7 +81651,6 @@ USE `vn`;
-- Final view structure for view `saleVolume`
--
-/*!50001 DROP TABLE IF EXISTS `saleVolume`*/;
/*!50001 DROP VIEW IF EXISTS `saleVolume`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81330,7 +81660,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */;
+/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) * `z`.`inflation` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -81339,7 +81669,6 @@ USE `vn`;
-- Final view structure for view `saleVolume_Today_VNH`
--
-/*!50001 DROP TABLE IF EXISTS `saleVolume_Today_VNH`*/;
/*!50001 DROP VIEW IF EXISTS `saleVolume_Today_VNH`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81358,7 +81687,6 @@ USE `vn`;
-- Final view structure for view `sale_freightComponent`
--
-/*!50001 DROP TABLE IF EXISTS `sale_freightComponent`*/;
/*!50001 DROP VIEW IF EXISTS `sale_freightComponent`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81377,7 +81705,6 @@ USE `vn`;
-- Final view structure for view `salesPersonSince`
--
-/*!50001 DROP TABLE IF EXISTS `salesPersonSince`*/;
/*!50001 DROP VIEW IF EXISTS `salesPersonSince`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81396,7 +81723,6 @@ USE `vn`;
-- Final view structure for view `salesPreparedLastHour`
--
-/*!50001 DROP TABLE IF EXISTS `salesPreparedLastHour`*/;
/*!50001 DROP VIEW IF EXISTS `salesPreparedLastHour`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81415,7 +81741,6 @@ USE `vn`;
-- Final view structure for view `salesPreviousPreparated`
--
-/*!50001 DROP TABLE IF EXISTS `salesPreviousPreparated`*/;
/*!50001 DROP VIEW IF EXISTS `salesPreviousPreparated`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81434,7 +81759,6 @@ USE `vn`;
-- Final view structure for view `supplierPackaging`
--
-/*!50001 DROP TABLE IF EXISTS `supplierPackaging`*/;
/*!50001 DROP VIEW IF EXISTS `supplierPackaging`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81453,7 +81777,6 @@ USE `vn`;
-- Final view structure for view `tagL10n`
--
-/*!50001 DROP TABLE IF EXISTS `tagL10n`*/;
/*!50001 DROP VIEW IF EXISTS `tagL10n`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81472,7 +81795,6 @@ USE `vn`;
-- Final view structure for view `ticketLastUpdated`
--
-/*!50001 DROP TABLE IF EXISTS `ticketLastUpdated`*/;
/*!50001 DROP VIEW IF EXISTS `ticketLastUpdated`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81491,7 +81813,6 @@ USE `vn`;
-- Final view structure for view `ticketLastUpdatedList`
--
-/*!50001 DROP TABLE IF EXISTS `ticketLastUpdatedList`*/;
/*!50001 DROP VIEW IF EXISTS `ticketLastUpdatedList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81510,7 +81831,6 @@ USE `vn`;
-- Final view structure for view `ticketMRW`
--
-/*!50001 DROP TABLE IF EXISTS `ticketMRW`*/;
/*!50001 DROP VIEW IF EXISTS `ticketMRW`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81529,7 +81849,6 @@ USE `vn`;
-- Final view structure for view `ticketNotInvoiced`
--
-/*!50001 DROP TABLE IF EXISTS `ticketNotInvoiced`*/;
/*!50001 DROP VIEW IF EXISTS `ticketNotInvoiced`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81548,7 +81867,6 @@ USE `vn`;
-- Final view structure for view `ticketPackingList`
--
-/*!50001 DROP TABLE IF EXISTS `ticketPackingList`*/;
/*!50001 DROP VIEW IF EXISTS `ticketPackingList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81567,7 +81885,6 @@ USE `vn`;
-- Final view structure for view `ticketPreviousPreparingList`
--
-/*!50001 DROP TABLE IF EXISTS `ticketPreviousPreparingList`*/;
/*!50001 DROP VIEW IF EXISTS `ticketPreviousPreparingList`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81586,7 +81903,6 @@ USE `vn`;
-- Final view structure for view `ticketState`
--
-/*!50001 DROP TABLE IF EXISTS `ticketState`*/;
/*!50001 DROP VIEW IF EXISTS `ticketState`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81605,7 +81921,6 @@ USE `vn`;
-- Final view structure for view `ticketStateToday`
--
-/*!50001 DROP TABLE IF EXISTS `ticketStateToday`*/;
/*!50001 DROP VIEW IF EXISTS `ticketStateToday`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81624,7 +81939,6 @@ USE `vn`;
-- Final view structure for view `tr2`
--
-/*!50001 DROP TABLE IF EXISTS `tr2`*/;
/*!50001 DROP VIEW IF EXISTS `tr2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81643,7 +81957,6 @@ USE `vn`;
-- Final view structure for view `traceabilityBuy`
--
-/*!50001 DROP TABLE IF EXISTS `traceabilityBuy`*/;
/*!50001 DROP VIEW IF EXISTS `traceabilityBuy`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81662,7 +81975,6 @@ USE `vn`;
-- Final view structure for view `traceabilitySale`
--
-/*!50001 DROP TABLE IF EXISTS `traceabilitySale`*/;
/*!50001 DROP VIEW IF EXISTS `traceabilitySale`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81681,7 +81993,6 @@ USE `vn`;
-- Final view structure for view `workerBusinessDated`
--
-/*!50001 DROP TABLE IF EXISTS `workerBusinessDated`*/;
/*!50001 DROP VIEW IF EXISTS `workerBusinessDated`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81700,7 +82011,6 @@ USE `vn`;
-- Final view structure for view `workerDepartment`
--
-/*!50001 DROP TABLE IF EXISTS `workerDepartment`*/;
/*!50001 DROP VIEW IF EXISTS `workerDepartment`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81719,7 +82029,6 @@ USE `vn`;
-- Final view structure for view `workerLabour`
--
-/*!50001 DROP TABLE IF EXISTS `workerLabour`*/;
/*!50001 DROP VIEW IF EXISTS `workerLabour`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81738,7 +82047,6 @@ USE `vn`;
-- Final view structure for view `workerMedia`
--
-/*!50001 DROP TABLE IF EXISTS `workerMedia`*/;
/*!50001 DROP VIEW IF EXISTS `workerMedia`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81757,7 +82065,6 @@ USE `vn`;
-- Final view structure for view `workerSpeedExpedition`
--
-/*!50001 DROP TABLE IF EXISTS `workerSpeedExpedition`*/;
/*!50001 DROP VIEW IF EXISTS `workerSpeedExpedition`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81776,7 +82083,6 @@ USE `vn`;
-- Final view structure for view `workerSpeedSaleTracking`
--
-/*!50001 DROP TABLE IF EXISTS `workerSpeedSaleTracking`*/;
/*!50001 DROP VIEW IF EXISTS `workerSpeedSaleTracking`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81795,7 +82101,6 @@ USE `vn`;
-- Final view structure for view `workerTeamCollegues`
--
-/*!50001 DROP TABLE IF EXISTS `workerTeamCollegues`*/;
/*!50001 DROP VIEW IF EXISTS `workerTeamCollegues`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81814,17 +82119,16 @@ USE `vn`;
-- Final view structure for view `workerTimeControlUserInfo`
--
-/*!50001 DROP TABLE IF EXISTS `workerTimeControlUserInfo`*/;
/*!50001 DROP VIEW IF EXISTS `workerTimeControlUserInfo`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb3 */;
-/*!50001 SET character_set_results = utf8mb3 */;
-/*!50001 SET collation_connection = utf8mb3_general_ci */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`userFk` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */;
+/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`id` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -81833,7 +82137,6 @@ USE `vn`;
-- Final view structure for view `workerTimeJourneyNG`
--
-/*!50001 DROP TABLE IF EXISTS `workerTimeJourneyNG`*/;
/*!50001 DROP VIEW IF EXISTS `workerTimeJourneyNG`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81843,7 +82146,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`userFk` = `wtc`.`userFk`)) */;
+/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`id` = `wtc`.`userFk`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -81852,7 +82155,6 @@ USE `vn`;
-- Final view structure for view `workerWithoutTractor`
--
-/*!50001 DROP TABLE IF EXISTS `workerWithoutTractor`*/;
/*!50001 DROP VIEW IF EXISTS `workerWithoutTractor`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81871,7 +82173,6 @@ USE `vn`;
-- Final view structure for view `zoneEstimatedDelivery`
--
-/*!50001 DROP TABLE IF EXISTS `zoneEstimatedDelivery`*/;
/*!50001 DROP VIEW IF EXISTS `zoneEstimatedDelivery`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -81895,4 +82196,4 @@ USE `vn`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2023-06-26 8:39:32
+-- Dump completed on 2023-08-30 15:59:19
diff --git a/db/export-data.sh b/db/export-data.sh
index 1df4db030..7d346b235 100755
--- a/db/export-data.sh
+++ b/db/export-data.sh
@@ -65,7 +65,6 @@ TABLES=(
sample
state
ticketUpdateAction
- time
volumeConfig
workCenter
companyI18n
@@ -98,13 +97,6 @@ TABLES=(
)
dump_tables ${TABLES[@]}
-TABLES=(
- postgresql
- labour_agreement
- media_type
-)
-dump_tables ${TABLES[@]}
-
TABLES=(
sage
TiposIva
diff --git a/db/export-structure.sh b/db/export-structure.sh
index a6888f2ac..4ecbfa7e8 100755
--- a/db/export-structure.sh
+++ b/db/export-structure.sh
@@ -7,7 +7,6 @@ SCHEMAS=(
edi
hedera
pbx
- postgresql
sage
salix
stock
@@ -23,7 +22,6 @@ IGNORETABLES=(
--ignore-table=bs.productionIndicators
--ignore-table=bs.VentasPorCliente
--ignore-table=bs.v_ventas
- --ignore-table=postgresql.currentWorkersStats
--ignore-table=vn.accounting__
--ignore-table=vn.agencyModeZone
--ignore-table=vn.agencyProvince
diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js
index 9140628e6..0ca1429d4 100644
--- a/db/tests/vn/workerTimeControlCheck.spec.js
+++ b/db/tests/vn/workerTimeControlCheck.spec.js
@@ -54,7 +54,6 @@ xdescribe('worker workerTimeControl_check()', () => {
});
it('should throw an error if the worker with a special category has not finished the 9h break', async() => {
- // dayBreak to 9h in postgresql.professional_category
const workerId = 1110;
const tabletId = 1;
let stmts = [];
@@ -91,7 +90,6 @@ xdescribe('worker workerTimeControl_check()', () => {
});
it('should check f the worker with a special category has finished the 9h break', async() => {
- // dayBreak to 9h in postgresql.professional_category
const workerId = 1110;
const tabletId = 1;
let stmts = [];
@@ -239,12 +237,6 @@ xdescribe('worker workerTimeControl_check()', () => {
stmts.push('START TRANSACTION');
- stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(businessFk,calendar_state_id,date)
- VALUES
- (?,1,CURDATE())`, [
- workerId
- ]);
- stmts.push(stmt);
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
VALUES
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js
index fe3ef08bd..b6ea32a6c 100644
--- a/e2e/helpers/extensions.js
+++ b/e2e/helpers/extensions.js
@@ -632,6 +632,7 @@ let actions = {
await this.write(selector, value.toString());
break;
case 'vn-autocomplete':
+ case 'vn-worker-autocomplete':
if (value)
await this.autocompleteSearch(selector, value.toString());
else
@@ -667,6 +668,7 @@ let actions = {
switch (tagName) {
case 'vn-textfield':
case 'vn-autocomplete':
+ case 'vn-worker-autocomplete':
case 'vn-input-time':
case 'vn-datalist':
el = await input.$('input');
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 93288efa7..fe3633723 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -187,7 +187,7 @@ export default {
country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]',
email: 'vn-client-create vn-textfield[ng-model="$ctrl.client.email"]',
- salesPerson: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
+ salesPerson: 'vn-client-create vn-worker-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
saveNewProvicenButton: '#saveProvince',
saveNewCityButton: '#saveCity',
saveNewPoscode: '#savePostcode',
@@ -199,7 +199,7 @@ export default {
email: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.email"]',
phone: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.phone"]',
mobile: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.mobile"]',
- salesPerson: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
+ salesPerson: 'vn-client-basic-data vn-worker-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
channel: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]',
transferor: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.transferorFk"]',
businessType: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.businessTypeFk"]',
@@ -735,7 +735,7 @@ export default {
},
createStateView: {
state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]',
- worker: 'vn-autocomplete[ng-model="$ctrl.workerFk"]',
+ worker: 'vn-worker-autocomplete[ng-model="$ctrl.workerFk"]',
saveStateButton: `button[type=submit]`
},
claimsIndex: {
@@ -781,12 +781,12 @@ export default {
firstClaimReason: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]',
firstClaimResult: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]',
firstClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]',
- firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.workerFk"]',
+ firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]',
firstClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]',
secondClaimReason: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]',
secondClaimResult: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]',
secondClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]',
- secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.workerFk"]',
+ secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]',
secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]',
saveDevelopmentButton: 'button[type=submit]'
},
@@ -854,7 +854,7 @@ export default {
},
createRouteView: {
- worker: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
+ worker: 'vn-route-create vn-worker-autocomplete[ng-model="$ctrl.route.workerFk"]',
createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.created"]',
vehicleAuto: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]',
agency: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]',
@@ -976,7 +976,7 @@ export default {
street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]',
user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]',
email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]',
- boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
+ boss: 'vn-worker-create vn-worker-autocomplete[ng-model="$ctrl.worker.bossFk"]',
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]',
createButton: 'vn-worker-create vn-submit[label="Create"]',
diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js
index 0fd06402a..744b11a72 100644
--- a/e2e/paths/02-client/01_create_client.spec.js
+++ b/e2e/paths/02-client/01_create_client.spec.js
@@ -73,8 +73,8 @@ describe('Client create path', () => {
it(`should attempt to create a new user with all it's data but wrong email`, async() => {
await page.write(selectors.createClientView.name, 'Carol Danvers');
- await page.write(selectors.createClientView.socialName, 'AVG tax');
- await page.write(selectors.createClientView.street, 'Many places');
+ await page.write(selectors.createClientView.socialName, 'AVG TAX');
+ await page.write(selectors.createClientView.street, 'MANY PLACES');
await page.clearInput(selectors.createClientView.email);
await page.write(selectors.createClientView.email, 'incorrect email format');
await page.waitToClick(selectors.createClientView.createButton);
diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js
index 0babb5396..9098e816f 100644
--- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js
+++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js
@@ -61,7 +61,7 @@ describe('Client Edit fiscalData path', () => {
await page.clearInput(selectors.clientFiscalData.fiscalId);
await page.write(selectors.clientFiscalData.fiscalId, 'INVALID!');
await page.clearInput(selectors.clientFiscalData.address);
- await page.write(selectors.clientFiscalData.address, 'Somewhere edited');
+ await page.write(selectors.clientFiscalData.address, 'SOMEWHERE EDITED');
await page.autocompleteSearch(selectors.clientFiscalData.country, 'España');
await page.autocompleteSearch(selectors.clientFiscalData.province, 'Province one');
await page.clearInput(selectors.clientFiscalData.city);
@@ -190,7 +190,7 @@ describe('Client Edit fiscalData path', () => {
const verifiedData = await page.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
expect(fiscalId).toEqual('94980061C');
- expect(address).toEqual('Somewhere edited');
+ expect(address).toEqual('SOMEWHERE EDITED');
expect(postcode).toContain('46000');
expect(sageTax).toEqual('Operaciones no sujetas');
expect(sageTransaction).toEqual('Regularización de inversiones');
diff --git a/e2e/paths/02-client/12_lock_of_verified_data.spec.js b/e2e/paths/02-client/12_lock_of_verified_data.spec.js
index 139af0cea..2d7ab7541 100644
--- a/e2e/paths/02-client/12_lock_of_verified_data.spec.js
+++ b/e2e/paths/02-client/12_lock_of_verified_data.spec.js
@@ -28,7 +28,7 @@ describe('Client lock verified data path', () => {
it('should edit the social name', async() => {
await page.waitForSelector(selectors.clientFiscalData.socialName);
await page.clearInput(selectors.clientFiscalData.socialName);
- await page.write(selectors.clientFiscalData.socialName, 'Captain America Civil War');
+ await page.write(selectors.clientFiscalData.socialName, 'CAPTAIN AMERICA CIVIL WAR');
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
@@ -39,7 +39,7 @@ describe('Client lock verified data path', () => {
await page.reloadSection('client.card.fiscalData');
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
- expect(result).toEqual('Captain America Civil War');
+ expect(result).toEqual('CAPTAIN AMERICA CIVIL WAR');
});
});
@@ -88,7 +88,7 @@ describe('Client lock verified data path', () => {
await page.reloadSection('client.card.fiscalData');
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
- expect(result).toEqual('Ant man and the Wasp');
+ expect(result).toEqual('ANT MAN AND THE WASP');
});
});
@@ -142,7 +142,7 @@ describe('Client lock verified data path', () => {
await page.reloadSection('client.card.fiscalData');
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
- expect(result).toEqual('new social name edition');
+ expect(result).toEqual('NEW SOCIAL NAME EDITION');
});
});
diff --git a/e2e/paths/02-client/19_summary.spec.js b/e2e/paths/02-client/19_summary.spec.js
index ab39154cf..b3bf43c5c 100644
--- a/e2e/paths/02-client/19_summary.spec.js
+++ b/e2e/paths/02-client/19_summary.spec.js
@@ -36,7 +36,7 @@ describe('Client summary path', () => {
it('should display fiscal address details', async() => {
const result = await page.waitToGetProperty(selectors.clientSummary.street, 'innerText');
- expect(result).toContain('20 Ingram Street');
+ expect(result).toContain('20 INGRAM STREET');
});
it('should display some fiscal data', async() => {
diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js
index 5440253cc..2accdfc31 100644
--- a/e2e/paths/03-worker/06_create.spec.js
+++ b/e2e/paths/03-worker/06_create.spec.js
@@ -23,7 +23,7 @@ describe('Worker create path', () => {
await page.write(selectors.workerCreate.fi, '78457139E');
await page.write(selectors.workerCreate.phone, '12356789');
await page.write(selectors.workerCreate.postcode, '46680');
- await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
+ await page.write(selectors.workerCreate.street, 'S/ DOOMSTADT');
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js
index e09ecb778..51195be48 100644
--- a/e2e/paths/04-item/01_summary.spec.js
+++ b/e2e/paths/04-item/01_summary.spec.js
@@ -27,10 +27,10 @@ describe('Item summary path', () => {
});
it(`should check the item summary preview shows fields from basic data`, async() => {
- await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m');
+ await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 200cm');
const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
- expect(result).toContain('Ranged weapon longbow 2m');
+ expect(result).toContain('Ranged weapon longbow 200cm');
});
it(`should check the item summary preview shows fields from tags`, async() => {
diff --git a/e2e/paths/04-item/03_tax.spec.js b/e2e/paths/04-item/03_tax.spec.js
index 16cc1667d..6013094e9 100644
--- a/e2e/paths/04-item/03_tax.spec.js
+++ b/e2e/paths/04-item/03_tax.spec.js
@@ -8,7 +8,7 @@ describe('Item edit tax path', () => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
- await page.accessToSearchResult('Ranged weapon longbow 2m');
+ await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.tax');
});
diff --git a/e2e/paths/04-item/04_tags.spec.js b/e2e/paths/04-item/04_tags.spec.js
index 574ff7562..f13cf9aa4 100644
--- a/e2e/paths/04-item/04_tags.spec.js
+++ b/e2e/paths/04-item/04_tags.spec.js
@@ -8,7 +8,7 @@ describe('Item create tags path', () => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
- await page.accessToSearchResult('Ranged weapon longbow 2m');
+ await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.tags');
});
diff --git a/e2e/paths/04-item/06_barcode.spec.js b/e2e/paths/04-item/06_barcode.spec.js
index 7fed5ea0c..36c9c39ae 100644
--- a/e2e/paths/04-item/06_barcode.spec.js
+++ b/e2e/paths/04-item/06_barcode.spec.js
@@ -8,7 +8,7 @@ describe('Item Create barcodes path', () => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
- await page.accessToSearchResult('Ranged weapon longbow 2m');
+ await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.itemBarcode');
});
diff --git a/e2e/paths/04-item/12_request.spec.js b/e2e/paths/04-item/12_request.spec.js
index 19838883e..e0f3a1b45 100644
--- a/e2e/paths/04-item/12_request.spec.js
+++ b/e2e/paths/04-item/12_request.spec.js
@@ -22,10 +22,10 @@ describe('Item request path', () => {
it('should fill the id and quantity then check the concept was updated', async() => {
await page.writeOnEditableTD(selectors.itemRequest.firstRequestItemID, '4');
await page.writeOnEditableTD(selectors.itemRequest.firstRequestQuantity, '10');
- await page.waitForTextInElement(selectors.itemRequest.firstRequestConcept, 'Melee weapon heavy shield 1x0.5m');
+ await page.waitForTextInElement(selectors.itemRequest.firstRequestConcept, 'Melee weapon heavy shield 100cm');
let filledConcept = await page.waitToGetProperty(selectors.itemRequest.firstRequestConcept, 'innerText');
- expect(filledConcept).toContain('Melee weapon heavy shield 1x0.5m');
+ expect(filledConcept).toContain('Melee weapon heavy shield 100cm');
});
it('should check the status of the request should now be accepted', async() => {
diff --git a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js
index 44f2b6947..5c8eba571 100644
--- a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js
+++ b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js
@@ -54,7 +54,7 @@ describe('Ticket List sale path', () => {
});
it('should select a valid item to be added as the second item in the sales list', async() => {
- let searchValue = 'Melee weapon heavy shield 1x0.5m';
+ let searchValue = 'Melee weapon heavy shield 100cm';
await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell);
await page.type(selectors.ticketSales.secondSaleQuantity, '1');
diff --git a/e2e/paths/05-ticket/04_packages.spec.js b/e2e/paths/05-ticket/04_packages.spec.js
index 2b79e9cb6..1e6a0a173 100644
--- a/e2e/paths/05-ticket/04_packages.spec.js
+++ b/e2e/paths/05-ticket/04_packages.spec.js
@@ -36,7 +36,7 @@ describe('Ticket Create packages path', () => {
it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => {
await page.clearInput($.firstQuantity);
- await page.autocompleteSearch($.firstPackage, 'Container medical box 1m');
+ await page.autocompleteSearch($.firstPackage, 'Container medical box 100cm');
await page.waitToClick($.savePackagesButton);
const message = await page.waitForSnackbar();
@@ -63,10 +63,10 @@ describe('Ticket Create packages path', () => {
it(`should confirm the first select is the expected one`, async() => {
await page.reloadSection('ticket.card.package');
- await page.waitForTextInField($.firstPackage, 'Container medical box 1m');
+ await page.waitForTextInField($.firstPackage, 'Container medical box 100cm');
const result = await page.waitToGetProperty($.firstPackage, 'value');
- expect(result).toEqual('Container medical box 1m');
+ expect(result).toEqual('Container medical box 100cm');
});
it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => {
diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js
index 949c9a8e6..9ac373287 100644
--- a/e2e/paths/05-ticket/05_tracking_state.spec.js
+++ b/e2e/paths/05-ticket/05_tracking_state.spec.js
@@ -59,7 +59,7 @@ describe('Ticket Create new tracking state path', () => {
const result = await page
.waitToGetProperty(selectors.createStateView.worker, 'value');
- expect(result).toEqual('salesPersonNick');
+ expect(result).toEqual('salesPerson');
});
it(`should succesfully create a valid state`, async() => {
diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js
index 80c288a01..1f9c0c40a 100644
--- a/e2e/paths/05-ticket/14_create_ticket.spec.js
+++ b/e2e/paths/05-ticket/14_create_ticket.spec.js
@@ -10,7 +10,7 @@ describe('Ticket create path', () => {
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
- await page.loginAndModule('employee', 'ticket');
+ await page.loginAndModule('salesPerson', 'ticket');
});
afterAll(async() => {
diff --git a/e2e/paths/12-entry/07_buys.spec.js b/e2e/paths/12-entry/07_buys.spec.js
index 28d39fb1d..b960673ec 100644
--- a/e2e/paths/12-entry/07_buys.spec.js
+++ b/e2e/paths/12-entry/07_buys.spec.js
@@ -41,10 +41,10 @@ describe('Entry import, create and edit buys path', () => {
await page.waitForTextInField(selectors.entryBuys.ref, '200573095, 200573106, 200573117, 200573506');
await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846');
- await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged weapon longbow 2m');
- await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Ranged weapon longbow 2m');
- await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Ranged weapon sniper rifle 300mm');
- await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Melee weapon heavy shield 1x0.5m');
+ await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged weapon longbow 200cm');
+ await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Ranged weapon longbow 200cm');
+ await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Ranged weapon sniper rifle 113cm');
+ await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Melee weapon heavy shield 100cm');
await page.waitToClick(selectors.entryBuys.importBuysButton);
diff --git a/front/core/components/autocomplete/index.html b/front/core/components/autocomplete/index.html
index 69aac4d43..527ca77e7 100755
--- a/front/core/components/autocomplete/index.html
+++ b/front/core/components/autocomplete/index.html
@@ -18,7 +18,7 @@
+
-
\ No newline at end of file
+
diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js
index 2539c4ef4..c78c29398 100755
--- a/front/core/components/autocomplete/index.js
+++ b/front/core/components/autocomplete/index.js
@@ -17,10 +17,9 @@ import './style.scss';
* @event change Thrown when value is changed
*/
export default class Autocomplete extends Field {
- constructor($element, $, $compile, $transclude) {
- super($element, $, $compile);
+ constructor($element, $, $transclude) {
+ super($element, $, $transclude);
this.$transclude = $transclude;
- this.$compile = $compile;
this._selection = null;
this.input = this.element.querySelector('input');
}
@@ -153,7 +152,14 @@ export default class Autocomplete extends Field {
filter.include = this.include;
let json = encodeURIComponent(JSON.stringify(filter));
- this.$http.get(`${this.url}?filter=${json}`).then(
+
+ let url;
+ if (this.url.includes('?'))
+ url = `${this.url}&filter=${json}`;
+ else
+ url = `${this.url}?filter=${json}`;
+
+ this.$http.get(url).then(
json => this.onSelectionRequest(json.data),
() => this.onSelectionRequest()
);
@@ -282,7 +288,7 @@ export default class Autocomplete extends Field {
this.refreshSelection();
}
}
-Autocomplete.$inject = ['$element', '$scope', '$compile', '$transclude'];
+Autocomplete.$inject = ['$element', '$scope', '$transclude'];
ngModule.vnComponent('vnAutocomplete', {
template: require('./index.html'),
diff --git a/front/core/components/drop-down/index.html b/front/core/components/drop-down/index.html
index ab868f7b5..692b0c87c 100644
--- a/front/core/components/drop-down/index.html
+++ b/front/core/components/drop-down/index.html
@@ -13,12 +13,12 @@
class="dropdown"
ng-click="$ctrl.onContainerClick($event)">
-
';
+ // Send email with failed tickets
+ if (failedtickets.length > 0) {
+ let body = 'This following tickets have failed:
';
- for (const ticket of failedtickets) {
- body += `Ticket: ${ticket.id}
- ${ticket.stacktrace}
`;
- }
+ for (const ticket of failedtickets) {
+ body += `Ticket: ${ticket.id}
+ ${ticket.stacktrace}
`;
+ }
- smtp.send({
- to: config.app.reportEmail,
- subject: '[API] Nightly ticket closure report',
- html: body
- });
- }
+ smtp.send({
+ to: config.app.reportEmail,
+ subject: '[API] Nightly ticket closure report',
+ html: body
+ });
+ }
- async function invalidEmail(ticket) {
- await Self.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [
- ticket.clientFk
- ], {userId});
+ async function invalidEmail(ticket) {
+ await Self.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [
+ ticket.clientFk
+ ], {userId});
- const oldInstance = `{"email": "${ticket.recipient}"}`;
- const newInstance = `{"email": ""}`;
- await Self.rawSql(`
- INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance)
- VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [
- ticket.clientFk,
- oldInstance,
- newInstance
- ], {userId});
+ const oldInstance = `{"email": "${ticket.recipient}"}`;
+ const newInstance = `{"email": ""}`;
+ await Self.rawSql(`
+ INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance)
+ VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [
+ ticket.clientFk,
+ oldInstance,
+ newInstance
+ ], {userId});
- const body = `No se ha podido enviar el albarán ${ticket.id}
- al cliente ${ticket.clientFk} - ${ticket.clientName}
- porque la dirección de email "${ticket.recipient}" no es correcta
- o no está disponible.
- Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente.
- Actualiza la dirección de email con una correcta.`;
+ const body = `No se ha podido enviar el albarán ${ticket.id}
+ al cliente ${ticket.clientFk} - ${ticket.clientName}
+ porque la dirección de email "${ticket.recipient}" no es correcta
+ o no está disponible.
+This entry has been deleted because the associated invoice {1} has been removed.
diff --git a/print/templates/email/book-entry-deleted/locale/es.yml b/print/templates/email/book-entry-deleted/locale/es.yml
new file mode 100644
index 000000000..c40cf25fd
--- /dev/null
+++ b/print/templates/email/book-entry-deleted/locale/es.yml
@@ -0,0 +1,5 @@
+subject: Asiento contable enlazado eliminado
+title: Asiento contable enlazado eliminado
+description: Se ha borrado el asiento contable que se encuentraba enlazado a SAGE
+
+ 3. Lugar y fecha de entrega /
+ Lieu et date de livraison /
+ Place and date of delivery
+
+
+ {{data.deliveryStreet}}
+ {{data.deliveryPostalCode}} {{data.deliveryCity}} {{(data.deliveryCountry) ? `(${data.deliveryCountry})` : null}}
+ {{(data.ead) ? formatDate(data.ead, '%d/%m/%Y') : null}}
+
+
+
+ 4. Lugar y fecha de carga /
+ Lieu et date del prise en charge de la merchandise /
+ Place and date of taking over the goods
+
+
+ {{data.loadStreet}}
+ {{data.loadPostalCode}} {{data.loadCity}} {{(data.loadCountry) ? `(${data.loadCountry})` : null}}
+ {{formatDate(data.created, '%d/%m/%Y')}}
+
+
+
+ 18. Obervaciones del transportista /
+ Reserves et observations du transporteur /
+ Carrier's reservations and observations
+
+
+ {{data.truckPlate}}
+ {{data.observations}}
+