diff --git a/db/.gitignore b/db/.gitignore
index b81ed39cc..54ed9df77 100644
--- a/db/.gitignore
+++ b/db/.gitignore
@@ -7,3 +7,5 @@ dump/.changes
dump/fixtures.local.sql
.dBeaver
.idea
+.project
+.dbeaver/
diff --git a/db/changes/240201/.gitkeep b/db/changes/240201/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/changes/240201/00-aclsMails.sql b/db/changes/240201/00-aclsMails.sql
deleted file mode 100644
index 5cfea4030..000000000
--- a/db/changes/240201/00-aclsMails.sql
+++ /dev/null
@@ -1,8 +0,0 @@
--- Definición de la tabla mailAliasACL
-
-CREATE OR REPLACE TABLE `account`.`mailAliasAcl` (
- `mailAliasFk` int(10) unsigned NOT NULL,
- `roleFk` int(10) unsigned NOT NULL,
- FOREIGN KEY (`mailAliasFk`) REFERENCES `account`.`mailAlias` (`id`),
- FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
diff --git a/db/changes/240201/00-fixInvoiceCorrectionConstraintsName.sql b/db/changes/240201/00-fixInvoiceCorrectionConstraintsName.sql
deleted file mode 100644
index 426afea90..000000000
--- a/db/changes/240201/00-fixInvoiceCorrectionConstraintsName.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `cplusInvoiceTyoeFk`;
-ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrectionType_Fk33`;
-ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrection_ibfk_1`;
-
-ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `siiTypeInvoiceOut_FK` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `vn`.`siiTypeInvoiceOut`(id) ON UPDATE CASCADE;
-ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `invoiceCorrectionType_FK` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `vn`.`invoiceCorrectionType`(id) ON UPDATE CASCADE;
-ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `cplusRectificationType_FK` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType`(id) ON UPDATE CASCADE;
diff --git a/db/changes/240201/00-getTaxBases.sql b/db/changes/240201/00-getTaxBases.sql
deleted file mode 100644
index 8bd1b745a..000000000
--- a/db/changes/240201/00-getTaxBases.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-DELIMITER $$
-$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`()
-BEGIN
-/**
-* Calcula y devuelve en número de bases imponibles postivas y negativas
-* Requiere la tabla temporal tmp.ticketToInvoice(id)
-*
-* returns tmp.taxBases
-*/
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
- (KEY (ticketFk))
- ENGINE = MEMORY
- SELECT id ticketFk
- FROM tmp.ticketToInvoice;
-
- CALL ticket_getTax(NULL);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.taxBases;
- CREATE TEMPORARY TABLE tmp.taxBases
- ENGINE = MEMORY
- SELECT
- SUM(taxableBase > 0) as positive,
- SUM(taxableBase < 0) as negative
- FROM(
- SELECT SUM(taxableBase) taxableBase
- FROM tmp.ticketTax
- GROUP BY pgcFk
- ) t;
-
-END$$
-DELIMITER ;
diff --git a/db/changes/240201/00-tabletDocuware.sql b/db/changes/240201/00-tabletDocuware.sql
deleted file mode 100644
index ffa0226b3..000000000
--- a/db/changes/240201/00-tabletDocuware.sql
+++ /dev/null
@@ -1,10 +0,0 @@
--- vn.docuwareTablet definition
-
-CREATE TABLE `vn`.`docuwareTablet` (
- `tablet` varchar(100) NOT NULL PRIMARY KEY,
- `description` varchar(255) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-
-ALTER TABLE `vn`.`userConfig`
-ADD COLUMN tabletFk varchar(100) DEFAULT NULL,
-ADD FOREIGN KEY (tabletFk) REFERENCES `vn`.`docuwareTablet`(tablet);
diff --git a/db/changes/240201/00-timecontrol.sql b/db/changes/240201/00-timecontrol.sql
deleted file mode 100644
index c3ddf5d96..000000000
--- a/db/changes/240201/00-timecontrol.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-DELETE FROM `salix`.`ACL`
- WHERE model = 'VnUser'
- AND property = 'renewToken';
-
-INSERT INTO `account`.`role` (name, description)
- VALUES ('timeControl','Tablet para fichar');
-
-INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
- VALUES (127, 11);
-
-INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
- VALUES
- ('WorkerTimeControl', 'login', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
- ('WorkerTimeControl', 'getClockIn', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
- ('WorkerTimeControl', 'clockIn', 'WRITE', 'ALLOW', 'ROLE', 'timeControl');
-
-CALL `account`.`role_sync`();
diff --git a/db/changes/240201/00-truncateWhereSignInLog.sql b/db/changes/240201/00-truncateWhereSignInLog.sql
deleted file mode 100644
index db5d8e25d..000000000
--- a/db/changes/240201/00-truncateWhereSignInLog.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DELETE FROM `account`.`signInLog` where owner <> FALSE;
-
diff --git a/db/changes/240201/01-functions.sql b/db/changes/240201/01-functions.sql
deleted file mode 100644
index 7bbe1f442..000000000
--- a/db/changes/240201/01-functions.sql
+++ /dev/null
@@ -1,81 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketPositionInPath`(vTicketId INT)
- RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
- DETERMINISTIC
-BEGIN
-
- DECLARE vRestTicketsMaxOrder INT;
- DECLARE vRestTicketsMinOrder INT;
- DECLARE vRestTicketsPacking INT;
- DECLARE vMyProductionOrder INT;
- DECLARE vPosition VARCHAR(10) DEFAULT 'MID';
- DECLARE vMyPath INT;
- DECLARE vMyWarehouse INT;
- DECLARE PACKING_ORDER INT;
- DECLARE vExpeditionsCount INT;
- DECLARE vIsValenciaPath BOOLEAN DEFAULT FALSE;
-
-
-
-SELECT `order`
- INTO PACKING_ORDER
- FROM state
- WHERE code = 'PACKING';
-
-SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0)
- INTO vMyPath, vMyWarehouse, vMyProductionOrder
- FROM ticket t
- LEFT JOIN ticketState ts on ts.ticketFk = t.id
- WHERE t.id = vTicketId;
-
-SELECT (ag.`name` = 'VN_VALENCIA')
- INTO vIsValenciaPath
- FROM vn2008.Rutas r
- JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia
- JOIN vn2008.agency ag on ag.agency_id = a.agency_id
- WHERE r.Id_Ruta = vMyPath;
-
-IF vIsValenciaPath THEN -- Rutas Valencia
-
- SELECT COUNT(*)
- INTO vExpeditionsCount
- FROM expedition e
- JOIN ticket t ON t.id = e.ticketFk
- WHERE t.routeFk = vMyPath;
-
- SELECT MAX(ts.productionOrder), MIN(ts.productionOrder)
- INTO vRestTicketsMaxOrder, vRestTicketsMinOrder
- FROM ticket t
- LEFT JOIN ticketState ts on t.id = ts.ticketFk
- WHERE t.routeFk = vMyPath
- AND t.warehouseFk = vMyWarehouse
- AND t.id != vTicketid;
-
- SELECT COUNT(*)
- INTO vRestTicketsPacking
- FROM ticket t
- LEFT JOIN ticketState ts on t.id = ts.ticketFk
- WHERE ts.productionOrder = PACKING_ORDER
- AND t.routeFk = vMyPath
- AND t.warehouseFk = vMyWarehouse
- AND t.id != vTicketid;
-
- IF vExpeditionsCount = 1 THEN
- SET vPosition = 'FIRST';
- ELSEIF vRestTicketsMinOrder > PACKING_ORDER THEN
- SET vPosition = 'LAST';
- ELSEIF vRestTicketsPacking THEN
- SET vPosition = 'SHARED';
- ELSE
- SET vPosition = 'MID';
- END IF;
-
-ELSE
- SET vPosition = 'MID';
-
-END IF;
-
-RETURN vPosition;
-
-END$$
-DELIMITER ;
diff --git a/db/changes/240201/01-newHasAnyPositiveBase.sql b/db/changes/240201/01-newHasAnyPositiveBase.sql
deleted file mode 100644
index c4edfaed0..000000000
--- a/db/changes/240201/01-newHasAnyPositiveBase.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-DELIMITER $$
-$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`() RETURNS tinyint(1)
- DETERMINISTIC
-BEGIN
-
-/**
-* Calcula si existe alguna base imponible positiva
-* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
-*
-* returns BOOLEAN
-*/
-
- DECLARE hasAnyPositiveBase BOOLEAN;
-
- CALL getTaxBases();
-
- SELECT positive INTO hasAnyPositiveBase
- FROM tmp.taxBases
- LIMIT 1;
-
- DROP TEMPORARY TABLE
- tmp.ticketTax,
- tmp.ticket,
- tmp.taxBases;
-
- RETURN hasAnyPositiveBase;
-
-END$$
-DELIMITER ;
diff --git a/db/changes/240201/01-procedures.sql b/db/changes/240201/01-procedures.sql
deleted file mode 100644
index ab52dbd1b..000000000
--- a/db/changes/240201/01-procedures.sql
+++ /dev/null
@@ -1,1788 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible`(
- vWarehouse TINYINT,
- vDate DATE,
- vType INT,
- vPrefix VARCHAR(255))
-BEGIN
-
-/**
- * Gets visible items of the specified type at specified date.
- *
- * @param vWarehouse The warehouse id
- * @param vDate The visible date
- * @param vType The type id
- * @param vPrefix The article prefix to filter or %NULL for all
- * @return tmp.itemVisible Visible items
- */
- DECLARE vPrefixLen SMALLINT;
- DECLARE vFilter VARCHAR(255) DEFAULT NULL;
- DECLARE vDateInv DATE DEFAULT vn.getInventoryDate();
- DECLARE EXIT HANDLER FOR 1114
- BEGIN
- GET DIAGNOSTICS CONDITION 1
- @message = MESSAGE_TEXT;
- CALL vn.mail_insert(
- 'cau@verdnatura.es',
- NULL,
- CONCAT('hedera.item_getVisible error: ', @message),
- CONCAT(
- 'warehouse: ', IFNULL(vWarehouse, ''),
- ', Fecha:', IFNULL(vDate, ''),
- ', tipo: ', IFNULL(vType,''),
- ', prefijo: ', IFNULL(vPrefix,'')));
- RESIGNAL;
- END;
- SET vPrefixLen = IFNULL(LENGTH(vPrefix), 0) + 1;
-
- IF vPrefixLen > 1 THEN
- SET vFilter = CONCAT(vPrefix, '%');
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS `filter`;
- CREATE TEMPORARY TABLE `filter`
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT id itemFk FROM vn.item
- WHERE typeFk = vType
- AND (vFilter IS NULL OR `name` LIKE vFilter);
-
- DROP TEMPORARY TABLE IF EXISTS currentStock;
- CREATE TEMPORARY TABLE currentStock
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT itemFk, SUM(quantity) quantity
- FROM (
- SELECT b.itemFk, b.quantity
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.landed BETWEEN vDateInv AND vDate
- AND t.warehouseInFk = vWarehouse
- AND NOT e.isRaid
- UNION ALL
- SELECT b.itemFk, -b.quantity
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
- AND t.warehouseOutFk = vWarehouse
- AND NOT e.isRaid
- AND t.isDelivered
- UNION ALL
- SELECT m.itemFk, -m.quantity
- FROM vn.sale m
- JOIN vn.ticket t ON t.id = m.ticketFk
- JOIN vn.ticketState s ON s.ticketFk = t.id
- WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
- AND t.warehouseFk = vWarehouse
- AND s.alertLevel = 3
- ) t
- GROUP BY itemFk
- HAVING quantity > 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp;
- CREATE TEMPORARY TABLE tmp
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT *
- FROM (
- SELECT b.itemFk, b.packagingFk, b.packing
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.landed BETWEEN vDateInv AND vDate
- AND NOT b.isIgnored
- AND b.price2 >= 0
- AND b.packagingFk IS NOT NULL
- ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC
- LIMIT 10000000000000000000
- ) t GROUP BY itemFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.itemVisible;
- CREATE TEMPORARY TABLE tmp.itemVisible
- ENGINE = MEMORY
- SELECT i.id Id_Article,
- SUBSTRING(i.`name`, vPrefixLen) Article,
- t.packing, p.id Id_Cubo,
- IF(p.depth > 0, p.depth, 0) depth, p.width, p.height,
- CEIL(s.quantity / t.packing) etiquetas
- FROM vn.item i
- JOIN `filter` f ON f.itemFk = i.id
- JOIN currentStock s ON s.itemFk = i.id
- LEFT JOIN tmp t ON t.itemFk = i.id
- LEFT JOIN vn.packaging p ON p.id = t.packagingFk
- WHERE CEIL(s.quantity / t.packing) > 0
- -- FIXME: Column Cubos.box not included in view vn.packaging
- /* AND p.box */ ;
-
- DROP TEMPORARY TABLE
- `filter`,
- currentStock,
- tmp;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(vSelf INT, vUserId INT)
-BEGIN
-/**
- * Confirms an order, creating each of its tickets on the corresponding
- * date, store and user.
- *
- * @param vSelf The order identifier
- * @param vUser The user identifier
- */
- DECLARE vOk BOOL;
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vWarehouse INT;
- DECLARE vShipment DATE;
- DECLARE vTicket INT;
- DECLARE vNotes VARCHAR(255);
- DECLARE vItem INT;
- DECLARE vConcept VARCHAR(30);
- DECLARE vAmount INT;
- DECLARE vPrice DECIMAL(10,2);
- DECLARE vSale INT;
- DECLARE vRate INT;
- DECLARE vRowId INT;
- DECLARE vPriceFixed DECIMAL(10,2);
- DECLARE vDelivery DATE;
- DECLARE vAddress INT;
- DECLARE vIsConfirmed BOOL;
- DECLARE vClientId INT;
- DECLARE vCompanyId INT;
- DECLARE vAgencyModeId INT;
- DECLARE TICKET_FREE INT DEFAULT 2;
- DECLARE vCalc INT;
- DECLARE vIsLogifloraItem BOOL;
- DECLARE vOldQuantity INT;
- DECLARE vNewQuantity INT;
- DECLARE vIsTaxDataChecked BOOL;
-
- DECLARE cDates CURSOR FOR
- SELECT zgs.shipped, r.warehouse_id
- FROM `order` o
- JOIN order_row r ON r.order_id = o.id
- LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id
- WHERE o.id = vSelf AND r.amount != 0
- GROUP BY r.warehouse_id;
-
- DECLARE cRows CURSOR FOR
- SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo
- FROM order_row r
- JOIN vn.item i ON i.id = r.item_id
- WHERE r.amount != 0
- AND r.warehouse_id = vWarehouse
- AND r.order_id = vSelf
- ORDER BY r.rate DESC;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- -- Carga los datos del pedido
- SELECT o.date_send, o.address_id, o.note, a.clientFk,
- o.company_id, o.agency_id, c.isTaxDataChecked
- INTO vDelivery, vAddress, vNotes, vClientId,
- vCompanyId, vAgencyModeId, vIsTaxDataChecked
- FROM hedera.`order` o
- JOIN vn.address a ON a.id = o.address_id
- JOIN vn.client c ON c.id = a.clientFk
- WHERE o.id = vSelf;
-
- -- Verifica si el cliente tiene los datos comprobados
- IF NOT vIsTaxDataChecked THEN
- CALL util.throw ('clientNotVerified');
- END IF;
-
- -- Carga las fechas de salida de cada almacen
- CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE);
-
- -- Trabajador que realiza la accion
- IF vUserId IS NULL THEN
- SELECT employeeFk INTO vUserId FROM orderConfig;
- END IF;
-
- START TRANSACTION;
-
- CALL order_checkEditable(vSelf);
-
- -- Check order is not empty
-
- SELECT COUNT(*) > 0 INTO vOk
- FROM order_row WHERE order_id = vSelf AND amount > 0;
-
- IF NOT vOk THEN
- CALL util.throw ('ORDER_EMPTY');
- END IF;
-
- -- Crea los tickets del pedido
-
- OPEN cDates;
-
- lDates:
- LOOP
- SET vTicket = NULL;
- SET vDone = FALSE;
- FETCH cDates INTO vShipment, vWarehouse;
-
- IF vDone THEN
- LEAVE lDates;
- END IF;
-
- -- Busca un ticket existente que coincida con los parametros
- WITH tPrevia AS
- (SELECT DISTINCT s.ticketFk
- FROM vn.sale s
- JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
- JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment)
- )
- SELECT t.id INTO vTicket
- FROM vn.ticket t
- LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
- LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
- JOIN hedera.`order` o
- ON o.address_id = t.addressFk
- AND vWarehouse = t.warehouseFk
- AND o.date_send = t.landed
- AND DATE(t.shipped) = vShipment
- WHERE o.id = vSelf
- AND t.refFk IS NULL
- AND tp.ticketFk IS NULL
- AND IFNULL(tls.alertLevel,0) = 0
- LIMIT 1;
-
- -- Crea el ticket en el caso de no existir uno adecuado
- IF vTicket IS NULL
- THEN
-
- SET vShipment = IFNULL(vShipment, util.VN_CURDATE());
-
- CALL vn.ticket_add(
- vClientId,
- vShipment,
- vWarehouse,
- vCompanyId,
- vAddress,
- vAgencyModeId,
- NULL,
- vDelivery,
- vUserId,
- TRUE,
- vTicket
- );
- ELSE
- INSERT INTO vn.ticketTracking
- SET ticketFk = vTicket,
- workerFk = vUserId,
- stateFk = TICKET_FREE;
- END IF;
-
- INSERT IGNORE INTO vn.orderTicket
- SET orderFk = vSelf,
- ticketFk = vTicket;
-
- -- Añade las notas
-
- IF vNotes IS NOT NULL AND vNotes != ''
- THEN
- INSERT INTO vn.ticketObservation SET
- ticketFk = vTicket,
- observationTypeFk = 4 /* salesperson */,
- `description` = vNotes
- ON DUPLICATE KEY UPDATE
- `description` = CONCAT(VALUES(`description`),'. ', `description`);
- END IF;
-
- -- Añade los movimientos y sus componentes
-
- OPEN cRows;
-
- lRows: LOOP
- SET vDone = FALSE;
- FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem;
-
- IF vDone THEN
- LEAVE lRows;
- END IF;
-
- SET vSale = NULL;
-
- SELECT s.id, s.quantity INTO vSale, vOldQuantity
- FROM vn.sale s
- WHERE ticketFk = vTicket
- AND price = vPrice
- AND itemFk = vItem
- AND discount = 0
- LIMIT 1;
-
- IF vSale THEN
- UPDATE vn.sale
- SET quantity = quantity + vAmount,
- originalQuantity = quantity
- WHERE id = vSale;
-
- SELECT s.quantity INTO vNewQuantity
- FROM vn.sale s
- WHERE id = vSale;
- ELSE
- -- Obtiene el coste
- SELECT SUM(rc.`price`) valueSum INTO vPriceFixed
- FROM orderRowComponent rc
- JOIN vn.component c ON c.id = rc.componentFk
- JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase
- WHERE rc.rowFk = vRowId;
-
- INSERT INTO vn.sale
- SET itemFk = vItem,
- ticketFk = vTicket,
- concept = vConcept,
- quantity = vAmount,
- price = vPrice,
- priceFixed = vPriceFixed,
- isPriceFixed = TRUE;
-
- SET vSale = LAST_INSERT_ID();
-
- INSERT INTO vn.saleComponent
- (saleFk, componentFk, `value`)
- SELECT vSale, rc.componentFk, rc.price
- FROM orderRowComponent rc
- JOIN vn.component c ON c.id = rc.componentFk
- WHERE rc.rowFk = vRowId
- GROUP BY vSale, rc.componentFk;
- END IF;
-
- UPDATE order_row SET Id_Movimiento = vSale
- WHERE id = vRowId;
-
- -- Inserta en putOrder si la compra es de Floramondo
- IF vIsLogifloraItem THEN
- CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment);
-
- SET @available := 0;
-
- SELECT GREATEST(0,available) INTO @available
- FROM cache.availableNoRaids
- WHERE calc_id = vCalc
- AND item_id = vItem;
-
- UPDATE cache.availableNoRaids
- SET available = GREATEST(0,available - vAmount)
- WHERE item_id = vItem
- AND calc_id = vCalc;
-
- INSERT INTO edi.putOrder (
- deliveryInformationID,
- supplyResponseId,
- quantity ,
- EndUserPartyId,
- EndUserPartyGLN,
- FHAdminNumber,
- saleFk
- )
- SELECT di.ID,
- i.supplyResponseFk,
- CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask),
- o.address_id ,
- vClientId,
- IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber),
- vSale
- FROM edi.deliveryInformation di
- JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId
- JOIN edi.floraHollandConfig fhc
- JOIN hedera.`order` o ON o.id = vSelf
- WHERE i.id = vItem
- AND di.LatestOrderDateTime > util.VN_NOW()
- AND vAmount > @available
- LIMIT 1;
- END IF;
- END LOOP;
-
- CLOSE cRows;
- END LOOP;
-
- CLOSE cDates;
-
- UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW()
- WHERE id = vSelf;
-
- COMMIT;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_new`(
- vSerial VARCHAR(255),
- vInvoiceDate DATE,
- vTaxArea VARCHAR(25),
- OUT vNewInvoiceId INT)
-BEGIN
-/**
- * Creación de facturas emitidas.
- * requiere previamente tabla tmp.ticketToInvoice(id).
- *
- * @param vSerial serie a la cual se hace la factura
- * @param vInvoiceDate fecha de la factura
- * @param vTaxArea tipo de iva en relacion a la empresa y al cliente
- * @param vNewInvoiceId id de la factura que se acaba de generar
- * @return vNewInvoiceId
- */
- DECLARE vIsAnySaleToInvoice BOOL;
- DECLARE vIsAnyServiceToInvoice BOOL;
- DECLARE vNewRef VARCHAR(255);
- DECLARE vWorker INT DEFAULT account.myUser_getId();
- DECLARE vCompanyFk INT;
- DECLARE vInterCompanyFk INT;
- DECLARE vClientFk INT;
- DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
- DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
- DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
- DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
- DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
- DECLARE vNewInvoiceInFk INT;
- DECLARE vIsInterCompany BOOL DEFAULT FALSE;
- DECLARE vIsCEESerial BOOL DEFAULT FALSE;
- DECLARE vIsCorrectInvoiceDate BOOL;
- DECLARE vMaxShipped DATE;
- DECLARE vDone BOOL;
- DECLARE vTicketFk INT;
- DECLARE vCursor CURSOR FOR
- SELECT id
- FROM tmp.ticketToInvoice;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- SET vInvoiceDate = IFNULL(vInvoiceDate, util.VN_CURDATE());
-
- SELECT t.clientFk,
- t.companyFk,
- MAX(DATE(t.shipped)),
- DATE(vInvoiceDate) >= invoiceOut_getMaxIssued(
- vSerial,
- t.companyFk,
- YEAR(vInvoiceDate))
- INTO vClientFk,
- vCompanyFk,
- vMaxShipped,
- vIsCorrectInvoiceDate
- FROM tmp.ticketToInvoice tt
- JOIN ticket t ON t.id = tt.id;
-
- IF(vMaxShipped > vInvoiceDate) THEN
- CALL util.throw("Invoice date can't be less than max date");
- END IF;
-
- IF NOT vIsCorrectInvoiceDate THEN
- CALL util.throw('Exists an invoice with a previous date');
- END IF;
-
- -- Eliminem de tmp.ticketToInvoice els tickets que no han de ser facturats
- DELETE ti.*
- FROM tmp.ticketToInvoice ti
- JOIN ticket t ON t.id = ti.id
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN client c ON c.id = t.clientFk
- LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
- OR c.isTaxDataChecked = FALSE
- OR t.isDeleted
- OR c.hasToInvoice = FALSE
- OR itc.id IS NULL;
-
- SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
- INTO vIsAnySaleToInvoice
- FROM tmp.ticketToInvoice t
- JOIN sale s ON s.ticketFk = t.id;
-
- SELECT COUNT(*) > 0 INTO vIsAnyServiceToInvoice
- FROM tmp.ticketToInvoice t
- JOIN ticketService ts ON ts.ticketFk = t.id;
-
- IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice)
- AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase())
- THEN
-
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- INSERT INTO invoiceOut(
- ref,
- serial,
- issued,
- clientFk,
- dued,
- companyFk,
- siiTypeInvoiceOutFk
- )
- SELECT
- 1,
- vSerial,
- vInvoiceDate,
- vClientFk,
- getDueDate(vInvoiceDate, dueDay),
- vCompanyFk,
- IF(vSerial = vCorrectingSerial,
- vCplusCorrectingInvoiceTypeFk,
- IF(vSerial = vSimplifiedSerial,
- vCplusSimplifiedInvoiceTypeFk,
- vCplusStandardInvoiceTypeFk))
- FROM client
- WHERE id = vClientFk;
-
- SET vNewInvoiceId = LAST_INSERT_ID();
-
- SELECT `ref`
- INTO vNewRef
- FROM invoiceOut
- WHERE id = vNewInvoiceId;
-
- OPEN vCursor;
- l: LOOP
- SET vDone = FALSE;
- FETCH vCursor INTO vTicketFk;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- CALL ticket_recalc(vTicketFk, vTaxArea);
-
- END LOOP;
- CLOSE vCursor;
-
- UPDATE ticket t
- JOIN tmp.ticketToInvoice ti ON ti.id = t.id
- SET t.refFk = vNewRef;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
- CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
- SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
- FROM tmp.ticketToInvoice ti
- LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
- JOIN state s
- WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = getAlert3State(ti.id);
-
- INSERT INTO ticketTracking(stateFk,ticketFk,userFk)
- SELECT * FROM tmp.updateInter;
-
- CALL invoiceExpenseMake(vNewInvoiceId);
- CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
-
- UPDATE invoiceOut io
- JOIN (
- SELECT SUM(amount) total
- FROM invoiceOutExpense
- WHERE invoiceOutFk = vNewInvoiceId
- ) base
- JOIN (
- SELECT SUM(vat) total
- FROM invoiceOutTax
- WHERE invoiceOutFk = vNewInvoiceId
- ) vat
- SET io.amount = base.total + vat.total
- WHERE io.id = vNewInvoiceId;
-
- DROP TEMPORARY TABLE tmp.updateInter;
-
- SELECT COUNT(*), id
- INTO vIsInterCompany, vInterCompanyFk
- FROM company
- WHERE clientFk = vClientFk;
-
- IF (vIsInterCompany) THEN
-
- INSERT INTO invoiceIn(supplierFk, supplierRef, issued, companyFk)
- SELECT vCompanyFk, vNewRef, vInvoiceDate, vInterCompanyFk;
-
- SET vNewInvoiceInFk = LAST_INSERT_ID();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- (KEY (ticketFk))
- ENGINE = MEMORY
- SELECT id ticketFk
- FROM tmp.ticketToInvoice;
-
- CALL `ticket_getTax`('NATIONAL');
-
- SET @vTaxableBaseServices := 0.00;
- SET @vTaxCodeGeneral := NULL;
-
- INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
- SELECT vNewInvoiceInFk,
- @vTaxableBaseServices,
- sub.expenseFk,
- sub.taxTypeSageFk,
- sub.transactionTypeSageFk
- FROM (
- SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
- i.expenseFk,
- i.taxTypeSageFk,
- i.transactionTypeSageFk,
- @vTaxCodeGeneral := i.taxClassCodeFk
- FROM tmp.ticketServiceTax tst
- JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
- WHERE i.isService
- HAVING taxableBase
- ) sub;
-
- INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
- SELECT vNewInvoiceInFk,
- SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
- @vTaxableBaseServices, 0) taxableBase,
- i.expenseFk,
- i.taxTypeSageFk ,
- i.transactionTypeSageFk
- FROM tmp.ticketTax tt
- JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
- WHERE !i.isService
- GROUP BY tt.pgcFk
- HAVING taxableBase
- ORDER BY tt.priority;
-
- CALL invoiceInDueDay_calculate(vNewInvoiceInFk);
-
- SELECT COUNT(*) INTO vIsCEESerial
- FROM invoiceOutSerial
- WHERE code = vSerial;
-
- IF vIsCEESerial THEN
-
- INSERT INTO invoiceInIntrastat (
- invoiceInFk,
- intrastatFk,
- amount,
- stems,
- countryFk,
- net)
- SELECT
- vNewInvoiceInFk,
- i.intrastatFk,
- SUM(CAST((s.quantity * s.price * (100 - s.discount) / 100 ) AS DECIMAL(10, 2))),
- SUM(CAST(IFNULL(i.stems, 1) * s.quantity AS DECIMAL(10, 2))),
- su.countryFk,
- CAST(SUM(IFNULL(i.stems, 1)
- * s.quantity
- * IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000) AS DECIMAL(10, 2))
- FROM sale s
- JOIN ticket t ON s.ticketFk = t.id
- JOIN supplier su ON su.id = t.companyFk
- JOIN item i ON i.id = s.itemFk
- LEFT JOIN itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
- WHERE t.refFk = vNewRef
- GROUP BY i.intrastatFk;
-
- END IF;
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.ticketAmount;
- DROP TEMPORARY TABLE tmp.ticketTax;
- DROP TEMPORARY TABLE tmp.ticketServiceTax;
- END IF;
- END IF;
- DROP TEMPORARY TABLE `tmp`.`ticketToInvoice`;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`(vSectorFk INT)
-proc:BEGIN
-
- DECLARE vCalcVisibleFk INT;
- DECLARE vCalcAvailableFk INT;
- DECLARE hasFatherSector BOOLEAN;
- DECLARE vBuyerFk INT DEFAULT 0;
- DECLARE vWarehouseFk INT DEFAULT 0;
- DECLARE vSonSectorFk INT;
- DECLARE vWorkerFk INT;
-
- 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
- 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
- AND s.isMain;
-
- 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
- SELECT *
- FROM (
- SELECT iss.itemFk,
- i.longName,
- i.size,
- i.subName producer,
- IFNULL(a.available,0) available,
- SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible,0), 0)) upstairs,
- SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs,
- IF(it.isPackaging, NULL, IFNULL(v.visible,0)) as visible,
- vSectorFk sectorFk
- FROM vn.itemShelvingStock iss
- JOIN vn.sector s ON s.id = iss.sectorFk
- JOIN vn.item i on i.id = iss.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk)
- 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
- WHERE vSectorFk IN (iss.sectorFk, s.sonFk)
- GROUP BY iss.itemFk
-
- UNION ALL
-
- SELECT v.item_id,
- i.longName,
- i.size,
- i.subName producer,
- IFNULL(a.available,0) as available,
- 0 upstairs,
- 0 downstairs,
- IF(it.isPackaging, NULL, v.visible) visible,
- vSectorFk as sectorFk
- 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
- LEFT JOIN cache.available a ON a.item_id = v.item_id AND a.calc_id = vCalcAvailableFk
- WHERE v.calc_id = vCalcVisibleFk
- AND iss.itemFk IS NULL
- AND it.isInventory
- ) sub GROUP BY itemFk;
-
- 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
- JOIN vn.item i ON i.id = ishr.itemFk
- LEFT JOIN (SELECT s.itemFk, sum(s.quantity) as notPickedYed
- FROM vn.ticket t
- JOIN vn.ticketStateToday tst ON tst.ticketFk = t.id
- JOIN vn.sale s ON s.ticketFk = t.id
- WHERE t.warehouseFk = vWarehouseFk
- AND tst.alertLevel = 0
- GROUP BY s.itemFk
- ) sub ON sub.itemFk = ishr.itemFk
- ORDER BY i.typeFk, i.longName;
- ELSE
- CREATE TEMPORARY TABLE tmp.itemShelvingRadar
- (PRIMARY KEY (itemFk))
- ENGINE = MEMORY
- SELECT iss.itemFk,
- 0 `hour`,
- 0 `minute`,
- '--' itemPlacementCode,
- i.longName,
- i.size,
- i.subName producer,
- i.upToDown,
- 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(i.minimum * b.packing,0) itemPlacementSize,
- ips.onTheWay,
- iss.visible itemShelvingStock,
- IFNULL(v.visible,0) visible,
- b.isPickedOff,
- iss.sectorFk
- FROM vn.itemShelvingStock iss
- JOIN vn.item i on i.id = iss.itemFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- 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
- GROUP BY itemFk
- ) ips ON ips.itemFk = i.id
- WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk)
- OR iss.sectorFk = vSectorFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime;
- CREATE TEMPORARY TABLE tmp.itemOutTime
- SELECT *,SUM(amount) quantity
- FROM
- (SELECT item_id itemFk,
- 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
- JOIN vn.ticket t on t.id= io.ticketFk
- 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()
- AND st.isChecked
- ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
- WHERE t.warehouseFk = vWarehouseFk
- 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() + 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,
- firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity),
- `hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0),
- `minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0);
-
- UPDATE tmp.itemShelvingRadar isr
- JOIN (SELECT s.itemFk, sum(s.quantity) amount
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN ticketLastState tls ON tls.ticketFk = t.id
- WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
- AND tls.name = 'Prep Camara'
- GROUP BY s.itemFk) sub ON sub.itemFk = isr.itemFk
- SET isr.dayEndVisible = dayEndVisible + sub.amount,
- firstNegative = firstNegative + sub.amount;
-
- SELECT * FROM tmp.itemShelvingRadar;
- END IF;
-
- DROP TEMPORARY TABLE tmp.itemShelvingRadar;
-
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`(
- vItemFk INT,
- vWarehouseFk INT,
- vDate DATETIME
-)
-BEGIN
-/**
- * @vItemFk item a buscar
- * @vWarehouseFk almacen donde buscar
- * @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;
-
- IF vDate IS NULL THEN
- SELECT inventoried INTO vDateInventory
- FROM config;
- ELSE
- SELECT mockUtcTime INTO vDateInventory
- FROM util.config;
- END IF;
-
- CREATE OR REPLACE TEMPORARY TABLE tItemDiary(
- shipped DATE,
- `in` INT(11),
- `out` INT(11),
- alertLevel INT(11),
- stateName VARCHAR(20),
- `name` VARCHAR(50),
- reference VARCHAR(50),
- origin INT(11),
- clientFk INT(11),
- isPicked INT(11),
- isTicket TINYINT(1),
- lineFk INT(11),
- `order` TINYINT(3) UNSIGNED,
- clientType VARCHAR(20),
- claimFk INT(10) UNSIGNED,
- inventorySupplierFk INT(10)
- );
-
- INSERT INTO tItemDiary
- SELECT tr.landed shipped,
- b.quantity `in`,
- NULL `out`,
- st.alertLevel ,
- st.name stateName,
- s.name `name`,
- e.invoiceNumber reference,
- e.id origin,
- s.id clientFk,
- IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
- FALSE isTicket,
- b.id lineFk,
- NULL `order`,
- NULL clientType,
- NULL claimFk,
- ec.inventorySupplierFk
- FROM buy b
- 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()
- OR (util.VN_CURDATE() AND tr.isReceived),
- 'DELIVERED',
- 'FREE')
- JOIN entryConfig ec
- WHERE tr.landed >= vDateInventory
- AND vWarehouseFk = tr.warehouseInFk
- AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
- AND b.itemFk = vItemFk
- AND e.isExcludedFromAvailable = FALSE
- AND e.isRaid = FALSE
- UNION ALL
- SELECT tr.shipped,
- NULL,
- b.quantity,
- st.alertLevel,
- st.name,
- s.name,
- e.invoiceNumber,
- e.id,
- s.id,
- IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
- FALSE,
- b.id,
- NULL,
- NULL,
- NULL,
- ec.inventorySupplierFk
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- 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()
- OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
- 'DELIVERED',
- 'FREE')
- JOIN entryConfig ec
- WHERE tr.shipped >= vDateInventory
- AND vWarehouseFk = tr.warehouseOutFk
- AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
- AND b.itemFk = vItemFk
- AND e.isExcludedFromAvailable = FALSE
- AND w.isFeedStock = FALSE
- AND e.isRaid = FALSE
- UNION ALL
- SELECT DATE(t.shipped),
- NULL,
- s.quantity,
- st2.alertLevel,
- st2.name,
- t.nickname,
- t.refFk,
- t.id,
- t.clientFk,
- stk.id,
- TRUE,
- s.id,
- st.`order`,
- ct.`code`,
- cb.claimFk,
- NULL
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- LEFT JOIN state st ON st.`code` = ts.`code`
- 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',
- 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
- AND stk.stateFk = stPrep.id
- LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
- WHERE t.shipped >= vDateInventory
- AND s.itemFk = vItemFk
- AND vWarehouseFk =t.warehouseFk
- ORDER BY shipped,
- (inventorySupplierFk = clientFk) DESC,
- alertLevel DESC,
- isTicket,
- `order` DESC,
- isPicked DESC,
- `in` DESC,
- `out` DESC;
-
- IF vDate IS NULL THEN
-
- SET @a := 0;
- SET @currentLineFk := 0;
- SET @shipped := '';
-
- SELECT DATE(@shipped:= shipped) shipped,
- alertLevel,
- stateName,
- origin,
- reference,
- clientFk,
- name,
- `in` invalue,
- `out`,
- @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0) balance,
- @currentLineFk := IF (@shipped < util.VN_CURDATE()
- OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.`code` >= 'ON_PREPARATION')),
- lineFk,
- @currentLineFk) lastPreparedLineFk,
- isTicket,
- lineFk,
- isPicked,
- clientType,
- claimFk
- FROM tItemDiary
- LEFT JOIN alertLevel a ON a.id = tItemDiary.alertLevel;
-
- ELSE
- SELECT SUM(`in`) - SUM(`out`) INTO @a
- FROM tItemDiary
- WHERE shipped < vDate;
-
- SELECT vDate shipped,
- 0 alertLevel,
- 0 stateName,
- 0 origin,
- '' reference,
- 0 clientFk,
- 'Inventario calculado',
- @a invalue,
- NULL `out`,
- @a balance,
- 0 lastPreparedLineFk,
- 0 isTicket,
- 0 lineFk,
- 0 isPicked,
- 0 clientType,
- 0 claimFk
- UNION ALL
- 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 ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`(
- vWarehouseFk INT,
- vScopeDays INT
-)
-proc: BEGIN
-/**
- * Devuelve un listado de tickets con parámetros relativos a la producción de los días en rango.
- *
- * @param vWarehouseFk Identificador de warehouse
- * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo.
- *
- * @return Table tmp.productionBuffer
- */
- DECLARE vEndingDate DATETIME;
- DECLARE vIsTodayRelative BOOLEAN;
-
- SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
- INTO vEndingDate
- FROM productionConfig;
-
- SELECT isTodayRelative INTO vIsTodayRelative
- FROM worker
- WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos
-
- CALL prepareTicketList(util.yesterday(), vEndingDate);
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
- SELECT * FROM tmp.productionTicket;
-
- CALL prepareClientList();
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems
- (INDEX (ticketFk)) ENGINE = MEMORY
- SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped
- FROM tmp.productionTicket tt
- JOIN ticket t ON t.id = tt.ticketFk;
-
- CALL ticket_getProblems(vIsTodayRelative);
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.productionBuffer
- (PRIMARY KEY(ticketFk), previaParking VARCHAR(255))
- ENGINE = MEMORY
- SELECT tt.ticketFk,
- tt.clientFk,
- t.warehouseFk,
- t.nickname,
- t.packages,
- IF(HOUR(t.shipped), HOUR(t.shipped), COALESCE(HOUR(zc.hour),HOUR(z.hour))) HH,
- COALESCE(HOUR(zc.hour), HOUR(z.hour)) Departure,
- COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) mm,
- t.routeFk,
- IF(dm.code = 'DELIVERY', z.`id`, 0) zona,
- t.nickname addressNickname,
- a.postalCode,
- a.city,
- p.name province,
- CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency,
- am.id agencyModeFk,
- 0 `lines`,
- CAST( 0 AS DECIMAL(5,2)) m3,
- CAST( 0 AS DECIMAL(5,2)) preparationRate,
- "" problem,
- IFNULL(tls.state,2) state,
- w.code workerCode,
- DATE(t.shipped) shipped,
- wk.code salesPersonCode,
- p.id provinceFk,
- tls.productionOrder,
- IFNULL(tls.alertLevel, 0) alertLevel,
- t.isBoxed palletized,
- IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion,
- tlu.lastUpdated,
- IFNULL(st.graphCategory, 0) graphCategory,
- pk.code parking,
- 0 H,
- 0 V,
- 0 N,
- st.isOk,
- ag.isOwn,
- rm.bufferFk
- FROM tmp.productionTicket tt
- JOIN ticket t ON tt.ticketFk = t.id
- LEFT JOIN ticketStateToday tst ON tst.ticket = t.id
- LEFT JOIN state st ON st.id = tst.state
- LEFT JOIN client c ON c.id = t.clientFk
- LEFT JOIN worker wk ON wk.id = c.salesPersonFk
- JOIN address a ON a.id = t.addressFk
- LEFT JOIN province p ON p.id = a.provinceFk
- JOIN agencyMode am ON am.id = t.agencyModeFk
- JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
- JOIN agency ag ON ag.id = am.agencyFk
- LEFT JOIN ticketState tls ON tls.ticketFk = tt.ticketFk
- LEFT JOIN ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk
- LEFT JOIN worker w ON w.id = tls.userFk
- LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk
- LEFT JOIN `zone` z ON z.id = t.zoneFk
- LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
- AND DATE(t.shipped) = zc.dated
- LEFT JOIN ticketParking tp ON tp.ticketFk = t.id
- 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
- FROM tmp.productionBuffer pb
- 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
- GROUP BY pb.ticketFk
- ) t ON t.ticketFk = pb.ticketFk
- SET pb.previaParking = t.previaParking;
-
- -- Problemas por ticket
- ALTER TABLE tmp.productionBuffer
- CHANGE COLUMN `problem` `problem` VARCHAR(255),
- ADD COLUMN `collectionH` INT,
- ADD COLUMN `collectionV` INT,
- ADD COLUMN `collectionN` INT;
-
- UPDATE tmp.productionBuffer pb
- JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk
- SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage, ''),
- IFNULL(tp.itemDelay, ''),
- IFNULL(tp.itemLost, ''),
- IF(tp.isFreezed, ' CONGELADO',''),
- IF(tp.hasHighRisk, ' RIESGO',''),
- IF(tp.hasTicketRequest, ' COD 100',''),
- IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'),
- IF(tp.hasComponentLack, ' COMPONENTES', ''),
- IF(HOUR(util.VN_NOW()) < pb.HH AND tp.isTooLittle, ' PEQUEÑO', '')
- ) AS char(255)));
-
- -- Clientes Nuevos o Recuperados
- UPDATE tmp.productionBuffer pb
- LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk
- JOIN productionConfig pc
- SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255)))
- WHERE (cnb.clientFk IS NULL OR cnb.isRookie)
- AND pc.rookieDays;
-
- -- Líneas y volumen por ticket
- UPDATE tmp.productionBuffer pb
- JOIN (
- SELECT tt.ticketFk,
- COUNT(*) `lines`,
- SUM(sv.volume) m3,
- IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate
- FROM tmp.productionTicket tt
- JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk
- GROUP BY tt.ticketFk
- ) m ON m.ticketFk = pb.ticketFk
- SET pb.`lines` = m.`lines`,
- pb.m3 = m.m3,
- pb.preparationRate = m.rate;
-
- DELETE FROM tmp.productionBuffer
- WHERE NOT `lines`;
-
- -- Lineas por linea de encajado
- UPDATE tmp.productionBuffer pb
- JOIN (
- SELECT ticketFk,
- SUM(sub.H) H,
- SUM(sub.V) V,
- SUM(sub.N) N
- FROM (
- SELECT t.ticketFk,
- SUM(i.itemPackingTypeFk = 'H') H,
- SUM(i.itemPackingTypeFk = 'V') V,
- SUM(i.itemPackingTypeFk IS NULL) N
- FROM tmp.productionTicket t
- JOIN sale s ON s.ticketFk = t.ticketFk
- JOIN item i ON i.id = s.itemFk
- GROUP BY t.ticketFk, i.itemPackingTypeFk
- ) sub
- GROUP BY ticketFk
- ) sub2 ON sub2.ticketFk = pb.ticketFk
- SET pb.H = sub2.H,
- pb.V = sub2.V,
- pb.N = sub2.N;
-
- -- Colecciones segun tipo de encajado
- UPDATE tmp.productionBuffer pb
- JOIN ticketCollection tc ON pb.ticketFk = tc.ticketFk
- SET pb.collectionH = IF(pb.H, tc.collectionFk, NULL),
- pb.collectionV = IF(pb.V, tc.collectionFk, NULL),
- pb.collectionN = IF(pb.N, tc.collectionFk, NULL);
-
- -- Previa pendiente
- ALTER TABLE tmp.productionBuffer
- ADD previousWithoutParking BOOL DEFAULT FALSE;
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticketWithPrevia
- (ticketFk INT PRIMARY KEY,
- salesCount INT DEFAULT 0,
- salesInParkingCount INT DEFAULT 0)
- ENGINE = MEMORY;
-
- -- Insertamos todos los tickets que tienen productos parkineados
- -- en sectores de previa, segun el sector
- CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock
- (PRIMARY KEY(itemFk, sectorFk))
- ENGINE = MEMORY
- SELECT ish.itemFk,
- p.sectorFk,
- sc.isPreviousPrepared,
- sc.itemPackingTypeFk
- FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
- JOIN parking p ON p.id = sh.parkingFk
- JOIN sector sc ON sc.id = p.sectorFk
- WHERE p.sectorFk
- AND ish.visible
- GROUP BY ish.itemFk, p.sectorFk;
-
- INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
- SELECT pb.ticketFk, COUNT(DISTINCT s.id)
- FROM tmp.productionBuffer pb
- JOIN sale s ON s.ticketFk = pb.ticketFk
- JOIN tItemShelvingStock iss ON iss.itemFk = s.itemFk
- JOIN sector sc ON sc.id = iss.sectorFk
- JOIN item i ON i.id = iss.itemFk
- WHERE iss.isPreviousPrepared
- 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
- UPDATE tmp.ticketWithPrevia twp
- JOIN (
- SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount
- FROM tmp.productionBuffer pb
- JOIN sale s ON s.ticketFk = pb.ticketFk
- 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;
-
- -- Marcamos como pendientes aquellos que no coinciden las cantidades
- UPDATE tmp.productionBuffer pb
- JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk
- SET pb.previousWithoutParking = TRUE
- WHERE twp.salesCount > twp.salesInParkingCount;
-
- DROP TEMPORARY TABLE
- tmp.productionTicket,
- tmp.ticket,
- tmp.risk,
- tmp.ticket_problems,
- tmp.ticketWithPrevia,
- tItemShelvingStock;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInsert`
- BEFORE INSERT ON `expedition`
- FOR EACH ROW
-BEGIN
- DECLARE intcounter INT;
- DECLARE vShipFk INT;
-
- SET NEW.editorFk = account.myUser_getId();
-
- IF NEW.freightItemFk IS NOT NULL THEN
-
- UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
-
- SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
- FROM expedition e
- INNER JOIN ticket t1 ON e.ticketFk = t1.id
- LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
- INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
- AND t1.warehouseFk = t2.warehouseFk
- WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
- AND t1.agencyModeFk = t2.agencyModeFk;
-
- SET NEW.`counter` = intcounter;
- END IF;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption INT)
-proc: BEGIN
-/**
- * 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 vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicketFk INT;
- 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;
-
- OPEN vCur;
-
- l: LOOP
- SET vDone = FALSE;
- 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,
- t.landed
- INTO vIsEditable,
- vZoneFk,
- vWarehouseFk,
- vShipped,
- vAddressFk,
- vAgencyModeFk,
- vLanded
- FROM ticket t
- LEFT JOIN ticketState ts ON t.id = ts.ticketFk
- LEFT JOIN alertLevel al ON al.id = ts.alertLevel
- WHERE t.id = vTicketFk;
-
- CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
-
- 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)
- 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);
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT s.id saleFk, vWarehouseFk warehouseFk
- FROM sale s
- JOIN tmp.recalculateSales rs ON s.id = rs.id
- WHERE s.ticketFk = vTicketFk;
-
- 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
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketFk
- GROUP BY s.itemFk;
-
- CALL catalog_componentPrepare();
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- IF vOption IS NULL THEN
- SET vOption = IF(vIsEditable, 1, 6);
- END IF;
-
- CALL ticketComponentUpdateSale(vOption);
- CALL catalog_componentPurge();
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE tmp.sale;
-
- END LOOP;
- CLOSE vCur;
-
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_new`(
- vSerial VARCHAR(255),
- vInvoiceDate DATE,
- vTaxArea VARCHAR(25),
- OUT vNewInvoiceId INT)
-BEGIN
-/**
- * Creación de facturas emitidas.
- * requiere previamente tabla tmp.ticketToInvoice(id).
- *
- * @param vSerial serie a la cual se hace la factura
- * @param vInvoiceDate fecha de la factura
- * @param vTaxArea tipo de iva en relacion a la empresa y al cliente
- * @param vNewInvoiceId id de la factura que se acaba de generar
- * @return vNewInvoiceId
- */
- DECLARE vIsAnySaleToInvoice BOOL;
- DECLARE vIsAnyServiceToInvoice BOOL;
- DECLARE vNewRef VARCHAR(255);
- DECLARE vWorker INT DEFAULT account.myUser_getId();
- DECLARE vCompanyFk INT;
- DECLARE vInterCompanyFk INT;
- DECLARE vClientFk INT;
- DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
- DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
- DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
- DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
- DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
- DECLARE vNewInvoiceInFk INT;
- DECLARE vIsInterCompany BOOL DEFAULT FALSE;
- DECLARE vIsCEESerial BOOL DEFAULT FALSE;
- DECLARE vIsCorrectInvoiceDate BOOL;
- DECLARE vMaxShipped DATE;
- DECLARE vDone BOOL;
- DECLARE vTicketFk INT;
- DECLARE vCursor CURSOR FOR
- SELECT id
- FROM tmp.ticketToInvoice;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- SET vInvoiceDate = IFNULL(vInvoiceDate, util.VN_CURDATE());
-
- SELECT t.clientFk,
- t.companyFk,
- MAX(DATE(t.shipped)),
- DATE(vInvoiceDate) >= invoiceOut_getMaxIssued(
- vSerial,
- t.companyFk,
- YEAR(vInvoiceDate))
- INTO vClientFk,
- vCompanyFk,
- vMaxShipped,
- vIsCorrectInvoiceDate
- FROM tmp.ticketToInvoice tt
- JOIN ticket t ON t.id = tt.id;
-
- IF(vMaxShipped > vInvoiceDate) THEN
- CALL util.throw("Invoice date can't be less than max date");
- END IF;
-
- IF NOT vIsCorrectInvoiceDate THEN
- CALL util.throw('Exists an invoice with a previous date');
- END IF;
-
- -- Eliminem de tmp.ticketToInvoice els tickets que no han de ser facturats
- DELETE ti.*
- FROM tmp.ticketToInvoice ti
- JOIN ticket t ON t.id = ti.id
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN client c ON c.id = t.clientFk
- LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
- OR c.isTaxDataChecked = FALSE
- OR t.isDeleted
- OR c.hasToInvoice = FALSE
- OR itc.id IS NULL;
-
- SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
- INTO vIsAnySaleToInvoice
- FROM tmp.ticketToInvoice t
- JOIN sale s ON s.ticketFk = t.id;
-
- SELECT COUNT(*) > 0 INTO vIsAnyServiceToInvoice
- FROM tmp.ticketToInvoice t
- JOIN ticketService ts ON ts.ticketFk = t.id;
-
- IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice)
- AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase())
- THEN
-
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- INSERT INTO invoiceOut(
- ref,
- serial,
- issued,
- clientFk,
- dued,
- companyFk,
- siiTypeInvoiceOutFk
- )
- SELECT
- 1,
- vSerial,
- vInvoiceDate,
- vClientFk,
- getDueDate(vInvoiceDate, dueDay),
- vCompanyFk,
- IF(vSerial = vCorrectingSerial,
- vCplusCorrectingInvoiceTypeFk,
- IF(vSerial = vSimplifiedSerial,
- vCplusSimplifiedInvoiceTypeFk,
- vCplusStandardInvoiceTypeFk))
- FROM client
- WHERE id = vClientFk;
-
- SET vNewInvoiceId = LAST_INSERT_ID();
-
- SELECT `ref`
- INTO vNewRef
- FROM invoiceOut
- WHERE id = vNewInvoiceId;
-
- OPEN vCursor;
- l: LOOP
- SET vDone = FALSE;
- FETCH vCursor INTO vTicketFk;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- CALL ticket_recalc(vTicketFk, vTaxArea);
-
- END LOOP;
- CLOSE vCursor;
-
- UPDATE ticket t
- JOIN tmp.ticketToInvoice ti ON ti.id = t.id
- SET t.refFk = vNewRef;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
- CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
- SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
- FROM tmp.ticketToInvoice ti
- LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
- JOIN state s
- WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = getAlert3State(ti.id);
-
- INSERT INTO ticketTracking(stateFk,ticketFk,userFk)
- SELECT * FROM tmp.updateInter;
-
- CALL invoiceExpenseMake(vNewInvoiceId);
- CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
-
- UPDATE invoiceOut io
- JOIN (
- SELECT SUM(amount) total
- FROM invoiceOutExpense
- WHERE invoiceOutFk = vNewInvoiceId
- ) base
- JOIN (
- SELECT SUM(vat) total
- FROM invoiceOutTax
- WHERE invoiceOutFk = vNewInvoiceId
- ) vat
- SET io.amount = base.total + vat.total
- WHERE io.id = vNewInvoiceId;
-
- DROP TEMPORARY TABLE tmp.updateInter;
-
- SELECT COUNT(*), id
- INTO vIsInterCompany, vInterCompanyFk
- FROM company
- WHERE clientFk = vClientFk;
-
- IF (vIsInterCompany) THEN
-
- INSERT INTO invoiceIn(supplierFk, supplierRef, issued, companyFk)
- SELECT vCompanyFk, vNewRef, vInvoiceDate, vInterCompanyFk;
-
- SET vNewInvoiceInFk = LAST_INSERT_ID();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- (KEY (ticketFk))
- ENGINE = MEMORY
- SELECT id ticketFk
- FROM tmp.ticketToInvoice;
-
- CALL `ticket_getTax`('NATIONAL');
-
- SET @vTaxableBaseServices := 0.00;
- SET @vTaxCodeGeneral := NULL;
-
- INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
- SELECT vNewInvoiceInFk,
- @vTaxableBaseServices,
- sub.expenseFk,
- sub.taxTypeSageFk,
- sub.transactionTypeSageFk
- FROM (
- SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
- i.expenseFk,
- i.taxTypeSageFk,
- i.transactionTypeSageFk,
- @vTaxCodeGeneral := i.taxClassCodeFk
- FROM tmp.ticketServiceTax tst
- JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
- WHERE i.isService
- HAVING taxableBase
- ) sub;
-
- INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
- SELECT vNewInvoiceInFk,
- SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
- @vTaxableBaseServices, 0) taxableBase,
- i.expenseFk,
- i.taxTypeSageFk ,
- i.transactionTypeSageFk
- FROM tmp.ticketTax tt
- JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
- WHERE !i.isService
- GROUP BY tt.pgcFk
- HAVING taxableBase
- ORDER BY tt.priority;
-
- CALL invoiceInDueDay_calculate(vNewInvoiceInFk);
-
- SELECT COUNT(*) INTO vIsCEESerial
- FROM invoiceOutSerial
- WHERE code = vSerial;
-
- IF vIsCEESerial THEN
-
- INSERT INTO invoiceInIntrastat (
- invoiceInFk,
- intrastatFk,
- amount,
- stems,
- countryFk,
- net)
- SELECT
- vNewInvoiceInFk,
- i.intrastatFk,
- SUM(CAST((s.quantity * s.price * (100 - s.discount) / 100 ) AS DECIMAL(10, 2))),
- SUM(CAST(IFNULL(i.stems, 1) * s.quantity AS DECIMAL(10, 2))),
- su.countryFk,
- CAST(SUM(IFNULL(i.stems, 1)
- * s.quantity
- * IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000) AS DECIMAL(10, 2))
- FROM sale s
- JOIN ticket t ON s.ticketFk = t.id
- JOIN supplier su ON su.id = t.companyFk
- JOIN item i ON i.id = s.itemFk
- LEFT JOIN itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
- WHERE t.refFk = vNewRef
- GROUP BY i.intrastatFk;
-
- END IF;
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.ticketAmount;
- DROP TEMPORARY TABLE tmp.ticketTax;
- DROP TEMPORARY TABLE tmp.ticketServiceTax;
- END IF;
- END IF;
- DROP TEMPORARY TABLE `tmp`.`ticketToInvoice`;
-END$$
-DELIMITER ;
diff --git a/db/changes/240201/01-refactorHasAnyNegativeBase.sql b/db/changes/240201/01-refactorHasAnyNegativeBase.sql
deleted file mode 100644
index a3eb2d9c7..000000000
--- a/db/changes/240201/01-refactorHasAnyNegativeBase.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-DELIMITER $$
-$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`() RETURNS tinyint(1)
- DETERMINISTIC
-BEGIN
-
-/**
-* Calcula si existe alguna base imponible negativa
-* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
-*
-* returns BOOLEAN
-*/
-
- DECLARE hasAnyNegativeBase BOOLEAN;
-
- CALL getTaxBases();
-
- SELECT negative INTO hasAnyNegativeBase
- FROM tmp.taxBases
- LIMIT 1;
-
- DROP TEMPORARY TABLE
- tmp.ticketTax,
- tmp.ticket,
- tmp.taxBases;
-
- RETURN hasAnyNegativeBase;
-
-END$$
-DELIMITER ;
-
-
diff --git a/db/changes/240201/01-triggers.sql b/db/changes/240201/01-triggers.sql
deleted file mode 100644
index a7fa029b4..000000000
--- a/db/changes/240201/01-triggers.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInsert`
- BEFORE INSERT ON `expedition`
- FOR EACH ROW
-BEGIN
- DECLARE intcounter INT;
- DECLARE vShipFk INT;
-
- SET NEW.editorFk = account.myUser_getId();
-
- IF NEW.freightItemFk IS NOT NULL THEN
-
- UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
-
- SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
- FROM expedition e
- INNER JOIN ticket t1 ON e.ticketFk = t1.id
- LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
- INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
- AND t1.warehouseFk = t2.warehouseFk
- WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
- AND t1.agencyModeFk = t2.agencyModeFk;
-
- SET NEW.`counter` = intcounter;
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/changes/240201/01-views.sql b/db/changes/240201/01-views.sql
deleted file mode 100644
index 30b08b776..000000000
--- a/db/changes/240201/01-views.sql
+++ /dev/null
@@ -1,58 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`expeditionRoute_freeTickets` AS
-SELECT
- `t`.`routeFk` AS `routeFk`,
- `tss`.`ticketFk` AS `ticket`,
- `s`.`name` AS `code`,
- `w`.`name` AS `almacen`,
- `tss`.`updated` AS `updated`,
- `p`.`code` AS `parkingCode`
- FROM `vn`.`ticketState` `tss`
- JOIN `vn`.`ticket` `t` ON `t`.`id` = `tss`.`ticketFk`
- JOIN `vn`.`warehouse` `w` ON `w`.`id` = `t`.`warehouseFk`
- JOIN `vn`.`state` `s` ON `s`.`id` = `tss`.`state`
- LEFT JOIN `vn`.`ticketParking` `tp` ON `tp`.`ticketFk` = `t`.`id`
- LEFT JOIN `vn`.`parking` `p` ON `p`.`id` = `tp`.`parkingFk`
- WHERE IFNULL(`t`.`packages`, 0) = 0;
-
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`ticketState`
-AS SELECT `tt`.`created` AS `updated`,
- `tt`.`stateFk` AS `stateFk`,
- `tt`.`userFk` AS `userFk`,
- `tls`.`ticketFk` AS `ticketFk`,
- `s`.`id` AS `state`,
- `s`.`order` AS `productionOrder`,
- `s`.`alertLevel` AS `alertLevel`,
- `s`.`code` AS `code`,
- `s`.`isPreviousPreparable` AS `isPreviousPreparable`,
- `s`.`isPicked` AS `isPicked`
-FROM (
- (
- `vn`.`ticketLastState` `tls`
- JOIN `vn`.`ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
- )
- JOIN `vn`.`state` `s` ON(`s`.`id` = `tt`.`stateFk`)
- );
-
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`ticketStateToday`
-AS
-SELECT
- `ts`.`ticketFk` AS `ticket`,
- `ts`.`state` AS `state`,
- `ts`.`productionOrder` AS `productionOrder`,
- `ts`.`alertLevel` AS `alertLevel`,
- `ts`.`userFk` AS `worker`,
- `ts`.`code` AS `code`,
- `ts`.`updated` AS `updated`,
- `ts`.`isPicked` AS `isPicked`
-FROM
- `vn`.`ticketState` `ts`
- JOIN `vn`.`ticket` `t` ON `t`.`id` = `ts`.`ticketFk`
-WHERE
- `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `util`.`VN_CURDATE`() + INTERVAL 1 DAY;
-
diff --git a/db/changes/240202/.gitkeep b/db/changes/240202/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/changes/240202/00-aclWorkerTimeControl.sql b/db/changes/240202/00-aclWorkerTimeControl.sql
deleted file mode 100644
index 5ccb3131d..000000000
--- a/db/changes/240202/00-aclWorkerTimeControl.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-DELETE FROM salix.ACL
- WHERE model = 'WorkerTimeControl'
- AND property IN ('*','addTime');
-
-INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
- VALUES
- ('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'deleteTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'updateTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'sendMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'updateWorkerTimeControlMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'weeklyHourRecordEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'getMailStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
- ('WorkerTimeControl', 'resendWeeklyHourEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee');
diff --git a/db/changes/240203/.gitkeep b/db/changes/240203/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/changes/240203/00-viaExpressConfig.sql b/db/changes/240203/00-viaExpressConfig.sql
deleted file mode 100644
index 57832e7cd..000000000
--- a/db/changes/240203/00-viaExpressConfig.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE `vn`.`viaexpressConfig` ADD agencyModeFk int DEFAULT NULL NULL COMMENT 'Indica el agencyMode que es interdia';
-ALTER TABLE `vn`.`viaexpressConfig` ADD CONSTRAINT viaexpressConfig_agencyMode_Fk FOREIGN KEY (agencyModeFK) REFERENCES vn.agencyMode(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
diff --git a/db/changes/240401/.gitkeep b/db/changes/240401/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/changes/240401/00-removeStars.sql b/db/changes/240401/00-removeStars.sql
deleted file mode 100644
index ecc1664c8..000000000
--- a/db/changes/240401/00-removeStars.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE `vn`.`item` DROP COLUMN stars;
diff --git a/db/changes/240401/00-revokeItem.sql b/db/changes/240401/00-revokeItem.sql
deleted file mode 100644
index 5f6a30620..000000000
--- a/db/changes/240401/00-revokeItem.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-REVOKE UPDATE ON TABLE `vn`.`item` FROM `employee`;
-
-
-GRANT UPDATE(id, equivalent, stems, minPrice, isToPrint, family, box, category, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, comment, typeFk, generic, producerFk, description, density, relevancy, expenseFk, isActive, subName, tag5, value5, tag6, value6, tag7, value7, tag8, value8, tag9, value9, tag10, value10, minimum, upToDown, supplyResponseFk, hasKgPrice, isFloramondo, isFragile, numberOfItemsPerCask, embalageCode, quality, stemMultiplier, itemPackingTypeFk, packingOut, genericFk, packingShelve, isLaid, lastUsed, weightByPiece, weightByPiece, editorFk, recycledPlastic, nonRecycledPlastic, minQuantity) ON TABLE `vn`.`item` TO `employee`;
diff --git a/db/changes/240401/00-supplier.sql b/db/changes/240401/00-supplier.sql
deleted file mode 100644
index e60707eca..000000000
--- a/db/changes/240401/00-supplier.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-ALTER TABLE `vn`.`company` MODIFY COLUMN `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL NULL COMMENT 'Cuenta por defecto para ingresos desde este pais';
-
-
-ALTER TABLE `vn`.`supplierAccount`
-ADD COLUMN `countryFk` mediumint(8) unsigned DEFAULT NULL,
-ADD CONSTRAINT `fk_supplierAccount_country`
- FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE;
-
-ALTER TABLE `vn`.`supplierAccount`
-ADD UNIQUE KEY `uk_supplier_country` (`supplierFk`, `countryFk`);
-
-
diff --git a/db/changes/240401/00-ticketSmsToClientSms.sql b/db/changes/240401/00-ticketSmsToClientSms.sql
deleted file mode 100644
index cd3cf7dd3..000000000
--- a/db/changes/240401/00-ticketSmsToClientSms.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-ALTER TABLE `vn`.`clientSms` ADD `ticketFk` int(11) NULL;
-ALTER TABLE `vn`.`clientSms` ADD CONSTRAINT `clientSms_FK_2` FOREIGN KEY (`ticketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
-INSERT INTO`vn`.`clientSms` (`clientFk`, `smsFk`, `ticketFk`)
- SELECT `t`.`clientFk`, `s`.`smsFk`, `s`.`ticketFk`
- FROM `vn`.`clientSms` `s`
- JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`;
-
-RENAME TABLE `vn`.`ticketSms` TO `vn`.`ticketSms__`;
diff --git a/db/changes/240401/00-ticket_canbePostponed.sql b/db/changes/240401/00-ticket_canbePostponed.sql
deleted file mode 100644
index e0fbb99cf..000000000
--- a/db/changes/240401/00-ticket_canbePostponed.sql
+++ /dev/null
@@ -1,74 +0,0 @@
-DELIMITER $$
-$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
-BEGIN
-/**
- * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
- *
- * @param vOriginDated Fecha en cuestión
- * @param vFutureDated Fecha en el futuro a sondear
- * @param vWarehouseFk Identificador de vn.warehouse
- */
- CREATE OR REPLACE TEMPORARY TABLE tmp.filter
- (INDEX (id))
- SELECT sv.ticketFk id,
- sub2.id futureId,
- GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
- CAST(sum(litros) AS DECIMAL(10,0)) liters,
- CAST(count(*) AS DECIMAL(10,0)) `lines`,
- st.name state,
- sub2.iptd futureIpt,
- sub2.state futureState,
- t.clientFk,
- t.warehouseFk,
- ts.alertLevel,
- t.shipped,
- t.totalWithVat,
- sub2.shipped futureShipped,
- t.workerFk,
- st.code stateCode,
- sub2.code futureStateCode,
- st.classColor,
- sub2.classColor futureClassColor
- FROM vn.saleVolume sv
- JOIN vn.sale s ON s.id = sv.saleFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.ticket t ON t.id = sv.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.ticketState ts ON ts.ticketFk = t.id
- JOIN vn.state st ON st.id = ts.stateFk
- JOIN vn.alertLevel al ON al.id = ts.alertLevel
- LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
- LEFT JOIN (
- SELECT *
- FROM (
- SELECT
- t.addressFk,
- t.id,
- t.shipped,
- st.name state,
- st.code,
- st.classColor,
- GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
- FROM vn.ticket t
- JOIN vn.ticketState ts ON ts.ticketFk = t.id
- JOIN vn.state st ON st.id = ts.stateFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- WHERE t.shipped BETWEEN vFutureDated
- AND util.dayend(vFutureDated)
- AND t.warehouseFk = vWarehouseFk
- GROUP BY t.id
- ) sub
- GROUP BY sub.addressFk
- ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
- WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
- AND t.warehouseFk = vWarehouseFk
- AND al.code = 'FREE'
- AND tp.ticketFk IS NULL
- GROUP BY sv.ticketFk
- HAVING futureId;
-END$$
-DELIMITER ;
diff --git a/db/changes/240401/00-updateACL_Role_VnRole.sql b/db/changes/240401/00-updateACL_Role_VnRole.sql
deleted file mode 100644
index 5d108ac44..000000000
--- a/db/changes/240401/00-updateACL_Role_VnRole.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) VALUES
- ('VnRole','*','READ','ALLOW','ROLE','employee'),
- ('VnRole','*','WRITE','ALLOW','ROLE','it');
-
-DELETE FROM`salix`.`ACL` WHERE model='Role';
-
diff --git a/db/changes/240401/01-saleGroupDetailDefaultSize.sql b/db/changes/240401/01-saleGroupDetailDefaultSize.sql
deleted file mode 100644
index 34529ba78..000000000
--- a/db/changes/240401/01-saleGroupDetailDefaultSize.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE `vn`.`productionConfig` ADD itemPreviousDefaultSize int NULL COMMENT 'Altura por defecto para los artículos de previa';
-UPDATE IGNORE `vn`.`productionConfig` SET itemPreviousDefaultSize = 40 WHERE id = 1;
diff --git a/db/changes/240401/01-supplierAccount.sql b/db/changes/240401/01-supplierAccount.sql
deleted file mode 100644
index 21ce7c71e..000000000
--- a/db/changes/240401/01-supplierAccount.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-UPDATE `vn`.`supplierAccount` sa
- JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'FR'
- SET countryFk = c.id
- WHERE iban = 'FR7630003012690002801121597';
-
-UPDATE `vn`.`supplierAccount` sa
- JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'PT'
- SET countryFk = c.id
- WHERE iban = 'PT50001000005813059150168';
diff --git a/db/changes/240401/03-fixInvoiceOutBeforeInsert.sql b/db/changes/240401/03-fixInvoiceOutBeforeInsert.sql
deleted file mode 100644
index 0081c8803..000000000
--- a/db/changes/240401/03-fixInvoiceOutBeforeInsert.sql
+++ /dev/null
@@ -1,59 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInsert`
- BEFORE INSERT ON `invoiceOut`
- FOR EACH ROW
-BEGIN
-/**
- * Generates the next reference for the invoice serial. There cannot be gaps
- * between identifiers of the same serial!
- *
- * Reference format:
- * {0} Invoice serial
- * {1} The company code
- * {2-3} Last two digits of issue year
- * {4-$} Autoincrement identifier
- */
- DECLARE vRef INT DEFAULT 0;
- DECLARE vRefLen INT;
- DECLARE vRefPrefix VARCHAR(255);
- DECLARE vLastRef VARCHAR(255);
- DECLARE vCompanyCode INT;
- DECLARE vYearLen INT DEFAULT 2;
- DECLARE vPrefixLen INT;
-
- SELECT companyCode INTO vCompanyCode
- FROM company
- WHERE id = NEW.companyFk;
-
- IF vCompanyCode IS NULL THEN
- CALL util.throw('companyCodeNotDefined');
- END IF;
-
- SELECT MAX(i.ref) INTO vLastRef
- FROM invoiceOut i
- WHERE i.serial = NEW.serial
- AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.lastDayOfYear(NEW.issued)
- AND i.companyFk = NEW.companyFk;
-
- IF vLastRef IS NOT NULL THEN
- SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
- SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
- SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
- SET vRef = RIGHT(vLastRef, vRefLen);
- ELSE
- SELECT refLen INTO vRefLen FROM invoiceOutConfig;
- SET vRefPrefix = CONCAT(
- NEW.serial,
- vCompanyCode,
- RIGHT(YEAR(NEW.issued), vYearLen)
- );
- END IF;
-
- SET vRef = vRef + 1;
- IF LENGTH(vRef) > vRefLen THEN
- CALL util.throw('refIdLenExceeded');
- END IF;
-
- SET NEW.ref = CONCAT(vRefPrefix, LPAD(vRef, vRefLen, '0'));
-END$$
-DELIMITER ;
diff --git a/db/changes/240403/00-saleComponent.sql b/db/changes/240403/00-saleComponent.sql
deleted file mode 100644
index ea2b9c399..000000000
--- a/db/changes/240403/00-saleComponent.sql
+++ /dev/null
@@ -1,589 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption VARCHAR(25))
-proc: BEGIN
-/**
- * Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes
- *
- * @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 ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
-BEGIN
-/**
- * Comprueba que las ventas creadas entre un rango de fechas tienen componentes
- *
- * @param vCreatedFrom inicio del rango
- * @param vCreatedTo fin del rango
- */
- DECLARE v_done BOOL DEFAULT FALSE;
- DECLARE vSaleFk INTEGER;
- DECLARE vTicketFk INTEGER;
- DECLARE vConcept VARCHAR(50);
- DECLARE vCur CURSOR FOR
- SELECT s.id
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
- LEFT JOIN tmp.coste c ON c.id = s.id
- WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo
- AND c.id IS NULL
- AND t.agencyModeFk IS NOT NULL
- AND t.isDeleted IS FALSE
- AND t.warehouseFk = 60
- AND ic.merchandise != FALSE
- GROUP BY s.id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET v_done = TRUE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.coste;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.coste;
- CREATE TEMPORARY TABLE tmp.coste
- (PRIMARY KEY (id)) ENGINE = MEMORY
- SELECT s.id
- 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
- JOIN saleComponent sc ON sc.saleFk = s.id
- JOIN component c ON c.id = sc.componentFk
- JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 6
- WHERE s.created >= vCreatedFrom
- AND ic.merchandise != FALSE;
-
- OPEN vCur;
-
- l: LOOP
- SET v_done = FALSE;
- FETCH vCur INTO vSaleFk;
-
- IF v_done THEN
- LEAVE l;
- END IF;
-
- SELECT ticketFk, concept
- INTO vTicketFk, vConcept
- FROM sale
- WHERE id = vSaleFk;
-
- CALL sale_calculateComponent(vSaleFk, 'renewPrices');
- END LOOP;
-
- CLOSE vCur;
- DROP TEMPORARY TABLE tmp.coste;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption VARCHAR(25))
-proc: BEGIN
-/**
- * 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 vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicketFk INT;
- 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;
-
- OPEN vCur;
-
- l: LOOP
- SET vDone = FALSE;
- 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,
- t.landed
- INTO vIsEditable,
- vZoneFk,
- vWarehouseFk,
- vShipped,
- vAddressFk,
- vAgencyModeFk,
- vLanded
- FROM ticket t
- LEFT JOIN ticketState ts ON t.id = ts.ticketFk
- LEFT JOIN alertLevel al ON al.id = ts.alertLevel
- WHERE t.id = vTicketFk;
-
- CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
-
- 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)
- 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);
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT s.id saleFk, vWarehouseFk warehouseFk
- FROM sale s
- JOIN tmp.recalculateSales rs ON s.id = rs.id
- WHERE s.ticketFk = vTicketFk;
-
- 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
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketFk
- GROUP BY s.itemFk;
-
- CALL catalog_componentPrepare();
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- IF vOption IS NULL THEN
- SET vOption = IF(vIsEditable, 'renewPrices', 'imbalance');
- END IF;
-
- CALL ticketComponentUpdateSale(vOption);
- CALL catalog_componentPurge();
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE tmp.sale;
-
- END LOOP;
- CLOSE vCur;
-
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
-BEGIN
-/*
- * Recalcula los componentes un ticket clonado,
- * las lineas a precio cero fuerza para que tengan precio, el resto lo respeta
- * @param vTicketNew nuevo ticket clonado
- * @param vTicketOld icket original, a partir del qual se clonara el nuevo
-*/
-
- REPLACE INTO orderTicket(orderFk,ticketFk)
- 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
- FROM sale
- WHERE ticketFk = vTicketNew AND price = 0;
-
- CALL sale_recalcComponent('renewPrices');
-
- -- Bionizamos lineas con Preu > 0
- CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
- (PRIMARY KEY (id)) ENGINE = MEMORY
- SELECT id
- FROM sale
- WHERE ticketFk = vTicketNew AND price > 0;
-
- CALL sale_recalcComponent('imbalance');
-
- DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
-
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`(
- vTicketFk INT,
- vClientFk INT,
- vAgencyModeFk INT,
- vAddressFk INT,
- vWarehouseFk TINYINT,
- vCompanyFk SMALLINT,
- vShipped DATETIME,
- vLanded DATE,
- vIsDeleted BOOLEAN,
- vHasToBeUnrouted BOOLEAN,
- vOption VARCHAR(25))
-BEGIN
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
-
- 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
- t.clientFk = vClientFk,
- t.agencyModeFk = vAgencyModeFk,
- t.addressFk = vAddressFk,
- t.warehouseFk = vWarehouseFk,
- t.companyFk = vCompanyFk,
- t.landed = vLanded,
- t.shipped = vShipped,
- t.isDeleted = vIsDeleted
- WHERE
- t.id = vTicketFk;
-
- IF vHasToBeUnrouted THEN
- UPDATE ticket t SET t.routeFk = NULL
- WHERE t.id = vTicketFk;
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk))
- ENGINE = MEMORY
- SELECT id AS saleFk, vWarehouseFk warehouseFk
- FROM sale s WHERE s.ticketFk = vTicketFk;
-
- CALL ticketComponentUpdateSale (vOption);
-
- DROP TEMPORARY TABLE tmp.sale;
- COMMIT;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25))
-BEGIN
-/**
- * A partir de la tabla tmp.sale, crea los Movimientos_componentes
- * y modifica el campo Preu de la tabla Movimientos
- *
- * @param i_option integer tipo de actualizacion
- * @param table tmp.sale tabla memory con el campo saleFk, warehouseFk
- **/
- DECLARE vComponentFk INT;
-
- IF vCode <> 'renewPrices' THEN
- SELECT id INTO vComponentFk FROM component WHERE `code` = vCode;
- END IF;
-
- 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
- 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
- WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE);
-
- -- Añadir componente venta por paquete
- 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 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'
- LEFT JOIN (
- SELECT s.id
- FROM vn.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
- JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = tc.componentFk
- JOIN `component` c ON c.id = sc.componentFk AND c.code = 'lastUnitsDiscount'
- ) tp ON tp.id = s.id
- WHERE tp.id IS NULL
- HAVING resto <> 0) t;
-
- IF vCode <> 'renewPrices' THEN
- REPLACE INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
- FROM sale s
- JOIN tmp.sale tmps ON tmps.saleFk = s.id
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
- WHERE sc.saleFk <> vComponentFk
- GROUP BY s.id
- HAVING dif <> 0;
- ELSE
- 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
- 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' ;
-
- 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
- HAVING ROUND(saleValue, 4) <> 0;
- END IF;
-
- UPDATE sale s
- JOIN (
- 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
- JOIN componentType ct on ct.id = c.typeFk AND ct.isBase
- GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
- SET s.priceFixed = sumValue, s.isPriceFixed = 1;
-
- DELETE sc.*
- FROM saleComponent sc
- JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
- 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';
-
- INSERT INTO saleComponent(saleFk, componentFk, value)
- 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
- JOIN itemType it ON it.id = i.typeFk
- WHERE it.code = 'PRT' AND s.price > 0;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME)
-BEGIN
-
-/**
- * Comprueba que los tickets entre un rango de fechas tienen componentes
- * y recalcula sus componentes
- *
- * @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
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
- JOIN saleComponent sc ON sc.saleFk = s.id
- JOIN component c ON c.id = sc.componentFk
- JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1
- WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
- AND ic.merchandise;
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
- (primary key (id)) ENGINE = MEMORY
- SELECT DISTINCT s.id
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
- LEFT JOIN tmp.coste c ON c.id = s.id
- WHERE t.shipped >= vShippedFrom AND t.shipped <= vShippedTo
- AND c.id IS NULL
- AND ic.merchandise;
-
- CALL sale_recalcComponent('renewPrices');
-
- DROP TEMPORARY TABLE tmp.recalculateSales;
- DROP TEMPORARY TABLE tmp.coste;
- END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_componentMakeUpdate`(
- vTicketFk INT,
- vClientFk INT,
- vNickname VARCHAR(50),
- vAgencyModeFk INT,
- vAddressFk INT,
- vZoneFk INT,
- vWarehouseFk INT,
- vCompanyFk INT,
- vShipped DATETIME,
- vLanded DATE,
- vIsDeleted BOOLEAN,
- vHasToBeUnrouted BOOLEAN,
- vOption VARCHAR(25))
-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
- * @param vAgencyModeFk nueva agencia
- * @param vAddressFk nuevo consignatario
- * @param vZoneFk nueva zona
- * @param vWarehouseFk nuevo almacen
- * @param vCompanyFk nueva empresa
- * @param vShipped nueva fecha del envio de mercancia
- * @param vLanded nueva fecha de recepcion de mercancia
- * @param vIsDeleted si se borra el ticket
- * @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
- 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
- FROM tmp.zoneGetShipped
- WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1;
-
- UPDATE ticket t
- SET
- t.clientFk = vClientFk,
- t.nickname = vNickname,
- t.agencyModeFk = vAgencyModeFk,
- t.addressFk = vAddressFk,
- t.zoneFk = vZoneFk,
- t.zonePrice = vPrice,
- t.zoneBonus = vBonus,
- t.warehouseFk = vWarehouseFk,
- t.companyFk = vCompanyFk,
- t.landed = vLanded,
- t.shipped = vShipped,
- t.isDeleted = vIsDeleted
- WHERE
- t.id = vTicketFk;
-
- IF vHasToBeUnrouted THEN
- UPDATE ticket t SET t.routeFk = NULL
- WHERE t.id = vTicketFk;
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk))
- ENGINE = MEMORY
- SELECT id AS saleFk, vWarehouseFk warehouseFk
- FROM sale s WHERE s.ticketFk = vTicketFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
- CREATE TEMPORARY TABLE tmp.ticketComponent
- SELECT * FROM tmp.ticketComponentPreview;
-
- CALL ticketComponentUpdateSale (vOption);
-
- DROP TEMPORARY TABLE tmp.sale;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
-
- DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview;
-END$$
-DELIMITER ;
-
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25))
-proc: BEGIN
-
-/**
- * Crea tabla temporal para sale_recalcComponent() para recalcular los componentes
- *
- * @param vSelf Id del ticket
- * @param vOption si no se quiere forzar llamar con NULL
- */
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
- SELECT s.id
- FROM sale s
- WHERE s.ticketFk = vSelf;
-
- CALL sale_recalcComponent(vOption);
-
- DROP TEMPORARY TABLE tmp.recalculateSales;
-END$$
-DELIMITER ;
-
-TRUNCATE TABLE `vn`.`ticketUpdateAction`;
-INSERT INTO `vn`.`ticketUpdateAction` (id, description, code) VALUES(1, 'Cambiar los precios en el ticket', 'renewPrices');
-INSERT INTO `vn`.`ticketUpdateAction` (id, description, code) VALUES(2, 'Convertir en maná', 'mana');
\ No newline at end of file
diff --git a/db/changes/240601/.gitkeep b/db/changes/240601/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql
index 69a59885a..3be5893f7 100644
--- a/db/dump/.dump/data.sql
+++ b/db/dump/.dump/data.sql
@@ -4,52 +4,8 @@ USE `util`;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL);
-INSERT INTO `version` VALUES ('vn-database','10806','f73a447391b7541f41e3be2ccc05327c1254578e','2024-01-04 08:36:01','10808');
+INSERT INTO `version` VALUES ('vn-database','10818','c156178ea565d81485769882618e122d9cba5d4e','2024-01-25 10:00:48','10831');
-INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL);
@@ -74,7 +30,6 @@ INSERT INTO `versionLog` VALUES ('vn-database','10141','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL);
@@ -131,7 +86,6 @@ INSERT INTO `versionLog` VALUES ('vn-database','10207','00-Alter_table_entry.sql
INSERT INTO `versionLog` VALUES ('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10208','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada');
INSERT INTO `versionLog` VALUES ('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10215','00-renameIsInventory.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL);
@@ -473,7 +427,6 @@ INSERT INTO `versionLog` VALUES ('vn-database','10633','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10634','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-06-06 12:15:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10637','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-06-15 12:30:19',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10640','00-companyFkDrop.sql','jenkins@db-proxy2.static.verdnatura.es','2023-06-07 14:43:23',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10640','00-updateCompany.sql','jenkins@db-proxy1.static.verdnatura.es','2023-06-07 14:22:13',1205,'Tiempo de espera de bloqueo excedido; intente rearrancar la transacción');
INSERT INTO `versionLog` VALUES ('vn-database','10640','01-companyFkAi.sql','jenkins@db-proxy2.static.verdnatura.es','2023-06-07 14:43:23',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10640','02-companyFkCreate.sql','jenkins@db-proxy2.static.verdnatura.es','2023-06-07 14:47:04',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10640','04-supplierFkDrop.sql','jenkins@db-proxy2.static.verdnatura.es','2023-06-07 14:48:30',NULL,NULL);
@@ -544,7 +497,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10718','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10719','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-01 12:53:30',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10720','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-21 09:42:22',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10721','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-21 09:42:29',NULL,NULL);
-INSERT INTO `versionLog` VALUES ('vn-database','10722','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-09 13:00:29',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10724','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:28',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10725','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-09-12 14:15:14',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10726','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-21 15:32:20',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10727','00-addPrinterField.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-21 09:42:29',NULL,NULL);
@@ -558,6 +511,9 @@ INSERT INTO `versionLog` VALUES ('vn-database','10727','07-AddFieldsToPackingSit
INSERT INTO `versionLog` VALUES ('vn-database','10730','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-15 11:42:48',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10733','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-10-05 09:54:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10736','00-workerBossNull.sql','jenkins@db-proxy1.static.verdnatura.es','2023-09-22 00:02:05',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10738','00-addFieldToTravel.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:31',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10738','01-copyDataToTravel.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:31',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10738','03-deprecateDuaAwbFk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10739','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-10-10 10:19:07',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10740','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-02 09:13:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10741','01-refactorCplusTrascendency472.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-02 09:13:27',NULL,NULL);
@@ -582,7 +538,9 @@ INSERT INTO `versionLog` VALUES ('vn-database','10756','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10757','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-16 09:30:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10758','00-sectorType.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:17:18',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10758','01-dipole.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:17:18',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10758','02-agencyMode.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10761','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-16 09:30:58',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10764','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-04 12:07:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10768','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:37',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10771','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:37',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10773','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:38',NULL,NULL);
@@ -590,6 +548,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10775','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10778','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10782','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-03 10:18:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10783','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-24 14:49:17',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10784','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10785','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:33:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10785','02-invoiceIn.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:33:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10785','02-invoiceInTax.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:33:39',NULL,NULL);
@@ -599,7 +558,23 @@ INSERT INTO `versionLog` VALUES ('vn-database','10792','00-buy.sql','jenkins@db-
INSERT INTO `versionLog` VALUES ('vn-database','10798','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-03 10:21:14',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10799','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-26 12:00:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10800','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-03 10:21:16',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10801','00-firstScript.sql','jenkins@test-db-proxy1.servers.dc.verdnatura.es','2024-01-11 05:53:13',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10806','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2024-01-03 11:56:05',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10808','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10809','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10810','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2024-01-04 14:29:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10811','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10812','00-update.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10812','01-delete.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10812','02-rename.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10812','03-changePosition.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10812','04-unique.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10813','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10815','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2024-01-09 18:11:57',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10816','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10817','00-invoiceOutConfig_refLen.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-24 21:47:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10818','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','10827','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-23 12:32:13',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@@ -693,6 +668,7 @@ INSERT INTO `role` VALUES (123,'deliveryAssistant','Jefe auxiliar repartos',1,'2
INSERT INTO `role` VALUES (124,'hrBuyer','Recursos Humanos con Buyer',1,'2023-10-23 13:50:43','2023-10-23 13:50:43',NULL);
INSERT INTO `role` VALUES (125,'claimViewer','Trabajadores que consulta las reclamaciones ',1,'2023-11-16 09:14:46','2023-11-16 09:14:46',10578);
INSERT INTO `role` VALUES (126,'greenhouseBoss','Jefe de invernadero',1,'2023-11-16 14:32:13','2023-11-16 14:32:13',NULL);
+INSERT INTO `role` VALUES (127,'timeControl','Tablet para fichar',1,'2024-01-09 16:36:56','2024-01-09 16:36:56',NULL);
INSERT INTO `roleInherit` VALUES (1,1,2,NULL);
INSERT INTO `roleInherit` VALUES (2,1,3,NULL);
@@ -729,7 +705,6 @@ INSERT INTO `roleInherit` VALUES (37,34,1,NULL);
INSERT INTO `roleInherit` VALUES (38,34,13,NULL);
INSERT INTO `roleInherit` VALUES (39,34,33,NULL);
INSERT INTO `roleInherit` VALUES (40,35,1,NULL);
-INSERT INTO `roleInherit` VALUES (41,36,44,NULL);
INSERT INTO `roleInherit` VALUES (42,36,47,NULL);
INSERT INTO `roleInherit` VALUES (43,37,1,NULL);
INSERT INTO `roleInherit` VALUES (44,38,37,NULL);
@@ -912,7 +887,6 @@ INSERT INTO `roleInherit` VALUES (281,5,18,NULL);
INSERT INTO `roleInherit` VALUES (282,50,60,NULL);
INSERT INTO `roleInherit` VALUES (283,5,21,NULL);
INSERT INTO `roleInherit` VALUES (285,58,76,NULL);
-INSERT INTO `roleInherit` VALUES (287,69,58,NULL);
INSERT INTO `roleInherit` VALUES (288,115,66,NULL);
INSERT INTO `roleInherit` VALUES (290,104,115,NULL);
INSERT INTO `roleInherit` VALUES (291,115,103,NULL);
@@ -954,6 +928,10 @@ INSERT INTO `roleInherit` VALUES (350,49,75,NULL);
INSERT INTO `roleInherit` VALUES (351,72,35,NULL);
INSERT INTO `roleInherit` VALUES (353,110,49,NULL);
INSERT INTO `roleInherit` VALUES (354,103,119,NULL);
+INSERT INTO `roleInherit` VALUES (355,127,11,NULL);
+INSERT INTO `roleInherit` VALUES (356,123,125,NULL);
+INSERT INTO `roleInherit` VALUES (357,36,35,NULL);
+INSERT INTO `roleInherit` VALUES (358,36,49,NULL);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@@ -1098,13 +1076,11 @@ INSERT INTO `ACL` VALUES (165,'TicketDms','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee');
-INSERT INTO `ACL` VALUES (170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (172,'Sms','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (173,'Sms','send','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (176,'Device','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (177,'Device','*','*','ALLOW','ROLE','employee');
-INSERT INTO `ACL` VALUES (178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (179,'ItemLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (180,'RouteLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee');
@@ -1521,13 +1497,10 @@ INSERT INTO `ACL` VALUES (657,'Supplier','getItemsPackaging','READ','ALLOW','ROL
INSERT INTO `ACL` VALUES (658,'Ticket','closeAll','WRITE','ALLOW','ROLE','system');
INSERT INTO `ACL` VALUES (659,'Account','*','*','ALLOW','ROLE','developerBoss');
INSERT INTO `ACL` VALUES (664,'MailForward','*','*','ALLOW','ROLE','itManagement');
-INSERT INTO `ACL` VALUES (665,'Role','*','READ','ALLOW','ROLE','employee');
-INSERT INTO `ACL` VALUES (666,'Role','*','WRITE','ALLOW','ROLE','it');
INSERT INTO `ACL` VALUES (667,'VnUser','*','*','ALLOW','ROLE','itManagement');
INSERT INTO `ACL` VALUES (668,'VnUser','__get__preview','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (669,'VnUser','preview','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (670,'VnUser','create','*','ALLOW','ROLE','itManagement');
-INSERT INTO `ACL` VALUES (671,'VnUser','renewToken','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (672,'PackingSiteAdvanced','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (673,'InvoiceOut','makePdfAndNotify','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (674,'InvoiceOutConfig','*','READ','ALLOW','ROLE','invoicing');
@@ -1568,8 +1541,8 @@ INSERT INTO `ACL` VALUES (713,'Client','__get__addresses','READ','ALLOW','ROLE',
INSERT INTO `ACL` VALUES (714,'ExpeditionMistakeType','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (715,'WorkerMistakeType','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (716,'ExpeditionMistake','*','WRITE','ALLOW','ROLE','employee');
-INSERT INTO `ACL` VALUES (717,'WorkerMistake','*','WRITE','ALLOW','ROLE','coolerBoss');
-INSERT INTO `ACL` VALUES (718,'MistakesTypes','*','WRITE','ALLOW','ROLE','coolerBoss');
+INSERT INTO `ACL` VALUES (717,'WorkerMistake','*','WRITE','ALLOW','ROLE','coolerAssist');
+INSERT INTO `ACL` VALUES (718,'MistakesTypes','*','WRITE','ALLOW','ROLE','coolerAssist');
INSERT INTO `ACL` VALUES (719,'MistakeType','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (720,'MachineWorker','*','READ','ALLOW','ROLE','coolerAssist');
INSERT INTO `ACL` VALUES (721,'Printer','*','READ','ALLOW','ROLE','employee');
@@ -1608,7 +1581,7 @@ INSERT INTO `ACL` VALUES (754,'Route','find','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (755,'Route','findById','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee');
-INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryBoss');
+INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee');
@@ -1622,6 +1595,21 @@ INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','em
INSERT INTO `ACL` VALUES (769,'Route','insertTicket','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (770,'Route','getDeliveryPoint','READ','ALLOW','ROLE','deliveryBoss');
INSERT INTO `ACL` VALUES (771,'Route','summary','READ','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (772,'Route','getExpeditionSummary','READ','ALLOW','ROLE','delivery');
+INSERT INTO `ACL` VALUES (773,'WorkerTimeControl','login','READ','ALLOW','ROLE','timeControl');
+INSERT INTO `ACL` VALUES (774,'WorkerTimeControl','getClockIn','READ','ALLOW','ROLE','timeControl');
+INSERT INTO `ACL` VALUES (775,'WorkerTimeControl','clockIn','WRITE','ALLOW','ROLE','timeControl');
+INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateWorkerTimeControlMail','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (782,'WorkerTimeControl','getMailStates','READ','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (784,'VnRole','*','READ','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (785,'VnRole','*','WRITE','ALLOW','ROLE','it');
+INSERT INTO `ACL` VALUES (786,'State','isAllEditable','READ','ALLOW','ROLE','delivery');
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@@ -1941,7 +1929,7 @@ INSERT INTO `continent` VALUES (3,'África','AF');
INSERT INTO `continent` VALUES (4,'Europa','EU');
INSERT INTO `continent` VALUES (5,'Oceanía','OC');
-INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,104,763,0,0,0,0,28,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,106,763,0,0,0,0,28,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL);
INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL);
@@ -1952,28 +1940,28 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,33,NULL,72,1,1,1,10,1
INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',34,35,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (43,'VT','VENTAS',36,59,NULL,0,0,0,1,11,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (44,'management','GERENCIA',60,61,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',62,63,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (46,'delivery','REPARTO',64,65,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',66,67,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',68,69,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (43,'VT','VENTAS',36,61,NULL,0,0,0,1,12,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (44,'management','GERENCIA',62,63,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',64,65,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (46,'delivery','REPARTO',66,67,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',68,69,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL);
-INSERT INTO `department` VALUES (58,'CMP','CAMPOS',76,79,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,1,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (61,NULL,'VNH',84,87,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (58,'CMP','CAMPOS',78,81,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,1,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (61,NULL,'VNH',86,89,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',90,91,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',92,93,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (80,NULL,'EQUIPO J VALLES',37,38,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (89,NULL,'COORDINACION',94,95,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (90,NULL,'TRAILER',85,86,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (89,NULL,'COORDINACION',96,97,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (90,NULL,'TRAILER',87,88,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',39,40,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (94,NULL,'EQUIPO J BROCAL',41,42,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
@@ -1981,18 +1969,19 @@ INSERT INTO `department` VALUES (95,NULL,'EQUIPO C ZAMBRANO',43,44,4667,0,0,0,2,
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',45,46,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',47,48,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',49,50,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (125,NULL,'EQUIPO MIRIAM MAR',51,52,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL);
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',77,78,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',79,80,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',53,54,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',55,56,1731,72,0,0,2,0,43,'/1/43/','fra_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (134,NULL,'EQUIPO RODRI',57,58,6264,0,0,0,2,0,43,'/1/43/','rhr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',98,99,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',100,101,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
-INSERT INTO `department` VALUES (137,'sorter','SORTER',102,103,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',100,101,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',102,103,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (137,'sorter','SORTER',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
+INSERT INTO `department` VALUES (139,NULL,'EQUIPO MIRIAM MAR 2',59,60,3803,0,0,0,2,0,43,'/1/43/','mir2_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);
@@ -2287,8 +2276,8 @@ INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,
INSERT INTO `state` VALUES (38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (41,'Prep Parcial',6,1,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
-INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','changePrice');
-INSERT INTO `ticketUpdateAction` VALUES (3,'Convertir en maná','turnInMana');
+INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices');
+INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana');
INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,167.0);
@@ -2303,7 +2292,15 @@ INSERT INTO `workCenter` VALUES (8,'Silla-Agrario',26,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `workCenter` VALUES (9,'Algemesi',20,1354,60,'Fenollars, 2',523549,NULL);
INSERT INTO `workCenter` VALUES (10,'Rubi',88,NULL,84,'Av. de la Llana, 131',549722,NULL);
-INSERT INTO `workerBusinessAgreement` VALUES (1,'Flores y Plantas',2.5,1830,'2012-01-01',NULL);
+INSERT INTO `workerTimeControlError` VALUES (1,'IS_NOT_ALLOWED_FUTURE','No se permite fichar a futuro');
+INSERT INTO `workerTimeControlError` VALUES (2,'INACTIVE_BUSINESS','No hay un contrato en vigor');
+INSERT INTO `workerTimeControlError` VALUES (3,'IS_NOT_ALLOWED_WORK','No está permitido trabajar');
+INSERT INTO `workerTimeControlError` VALUES (4,'ODD_WORKERTIMECONTROL','Fichadas impares');
+INSERT INTO `workerTimeControlError` VALUES (5,'DAY_MAX_TIME','Superado el tiempo máximo entre entrada y salida');
+INSERT INTO `workerTimeControlError` VALUES (6,'BREAK_DAY','Descanso diario');
+INSERT INTO `workerTimeControlError` VALUES (7,'BREAK_WEEK','Descanso semanal');
+INSERT INTO `workerTimeControlError` VALUES (8,'WRONG_DIRECTION','Dirección incorrecta');
+INSERT INTO `workerTimeControlError` VALUES (9,'UNDEFINED_ERROR','Error sin definir');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql
index b8abe322e..290c8a2a3 100644
--- a/db/dump/.dump/privileges.sql
+++ b/db/dump/.dump/privileges.sql
@@ -676,7 +676,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','glsExpedition__','
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','postCode','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','pgcMaster','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBarcode','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemBarcode','alexm@%','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','host','alexm@%','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Facturas','guillermo@10.5.1.4','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticket','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@@ -701,11 +700,11 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInTax
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOut','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','invoiceOut','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceOutExpense','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','item','alexm@%','0000-00-00 00:00:00','Update','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Update');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutSerial','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutTax','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','item','alexm@%','0000-00-00 00:00:00','Insert','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemBarcode','alexm@%','0000-00-00 00:00:00','Insert,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemBarcode','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemBotanical','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBotanicalWithGenus','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemCategory','alexm@%','0000-00-00 00:00:00','Select','');
@@ -774,7 +773,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeSubscripti
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','noticeCategory','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeCategory','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwServiceWeekday','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','alexm@%','0000-00-00 00:00:00','Select,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwService','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppePlan','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','accountingConfig','alexm@%','0000-00-00 00:00:00','Select','');
@@ -911,8 +910,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','supplier','alexm@%'
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierAccount','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierExpense','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','supplierExpense','alexm@%','0000-00-00 00:00:00','Insert','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','ticketService','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketService','jgallego@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingServiceWeekday','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@@ -1152,6 +1150,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLastState','g
INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myAddress','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','tag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemTag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Tipos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','saleBuy','carlosap@10.5.1.6','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','orderTicket','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','negativeOrigin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','route','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemPackingType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@@ -1218,7 +1220,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingInvoi
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeCommission','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','warehouse','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','warehouse','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimBeginning','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','invoicing','vehiclePlateRegex','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessSchedule','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@@ -1337,6 +1339,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimState','juan@d
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update');
/*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
@@ -1475,6 +1478,67 @@ INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','edit
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','code','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','townFk','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','town','provinceFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','id','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','equivalent','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stems','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minPrice','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isToPrint','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','family','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','box','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','category','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','doPhoto','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','image','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','inkFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','intrastatFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasMinPrice','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','created','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','comment','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','typeFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','generic','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','producerFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','description','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','density','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','relevancy','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','expenseFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isActive','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','subName','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag5','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value5','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag6','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value6','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag7','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value7','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag8','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value8','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag9','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value9','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag10','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value10','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minimum','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','upToDown','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','supplyResponseFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasKgPrice','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFloramondo','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFragile','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','numberOfItemsPerCask','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','embalageCode','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','quality','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stemMultiplier','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','itemPackingTypeFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingOut','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','genericFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingShelve','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isLaid','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','lastUsed','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','weightByPiece','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','editorFk','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','size','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','longName','0000-00-00 00:00:00','Update');
+INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','name','0000-00-00 00:00:00','Update');
/*!40000 ALTER TABLE `columns_priv` ENABLE KEYS */;
/*!40000 ALTER TABLE `procs_priv` DISABLE KEYS */;
@@ -1539,7 +1603,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','buffer_settypeby
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','financialBoss','balance_create','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','employee','base_ticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','barcodeToItem','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_splititempackingtype','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_getCommission','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
@@ -1596,7 +1659,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan'
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','buyer','historico_absoluto','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','buyer','historico_multiple','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','logistic','f10_no_vincular','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','hrBoss','balance_create','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buyultimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofyear','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -1765,7 +1827,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_TIMESTAMP','F
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_getsaledate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_setState','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','invoicing','invoiceout_new','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizer','ticket_setState','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_replaceItem','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_next','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','workerjourney_replace','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','account','developerBoss','role_sync','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -1878,6 +1940,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemShelving_getinf
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_get','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','item_comparative','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_getBoxPickingList','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_isInDepartment','FUNCTION','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
/*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1898,7 +1961,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','agency','{\"access\": 0, \"max_que
INSERT IGNORE INTO `global_priv` VALUES ('','android','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','artificialBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','assetManager','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
-INSERT IGNORE INTO `global_priv` VALUES ('','buyer','{\"access\": 0, \"version_id\": 100707, \"is_role\": true}');
+INSERT IGNORE INTO `global_priv` VALUES ('','buyer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}');
INSERT IGNORE INTO `global_priv` VALUES ('','buyerBoss','{\"access\": 0, \"version_id\": 100707, \"is_role\": true}');
INSERT IGNORE INTO `global_priv` VALUES ('','claimManager','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','cooler','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
@@ -1910,7 +1973,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','deliveryAssistant','{\"access\":0,
INSERT IGNORE INTO `global_priv` VALUES ('','deliveryBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','developer','{\"access\": 5909905728, \"is_role\": true, \"version_id\": 100707}');
INSERT IGNORE INTO `global_priv` VALUES ('','developerBoss','{\"access\":33554432,\"version_id\":100707,\"is_role\":true}');
-INSERT IGNORE INTO `global_priv` VALUES ('','employee','{\"access\": 0, \"is_role\": true, \"version_id\": 100707}');
+INSERT IGNORE INTO `global_priv` VALUES ('','employee','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}');
INSERT IGNORE INTO `global_priv` VALUES ('','entryEditor','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','ext','{\"access\": 0, \"is_role\": true, \"version_id\": 100707}');
INSERT IGNORE INTO `global_priv` VALUES ('','financial','{\"access\": 0, \"version_id\": 100707, \"is_role\": true}');
@@ -1940,7 +2003,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','palletizer','{\"access\":0,\"versi
INSERT IGNORE INTO `global_priv` VALUES ('','palletizerBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','preservedBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','production','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
-INSERT IGNORE INTO `global_priv` VALUES ('','productionAssi','{\"access\": 0, \"version_id\": 100707, \"is_role\": true}');
+INSERT IGNORE INTO `global_priv` VALUES ('','productionAssi','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}');
INSERT IGNORE INTO `global_priv` VALUES ('','productionBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','productionPlus','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','root','{\"access\": 549755781119, \"version_id\": 100705, \"is_role\": true}');
diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql
new file mode 100644
index 000000000..f68b463d2
--- /dev/null
+++ b/db/dump/.dump/triggers.sql
@@ -0,0 +1,10780 @@
+-- MariaDB dump 10.19 Distrib 10.5.21-MariaDB, for debian-linux-gnu (x86_64)
+--
+-- Host: db.verdnatura.es Database: account
+-- ------------------------------------------------------
+-- Server version 10.11.6-MariaDB-1:10.11.6+maria~deb12-log
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Current Database: `account`
+--
+
+USE `account`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_beforeInsert`
+ BEFORE INSERT ON `account`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_afterInsert`
+ AFTER INSERT ON `account`
+ FOR EACH ROW
+BEGIN
+ INSERT IGNORE INTO userSync (`name`)
+ SELECT `name` FROM `user` WHERE id = NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_beforeUpdate`
+ BEFORE UPDATE ON `account`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_afterDelete`
+ AFTER DELETE ON `account`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO userLog
+ SET `action` = 'delete',
+ `changedModel` = 'Account',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ INSERT IGNORE INTO userSync (`name`)
+ SELECT `name` FROM `user` WHERE id = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_beforeInsert`
+ BEFORE INSERT ON `mailAlias`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_beforeUpdate`
+ BEFORE UPDATE ON `mailAlias`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_afterDelete`
+ AFTER DELETE ON `mailAlias`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO userLog
+ SET `action` = 'delete',
+ `changedModel` = 'MailAlias',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeInsert`
+ BEFORE INSERT ON `mailForward`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeUpdate`
+ BEFORE UPDATE ON `mailForward`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_afterDelete`
+ AFTER DELETE ON `mailForward`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO userLog
+ SET `action` = 'delete',
+ `changedModel` = 'MailForward',
+ `changedModelId` = OLD.account,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`role_beforeInsert`
+ BEFORE INSERT ON `role`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ CALL role_checkName(NEW.`name`);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`role_beforeUpdate`
+ BEFORE UPDATE ON `role`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ IF !(NEW.`name` <=> OLD.`name`) THEN
+ CALL role_checkName (NEW.`name`);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`role_afterDelete`
+ AFTER DELETE ON `role`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO roleLog
+ SET `action` = 'delete',
+ `changedModel` = 'Role',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_beforeInsert`
+ BEFORE INSERT ON `roleInherit`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_beforeUpdate`
+ BEFORE UPDATE ON `roleInherit`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_afterDelete`
+ AFTER DELETE ON `roleInherit`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO roleLog
+ SET `action` = 'delete',
+ `changedModel` = 'RoleInherit',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_beforeInsert`
+ BEFORE INSERT ON `user`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ CALL user_checkName(NEW.`name`);
+
+ IF NEW.nickname = '' THEN
+ SET NEW.nickname = NEW.`name`;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_afterInsert`
+ AFTER INSERT ON `user`
+ FOR EACH ROW
+BEGIN
+ CALL hedera.image_ref('user', NEW.image);
+
+ INSERT IGNORE INTO userSync SET `name` = NEW.`name`;
+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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_beforeUpdate`
+ BEFORE UPDATE ON `user`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF !(NEW.`name` <=> OLD.`name`) THEN
+ CALL user_checkName (NEW.`name`);
+ END IF;
+
+ IF !(NEW.`password` <=> OLD.`password`) THEN
+ SET NEW.lastPassChange = util.VN_NOW();
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_afterUpdate`
+ AFTER UPDATE ON `user`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.image <=> OLD.image) THEN
+ CALL hedera.image_unref('user', OLD.image);
+ CALL hedera.image_ref('user', NEW.image);
+ END IF;
+
+ INSERT IGNORE INTO userSync SET `name` = NEW.`name`;
+
+ IF !(OLD.`name` <=> NEW.`name`) THEN
+ INSERT IGNORE INTO userSync SET `name` = OLD.`name`;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_afterDelete`
+ AFTER DELETE ON `user`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO userLog
+ SET `action` = 'delete',
+ `changedModel` = 'User',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL hedera.image_unref('user', OLD.image);
+
+ INSERT IGNORE INTO userSync SET `name` = OLD.`name`;
+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 */ ;
+
+--
+-- Current Database: `bi`
+--
+
+USE `bi`;
+
+--
+-- Current Database: `bs`
+--
+
+USE `bs`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `bs`.`clientNewBorn_BEFORE_UPDATE`
+ BEFORE UPDATE ON `clientNewBorn`
+ FOR EACH ROW
+BEGIN
+ -- Si ha pasado un año o mas
+ IF TIMESTAMPDIFF(YEAR,NEW.lastShipped, OLD.lastShipped) THEN
+ SET NEW.firstShipped = NEW.lastShipped;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `bs`.`nightTaskBeforeInsert`
+ BEFORE INSERT ON `nightTask`
+ FOR EACH ROW
+BEGIN
+
+ IF NOT (NEW.`schema`REGEXP '^[0-9a-zA-Z_]+$') OR NOT (NEW.`procedure`REGEXP '^[0-9a-zA-Z_]+$') THEN
+
+ CALL util.throw('ONLY_ALPHANUMERICS_ALLOWED');
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `bs`.`nightTaskBeforeUpdate`
+ BEFORE UPDATE ON `nightTask`
+ FOR EACH ROW
+BEGIN
+
+ IF NOT (NEW.`schema`REGEXP '^[0-9a-zA-Z_]+$') OR NOT (NEW.`procedure`REGEXP '^[0-9a-zA-Z_]+$') THEN
+
+ CALL util.throw('ONLY_ALPHANUMERICS_ALLOWED');
+
+ 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 */ ;
+
+--
+-- Current Database: `cache`
+--
+
+USE `cache`;
+
+--
+-- Current Database: `dipole`
+--
+
+USE `dipole`;
+
+--
+-- Current Database: `edi`
+--
+
+USE `edi`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `edi`.`item_feature_bi`
+ BEFORE INSERT ON `item_feature`
+ FOR EACH ROW
+BEGIN
+ IF NEW.expiry_date = '0000-00-00' THEN
+ SET NEW.expiry_date = NULL;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `edi`.`putOrder_BEFORE_INSERT`
+ BEFORE INSERT ON `putOrder`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE nextID INT;
+
+ SELECT 1 + MAX(id) INTO nextID FROM putOrder ;
+
+ SET NEW.orderTradelineItemID = nextID;
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `edi`.`BEFORE UPDATE`
+ BEFORE UPDATE ON `putOrder`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE vError VARCHAR(100) DEFAULT 'Orderregel niet meer teruggevonden op basis van de orderps';
+ DECLARE vVmpIdError INT DEFAULT 7;
+ DECLARE vVmpFk INT;
+ DECLARE vSupplyResponseNumberOfUnits INT;
+
+ SELECT sr.vmpID INTO vVmpFk
+ FROM edi.supplyResponse sr
+ WHERE sr.id = NEW.supplyResponseID;
+
+ IF NEW.OrderStatus = 3
+ AND NOT (NEW.OrderStatus <=> OLD.OrderStatus)
+ AND NEW.error = vError
+ AND vVmpFk = vVmpIdError
+
+ THEN
+
+ SET NEW.OrderStatus = 2;
+
+ END IF;
+
+ -- Error de disponible menor de lo solicitado
+ IF NEW.error LIKE 'error2602%' THEN
+
+ SELECT NumberOfUnits INTO vSupplyResponseNumberOfUnits
+ FROM edi.supplyResponse sr
+ WHERE sr.ID = NEW.supplyResponseID;
+
+ SET NEW.error = CONCAT('(',vSupplyResponseNumberOfUnits,') ', NEW.error);
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `edi`.`putOrder_AFTER_UPDATE`
+ AFTER UPDATE ON `putOrder`
+ FOR EACH ROW
+BEGIN
+ DECLARE vSaleFk INT;
+ DECLARE vOrderStatusDenied INT DEFAULT 3;
+ DECLARE vOrderStatusOK INT DEFAULT 2;
+ DECLARE vIsEktSender BOOLEAN;
+
+ IF NEW.OrderStatus = vOrderStatusDenied AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) THEN
+
+ SELECT s.id INTO vSaleFk
+ FROM vn.sale s
+ JOIN vn.ticket t ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID
+ WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE()
+ AND i.supplyResponseFk = NEW.supplyResponseID
+ LIMIT 1;
+
+ UPDATE vn.sale s
+ JOIN vn.ticket t ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID
+ SET s.quantity = 0
+ WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE()
+ AND i.supplyResponseFk = NEW.supplyResponseID;
+
+ INSERT INTO vn.mail (sender, `subject`, body)
+ SELECT IF(u.id IS NOT NULL AND c.email IS NOT NULL,
+ c.email,
+ CONCAT(account.user_getNameFromId(c.salesPersonFk), '@verdnatura.es')
+ ),
+ 'Producto no disponible en Floramondo',
+ CONCAT('El artículo ', s.concept, ' del ticket ', t.id , ' ha sido cancelado por Floramondo. ',
+ ' Se ha actualizado la cantidad de ', OLD.quantity,' a 0. ',
+ IF (u.id IS NOT NULL AND c.email IS NOT NULL ,
+ CONCAT('https://shop.verdnatura.es/#!form=ecomerce%2Fticket&ticket=', t.id ),
+ CONCAT('https://salix.verdnatura.es/#!/ticket/', t.id ,'/summary')))
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.`client` c ON c.id = t.clientFk
+ LEFT JOIN account.user u ON u.id= c.salesPersonFk AND u.name IN ('ruben', 'ismaelalcolea')
+ WHERE s.id = vSaleFk;
+
+ END IF;
+
+
+ IF NEW.OrderStatus = vOrderStatusOK AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) THEN
+
+ SELECT v.isEktSender INTO vIsEktSender
+ FROM edi.VMPSettings v
+ JOIN edi.supplyResponse sr ON sr.vmpID = v.VMPID
+ WHERE sr.id = NEW.supplyResponseID;
+
+ IF NOT vIsEktSender THEN
+
+ CALL edi.ekt_add(NEW.id);
+
+ END IF;
+
+ IF NEW.barcode THEN
+
+ INSERT IGNORE INTO vn.itemBarcode(itemFk, code)
+ SELECT i.id, NEW.barcode
+ FROM vn.item i
+ WHERE i.supplyResponseFk = NEW.supplyResponseID;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `edi`.`supplyResponse_AFTER_UPDATE`
+ AFTER UPDATE ON `supplyResponse`
+ FOR EACH ROW
+BEGIN
+
+ UPDATE vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
+ SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
+ b.stickers = NEW.NumberOfUnits
+ WHERE i.supplyResponseFk = NEW.ID
+ AND am.name = 'LOGIFLORA'
+ AND e.isRaid
+ AND tr.landed >= util.VN_CURDATE();
+
+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 */ ;
+
+--
+-- Current Database: `hedera`
+--
+
+USE `hedera`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`link_afterInsert`
+ AFTER INSERT ON `link`
+ FOR EACH ROW
+BEGIN
+ CALL image_ref('link', NEW.image);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`link_afterUpdate`
+ AFTER UPDATE ON `link`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.image <=> OLD.image) THEN
+ CALL image_unref('link', OLD.image);
+ CALL image_ref('link', NEW.image);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`link_afterDelete`
+ AFTER DELETE ON `link`
+ FOR EACH ROW
+BEGIN
+ CALL image_unref('link', OLD.image);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`news_afterInsert`
+ AFTER INSERT ON `news`
+ FOR EACH ROW
+BEGIN
+ CALL image_ref('news', NEW.image);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`news_afterUpdate`
+ AFTER UPDATE ON `news`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.image <=> OLD.image) THEN
+ CALL image_unref('news', OLD.image);
+ CALL image_ref('news', NEW.image);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`news_afterDelete`
+ AFTER DELETE ON `news`
+ FOR EACH ROW
+BEGIN
+ CALL image_unref('news', OLD.image);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`order_afterInsert`
+ AFTER INSERT ON `order`
+ FOR EACH ROW
+BEGIN
+ IF NEW.address_id = 2850 THEN
+ -- Fallo que se insertan no se sabe como tickets en este cliente
+ CALL vn.mail_insert(
+ 'jgallego@verdnatura.es',
+ 'noreply@verdnatura.es',
+ 'Creada order al address 2850',
+ CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id)
+ );
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`order_afterUpdate`
+ AFTER UPDATE ON `order`
+ FOR EACH ROW
+BEGIN
+ CALL stock.log_add('order', NEW.id, OLD.id);
+
+ IF !(OLD.address_id <=> NEW.address_id)
+ OR !(OLD.company_id <=> NEW.company_id)
+ OR !(OLD.customer_id <=> NEW.customer_id) THEN
+ CALL order_requestRecalc(NEW.id);
+ END IF;
+
+ IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN
+ -- Fallo que se actualiza no se sabe como tickets en este cliente
+ CALL vn.mail_insert(
+ 'jgallego@verdnatura.es',
+ 'noreply@verdnatura.es',
+ 'Actualizada order al address 2850',
+ CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id)
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`order_beforeDelete`
+ BEFORE DELETE ON `order`
+ FOR EACH ROW
+BEGIN
+ DELETE FROM orderRow WHERE orderFk = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`orderRow_beforeInsert`
+ BEFORE INSERT ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsFirst BOOL;
+
+ SELECT (first_row_stamp IS NULL) INTO vIsFirst
+ FROM `order`
+ WHERE id = NEW.orderFk;
+
+ IF vIsFirst THEN
+ UPDATE `order` SET first_row_stamp = util.VN_NOW()
+ WHERE id = NEW.orderFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`orderRow_afterInsert`
+ AFTER INSERT ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ CALL stock.log_add('orderRow', NEW.id, NULL);
+ CALL order_requestRecalc(NEW.orderFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`orderRow_afterUpdate`
+ AFTER UPDATE ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ CALL stock.log_add('orderRow', NEW.id, OLD.id);
+ CALL order_requestRecalc(OLD.orderFk);
+ CALL order_requestRecalc(NEW.orderFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`orderRow_afterDelete`
+ AFTER DELETE ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ CALL stock.log_add('orderRow', NULL, OLD.id);
+ CALL order_requestRecalc(OLD.orderFk);
+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 */ ;
+
+--
+-- Current Database: `pbx`
+--
+
+USE `pbx`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`blacklist_beforeInsert`
+ BEFORE INSERT ON `blacklist`
+ FOR EACH ROW
+BEGIN
+ CALL phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`blacklist_berforeUpdate`
+ BEFORE UPDATE ON `blacklist`
+ FOR EACH ROW
+BEGIN
+ CALL phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`followme_beforeInsert`
+ BEFORE INSERT ON `followme`
+ FOR EACH ROW
+BEGIN
+ CALL pbx.phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`followme_beforeUpdate`
+ BEFORE UPDATE ON `followme`
+ FOR EACH ROW
+BEGIN
+ CALL pbx.phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`queue_beforeInsert`
+ BEFORE INSERT ON `queue`
+ FOR EACH ROW
+BEGIN
+ CALL queue_isValid(NEW.`name`);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`queue_beforeUpdate`
+ BEFORE UPDATE ON `queue`
+ FOR EACH ROW
+BEGIN
+ CALL queue_isValid(NEW.`name`);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`queuePhone_beforeInsert`
+ BEFORE INSERT ON `queuePhone`
+ FOR EACH ROW
+BEGIN
+ CALL phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`queuePhone_beforeUpdate`
+ BEFORE UPDATE ON `queuePhone`
+ FOR EACH ROW
+BEGIN
+ CALL phone_isValid(NEW.phone);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`sip_beforeInsert`
+ BEFORE INSERT ON `sip`
+ FOR EACH ROW
+BEGIN
+ CALL sip_isValid(NEW.extension);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`sip_afterInsert`
+ AFTER INSERT ON `sip`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO sipReg
+ SET userId = NEW.user_id;
+
+ INSERT IGNORE INTO `account`.userSync (`name`)
+ SELECT `name` FROM `account`.`user`
+ WHERE id = NEW.user_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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`sip_beforeUpdate`
+ BEFORE UPDATE ON `sip`
+ FOR EACH ROW
+BEGIN
+ CALL sip_isValid(NEW.extension);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `pbx`.`sip_afterUpdate`
+ AFTER UPDATE ON `sip`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.extension <=> NEW.extension)
+ OR !(OLD.user_id <=> NEW.user_id) THEN
+ INSERT IGNORE INTO `account`.userSync (`name`)
+ SELECT `name` FROM `account`.`user`
+ WHERE id = NEW.user_id;
+ 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 */ ;
+
+--
+-- Current Database: `psico`
+--
+
+USE `psico`;
+
+--
+-- Current Database: `rfid`
+--
+
+USE `rfid`;
+
+--
+-- Current Database: `sage`
+--
+
+USE `sage`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `sage`.`movConta_BEFORE_UPDATE`
+ BEFORE UPDATE ON `movConta`
+ FOR EACH ROW
+BEGIN
+ IF NEW.enlazadoSage = TRUE THEN
+ UPDATE vn.XDiario SET enlazadoSage = TRUE WHERE ASIEN = NEW.Asiento;
+ 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 */ ;
+
+--
+-- Current Database: `salix`
+--
+
+USE `salix`;
+
+--
+-- Current Database: `srt`
+--
+
+USE `srt`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`expedition_BU`
+ BEFORE UPDATE ON `expedition`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.updated = util.VN_NOW();
+
+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_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`moving_AI`
+ AFTER INSERT ON `moving`
+ FOR EACH ROW
+BEGIN
+
+ INSERT INTO srt.movingLog(movingFk, expeditionFk, bufferFromFk, bufferToFk, stateFk, isColliding, `action`)
+ VALUES(NEW.id, NEW.expeditionFk, NEW.bufferFromFk, NEW.bufferToFk, NEW.stateFk, NEW.isColliding, 'NEW2');
+
+ DELETE FROM srt.movingLast;
+
+ INSERT INTO srt.movingLast (id, expeditionFk, bufferFromFk, bufferToFk)
+ VALUES(NEW.id, NEW.expeditionFk, NEW.bufferFromFk, NEW.bufferToFk);
+
+ IF srt.buffer_isFull(NEW.bufferToFk) THEN
+
+ CALL srt.buffer_setStateType(NEW.bufferToFk, 'FULL',NULL);
+
+ 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 */ ;
+
+--
+-- Current Database: `stock`
+--
+
+USE `stock`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `stock`.`inbound_beforeInsert`
+ BEFORE INSERT ON `inbound`
+ FOR EACH ROW
+BEGIN
+ SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
+
+ CALL visible_log(
+ NEW.isPicked,
+ NEW.warehouseFk,
+ NEW.itemFk,
+ NEW.quantity
+ );
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `stock`.`inbound_afterDelete`
+ AFTER DELETE ON `inbound`
+ FOR EACH ROW
+BEGIN
+ UPDATE outbound o
+ JOIN inboundPick ou ON ou.outboundFk = o.id
+ SET o.lack = o.lack + ou.quantity,
+ o.isSync = FALSE
+ WHERE ou.inboundFk = OLD.id;
+
+ DELETE FROM inboundPick
+ WHERE inboundFk = OLD.id;
+
+ CALL visible_log(
+ OLD.isPicked,
+ OLD.warehouseFk,
+ OLD.itemFk,
+ -OLD.quantity
+ );
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `stock`.`outbound_beforeInsert`
+ BEFORE INSERT ON `outbound`
+ FOR EACH ROW
+BEGIN
+ SET NEW.lack = NEW.quantity;
+ SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
+
+ CALL visible_log(
+ NEW.isPicked,
+ NEW.warehouseFk,
+ NEW.itemFk,
+ -NEW.quantity
+ );
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `stock`.`outbound_afterDelete`
+ AFTER DELETE ON `outbound`
+ FOR EACH ROW
+BEGIN
+ UPDATE inbound i
+ JOIN inboundPick ou ON ou.inboundFk = i.id
+ SET i.available = i.available + ou.quantity,
+ i.isSync = FALSE
+ WHERE ou.outboundFk = OLD.id;
+
+ DELETE FROM inboundPick
+ WHERE outboundFk = OLD.id;
+
+ CALL visible_log(
+ OLD.isPicked,
+ OLD.warehouseFk,
+ OLD.itemFk,
+ OLD.quantity
+ );
+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 */ ;
+
+--
+-- Current Database: `tmp`
+--
+
+USE `tmp`;
+
+--
+-- Current Database: `util`
+--
+
+USE `util`;
+
+--
+-- Current Database: `vn`
+--
+
+USE `vn`;
+/*!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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeInsert`
+ BEFORE INSERT ON `XDiario`
+ FOR EACH ROW
+BEGIN
+ IF NEW.SUBCTA <=> '' THEN
+ SET NEW.SUBCTA = NULL;
+ END IF;
+ IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN
+ CALL util.throw('INVALID_STRING_LENGTH');
+ END IF;
+ IF NEW.CONTRA <=> '' THEN
+ SET NEW.CONTRA = NULL;
+ END IF;
+ IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN
+ CALL util.throw('INVALID_STRING_LENGTH');
+ END IF;
+ CALL XDiario_checkDate(NEW.FECHA);
+ CALL XDiario_checkDate(NEW.FECHA_EX);
+ CALL XDiario_checkDate(NEW.FECHA_OP);
+ CALL XDiario_checkDate(NEW.FECHA_RT);
+ CALL XDiario_checkDate(NEW.FECREGCON);
+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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeUpdate`
+ BEFORE UPDATE ON `XDiario`
+ FOR EACH ROW
+BEGIN
+ IF NOT NEW.SUBCTA <=> OLD.SUBCTA THEN
+ IF NEW.SUBCTA <=> '' THEN
+ SET NEW.SUBCTA = NULL;
+ END IF;
+ IF NEW.SUBCTA IS NOT NULL AND NOT LENGTH(NEW.SUBCTA) <=> 10 THEN
+ CALL util.throw('INVALID_STRING_LENGTH');
+ END IF;
+ END IF;
+ IF NOT NEW.CONTRA <=> OLD.CONTRA THEN
+ IF NEW.CONTRA <=> '' THEN
+ SET NEW.CONTRA = NULL;
+ END IF;
+ IF NEW.CONTRA IS NOT NULL AND NOT LENGTH(NEW.CONTRA) <=> 10 THEN
+ CALL util.throw('INVALID_STRING_LENGTH');
+ END IF;
+ END IF;
+ IF NOT NEW.FECHA <=> OLD.FECHA THEN
+ CALL XDiario_checkDate(NEW.FECHA);
+ END IF;
+ IF NOT NEW.FECHA_EX <=> OLD.FECHA_EX THEN
+ CALL XDiario_checkDate(NEW.FECHA_EX);
+ END IF;
+ IF NOT NEW.FECHA_OP <=> OLD.FECHA_OP THEN
+ CALL XDiario_checkDate(NEW.FECHA_OP);
+ END IF;
+ IF NOT NEW.FECHA_RT <=> OLD.FECHA_RT THEN
+ CALL XDiario_checkDate(NEW.FECHA_RT);
+ END IF;
+ IF NOT NEW.FECREGCON <=> OLD.FECREGCON THEN
+ CALL XDiario_checkDate(NEW.FECREGCON);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeInsert`
+ BEFORE INSERT ON `address`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsEqualizated BOOL;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF (NEW.phone <> '') THEN
+ CALL pbx.phone_isValid(NEW.phone);
+ END IF;
+
+ IF (NEW.mobile <> '') THEN
+ CALL pbx.phone_isValid(NEW.mobile);
+ END IF;
+
+ IF NEW.isEqualizated IS NULL THEN
+ SELECT isEqualizated
+ INTO vIsEqualizated
+ FROM client
+ WHERE id = NEW.clientFk;
+
+ SET NEW.isEqualizated = vIsEqualizated;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterInsert`
+ BEFORE INSERT ON `address`
+ FOR EACH ROW
+BEGIN
+ IF (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN
+ UPDATE client
+ SET hasToInvoiceByAddress = TRUE
+ WHERE id = NEW.clientFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeUpdate`
+ BEFORE UPDATE ON `address`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
+ CALL pbx.phone_isValid(NEW.phone);
+ END IF;
+
+ IF !(NEW.mobile <=> OLD.mobile) AND (NEW.mobile <> '')THEN
+ CALL pbx.phone_isValid(NEW.mobile);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterUpdate`
+ AFTER UPDATE ON `address`
+ FOR EACH ROW
+BEGIN
+ -- Recargos de equivalencia distintos implican facturacion por consignatario
+ IF NEW.isEqualizated != OLD.isEqualizated THEN
+ IF
+ (SELECT COUNT(*) FROM
+ (
+ SELECT DISTINCT (isEqualizated = FALSE) as Equ
+ FROM address
+ WHERE clientFk = NEW.clientFk
+ ) t1
+ ) > 1
+ THEN
+ UPDATE client
+ SET hasToInvoiceByAddress = TRUE
+ WHERE id = NEW.clientFk;
+ END IF;
+ END IF;
+ IF NEW.isDefaultAddress AND NEW.isActive = FALSE THEN
+ CALL util.throw ('Cannot desactivate the default address');
+ END IF;
+
+ IF NOT (NEW.isEqualizated <=> OLD.isEqualizated) THEN
+ INSERT IGNORE INTO ticketRecalc (ticketFk)
+ SELECT id FROM ticket t
+ WHERE t.addressFk = NEW.id
+ AND t.refFk IS NULL;
+ END IF;
+
+ IF (NEW.clientFk <> OLD.clientFk OR NEW.isActive <> OLD.isActive OR NOT (NEW.provinceFk <=> OLD.provinceFk))
+ AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN
+ UPDATE client
+ SET hasToInvoiceByAddress = TRUE
+ WHERE id = NEW.clientFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterDelete`
+ AFTER DELETE ON `address`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'Address',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`agency_afterInsert`
+ AFTER INSERT ON `agency`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO agencyMode(name,agencyFk) VALUES(NEW.name,NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_BI`
+ BEFORE INSERT ON `autonomy`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.geoFk = zoneGeo_new('autonomy', NEW.`name`, (SELECT geoFk FROM country WHERE id = NEW.countryFk));
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_BU`
+ BEFORE UPDATE ON `autonomy`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.countryFk <=> NEW.countryFk) THEN
+ CALL zoneGeo_setParent(NEW.geoFk,
+ (SELECT geoFk FROM country WHERE id = NEW.countryFk));
+ END IF;
+
+ IF !(OLD.`name` <=> NEW.`name`) THEN
+ UPDATE zoneGeo SET `name` = NEW.`name`
+ WHERE id = NEW.geoFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_AD`
+ AFTER DELETE ON `autonomy`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_delete(OLD.geoFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`awb_bi`
+ BEFORE INSERT ON `awb`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.year= year(util.VN_CURDATE());
+
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeInsert`
+ BEFORE INSERT ON `bankEntity`
+ FOR EACH ROW
+BEGIN
+ CALL bankEntity_checkBic(NEW.bic);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeUpdate`
+ BEFORE UPDATE ON `bankEntity`
+ FOR EACH ROW
+BEGIN
+ IF NOT (NEW.bic <=> OLD.bic) THEN
+ CALL bankEntity_checkBic(NEW.bic);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`budgetNotes_BeforeInsert`
+ BEFORE INSERT ON `budgetNotes`
+ FOR EACH ROW
+BEGIN
+
+ IF ISNULL(NEW.userFk) THEN
+
+ SET NEW.userFk = account.myUser_getId();
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeInsert`
+ BEFORE INSERT ON `business`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.ended IS NULL THEN
+ SET NEW.payedHolidays = 0;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterInsert`
+ AFTER INSERT ON `business`
+ FOR EACH ROW
+BEGIN
+ CALL worker_updateBusiness(NEW.workerFk);
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeUpdate`
+ BEFORE UPDATE ON `business`
+ FOR EACH ROW
+BEGIN
+ DECLARE isOverlapping BOOL;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.ended IS NULL THEN
+ SET NEW.payedHolidays = 0;
+ END IF;
+
+ IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN
+
+ SELECT COUNT(*) > 0 INTO isOverlapping
+ FROM business b
+ WHERE (util.hasDateOverlapped(
+ NEW.started,
+ IFNULL(NEW.ended, b.started),
+ b.started,
+ IFNULL(b.ended, NEW.started))
+ OR (NEW.ended <=> NULL AND b.ended <=> NULL))
+ AND b.id <> OLD.id
+ AND workerFk = OLD.workerFk;
+
+ IF isOverlapping THEN
+ CALL util.throw ('IS_OVERLAPPING');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterUpdate`
+ AFTER UPDATE ON `business`
+ FOR EACH ROW
+BEGIN
+ CALL worker_updateBusiness(NEW.workerFk);
+
+ IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
+ CALL worker_updateBusiness(OLD.workerFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterDelete`
+ AFTER DELETE ON `business`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO workerLog
+ SET `action` = 'delete',
+ `changedModel` = 'Business',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL worker_updateBusiness(OLD.workerFk);
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeInsert`
+ BEFORE INSERT ON `buy`
+ FOR EACH ROW
+trig: BEGIN
+ DECLARE vWarehouse INT;
+ DECLARE vLanding DATE;
+ DECLARE vGrouping INT;
+ DECLARE vGroupingMode TINYINT;
+ DECLARE vGenericFk INT;
+ DECLARE vGenericInDate BOOL;
+
+ IF @isModeInventory THEN
+ LEAVE trig;
+ END IF;
+
+ IF NEW.printedStickers <> 0 THEN
+ CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
+ END IF;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ CALL buy_checkGrouping(NEW.`grouping`);
+
+ SELECT t.warehouseInFk, t.landed
+ INTO vWarehouse, vLanding
+ FROM entry e
+ JOIN travel t ON t.id = e.travelFk
+ WHERE e.id = NEW.entryFk;
+
+ SELECT b.`grouping`, b.groupingMode
+ INTO vGrouping, vGroupingMode
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ WHERE t.landed <= vLanding
+ AND b.itemFk = NEW.itemFk
+ AND !b.isIgnored
+ ORDER BY t.warehouseInFk = vWarehouse DESC,
+ t.landed DESC,
+ b.id DESC
+ LIMIT 1;
+
+ IF NEW.`grouping` IS NULL THEN
+ SET NEW.`grouping` = vGrouping;
+ END IF;
+
+ IF NEW.groupingMode IS NULL THEN
+ SET NEW.groupingMode = vGroupingMode;
+ END IF;
+
+ -- Generics
+ SELECT i.genericFk INTO vGenericFk
+ FROM item i
+ WHERE i.id = NEW.itemFk;
+
+ IF vGenericFk THEN
+ SELECT COUNT(*) INTO vGenericInDate
+ FROM genericAllocation ga
+ JOIN entry e ON e.id = NEW.entryFk
+ JOIN travel tr on tr.id = e.travelFk
+ WHERE ga.itemFk = vGenericFk
+ AND tr.landed BETWEEN ga.startDated AND ga.endDated;
+
+ IF vGenericInDate THEN
+ SET NEW.itemOriginalFk = NEW.itemFk;
+ SET NEW.itemFk = vGenericFk;
+ END IF;
+ END IF;
+
+ IF NEW.quantity < 0 THEN
+ SET NEW.isIgnored = TRUE;
+ END IF;
+
+ IF NEW.weight AND NEW.packing
+ AND (SELECT weightByPiece FROM item WHERE id = NEW.itemFk) IS NULL THEN
+
+ UPDATE item
+ SET weightByPiece = (NEW.weight * 1000) / NEW.packing
+ WHERE id = NEW.itemFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterInsert`
+ AFTER INSERT ON `buy`
+ FOR EACH ROW
+trig: BEGIN
+ IF @isModeInventory OR @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ CALL stock.log_add('buy', NEW.id, NULL);
+
+ CALL buy_afterUpsert(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeUpdate`
+ BEFORE UPDATE ON `buy`
+ FOR EACH ROW
+trig:BEGIN
+ DECLARE vGenericFk INT;
+ DECLARE vGenericInDate BOOL;
+ DECLARE vIsInventory BOOL;
+ DECLARE vDefaultEntry INT;
+
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ SELECT defaultEntry INTO vDefaultEntry
+ FROM entryConfig;
+
+ IF (NOT OLD.entryFk <=> NEW.entryFk OR NOT OLD.printedStickers <=> NEW.printedStickers)
+ AND NEW.printedStickers <> 0 THEN
+ SELECT defaultEntry INTO vDefaultEntry
+ FROM entryConfig;
+
+ IF NEW.entryFk = vDefaultEntry THEN
+ CALL util.throw('There can be no lines with printed labels on the default entry');
+ END IF;
+ END IF;
+
+ IF NOT NEW.`grouping` <=> OLD.`grouping` THEN
+ CALL buy_checkGrouping(NEW.`grouping`);
+ END IF;
+
+ -- Generics
+ SELECT i.genericFk INTO vGenericFk
+ FROM item i
+ WHERE i.id = NEW.itemFk;
+
+ IF vGenericFk THEN
+ SELECT COUNT(*) INTO vGenericInDate
+ FROM genericAllocation ga
+ JOIN entry e ON e.id = NEW.entryFk
+ JOIN travel tr on tr.id = e.travelFk
+ WHERE ga.itemFk = vGenericFk
+ AND tr.landed BETWEEN ga.startDated AND ga.endDated;
+ IF vGenericInDate THEN
+ SET NEW.itemOriginalFk = NEW.itemFk;
+ SET NEW.itemFk = vGenericFk;
+ END IF;
+ END IF;
+
+ SELECT COUNT(*) INTO vIsInventory
+ FROM entry e
+ JOIN supplier s ON s.id = e.supplierFk
+ JOIN entryConfig ec ON ec.inventorySupplierFk = e.supplierFk
+ WHERE e.id = NEW.entryFk;
+
+ IF vIsInventory THEN
+ IF NOT NEW.printedStickers <=> OLD.printedStickers THEN
+ CALL util.throw("Stickers cannot be modified if they are inventory");
+ END IF;
+ END IF;
+
+ IF NEW.quantity < 0 THEN
+ SET NEW.isIgnored = TRUE;
+ 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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterUpdate`
+ AFTER UPDATE ON `buy`
+ FOR EACH ROW
+trig: BEGIN
+ DECLARE vLanded DATE;
+ DECLARE vBuyerFk INT;
+ DECLARE vIsBuyerToBeEmailed BOOL;
+ DECLARE vItemName VARCHAR(50);
+
+ IF @isModeInventory OR @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ IF !(NEW.id <=> OLD.id)
+ OR !(NEW.entryFk <=> OLD.entryFk)
+ OR !(NEW.itemFk <=> OLD.itemFk)
+ OR !(NEW.quantity <=> OLD.quantity)
+ OR !(NEW.created <=> OLD.created) THEN
+ CALL stock.log_add('buy', NEW.id, OLD.id);
+ END IF;
+
+ CALL buy_afterUpsert(NEW.id);
+
+ SELECT w.isBuyerToBeEmailed, t.landed
+ INTO vIsBuyerToBeEmailed, vLanded
+ FROM entry e
+ JOIN travel t ON t.id = e.travelFk
+ JOIN warehouse w ON w.id = t.warehouseInFk
+ WHERE e.id = NEW.entryFk;
+
+ SELECT it.workerFk, i.longName
+ INTO vBuyerFk, vItemName
+ FROM itemCategory k
+ JOIN itemType it ON it.categoryFk = k.id
+ JOIN item i ON i.typeFk = it.id
+ WHERE i.id = OLD.itemFk;
+
+ IF vIsBuyerToBeEmailed AND
+ vBuyerFk != account.myUser_getId() AND
+ vLanded = util.VN_CURDATE() THEN
+ IF !(NEW.itemFk <=> OLD.itemFk) OR
+ !(NEW.quantity <=> OLD.quantity) OR
+ !(NEW.packing <=> OLD.packing) OR
+ !(NEW.grouping <=> OLD.grouping) OR
+ !(NEW.packagingFk <=> OLD.packagingFk) OR
+ !(NEW.weight <=> OLD.weight) THEN
+ CALL vn.mail_insert(
+ CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'),
+ CONCAT(account.myUser_getName(),'@verdnatura.es'),
+ CONCAT('E ', NEW.entryFk ,' Se ha modificado item ', NEW.itemFk, ' ', vItemName),
+ 'Este email se ha generado automáticamente'
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete`
+ BEFORE DELETE ON buy
+ FOR EACH ROW
+BEGIN
+ IF OLD.printedStickers <> 0 THEN
+ CALL util.throw("it is not possible to delete buys with printed labels ");
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterDelete`
+ AFTER DELETE ON `buy`
+ FOR EACH ROW
+trig: BEGIN
+ DECLARE vValues VARCHAR(255);
+
+ IF @isModeInventory OR @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ CALL stock.log_add('buy', NULL, OLD.id);
+
+ INSERT INTO entryLog
+ SET `action` = 'delete',
+ `changedModel` = 'Buy',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeInsert`
+ BEFORE INSERT ON `claim`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeUpdate`
+ BEFORE UPDATE ON `claim`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_afterDelete`
+ AFTER DELETE ON `claim`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'Claim',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeInsert`
+ BEFORE INSERT ON `claimBeginning`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeUpdate`
+ BEFORE UPDATE ON `claimBeginning`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_afterDelete`
+ AFTER DELETE ON `claimBeginning`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimBeginning',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeInsert`
+ BEFORE INSERT ON `claimDevelopment`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeUpdate`
+ BEFORE UPDATE ON `claimDevelopment`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_afterDelete`
+ AFTER DELETE ON `claimDevelopment`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimDevelopment',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeInsert`
+ BEFORE INSERT ON `claimDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeUpdate`
+ BEFORE UPDATE ON `claimDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_afterDelete`
+ AFTER DELETE ON `claimDms`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimDms',
+ `changedModelId` = OLD.claimFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeInsert`
+ BEFORE INSERT ON `claimEnd`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeUpdate`
+ BEFORE UPDATE ON `claimEnd`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_afterDelete`
+ AFTER DELETE ON `claimEnd`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimEnd',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeInsert`
+ BEFORE INSERT ON `claimObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeUpdate`
+ BEFORE UPDATE ON `claimObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_afterDelete`
+ AFTER DELETE ON `claimObservation`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimObservation',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeInsert`
+ BEFORE INSERT ON `claimState`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeUpdate`
+ BEFORE UPDATE ON `claimState`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_afterDelete`
+ AFTER DELETE ON `claimState`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO claimLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClaimState',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeInsert`
+ BEFORE INSERT ON `client`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF (NEW.phone <> '') THEN
+ CALL pbx.phone_isValid(NEW.phone);
+ END IF;
+
+ IF (NEW.mobile <> '') THEN
+ CALL pbx.phone_isValid(NEW.mobile);
+ END IF;
+
+ SET NEW.accountingAccount = 4300000000 + NEW.id;
+
+ SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
+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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_AfterInsert`
+ AFTER INSERT ON `client`
+ FOR EACH ROW
+BEGIN
+ IF NEW.credit IS NOT NULL AND NEW.credit THEN
+ INSERT INTO clientCredit
+ SET clientFk = NEW.id,
+ workerFk = NEW.editorFk,
+ amount = NEW.credit;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeUpdate`
+ BEFORE UPDATE ON `client`
+ FOR EACH ROW
+BEGIN
+ DECLARE vText VARCHAR(255) DEFAULT NULL;
+ DECLARE vPayMethodFk INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NOT(NEW.credit <=> OLD.credit) THEN
+ INSERT INTO clientCredit
+ SET clientFk = NEW.id,
+ amount = NEW.credit,
+ workerFk = NEW.editorFk;
+ END IF;
+ -- Comprueba que el formato de los teléfonos es válido
+
+ IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
+ CALL pbx.phone_isValid(NEW.phone);
+ END IF;
+
+ IF !(NEW.mobile <=> OLD.mobile) AND (NEW.mobile <> '')THEN
+ CALL pbx.phone_isValid(NEW.mobile);
+ END IF;
+
+ SELECT id INTO vPayMethodFk
+ FROM vn.payMethod
+ WHERE code = 'bankDraft';
+
+ IF NEW.payMethodFk = vPayMethodFk AND NEW.dueDay = 0 THEN
+ SET NEW.dueDay = 5;
+ END IF;
+
+ -- Avisar al comercial si ha llegado la documentación sepa/core
+
+ IF NEW.hasSepaVnl AND !OLD.hasSepaVnl THEN
+ SET vText = 'Sepa de VNL';
+ END IF;
+
+ IF NEW.hasCoreVnl AND !OLD.hasCoreVnl THEN
+ SET vText = 'Core de VNL';
+ END IF;
+
+ IF vText IS NOT NULL
+ THEN
+ INSERT INTO mail(receiver, replyTo, `subject`, body)
+ SELECT
+ CONCAT(IF(ac.id,u.name, 'jgallego'), '@verdnatura.es'),
+ 'administracion@verdnatura.es',
+ CONCAT('Cliente ', NEW.id),
+ CONCAT('Recibida la documentación: ', vText)
+ FROM worker w
+ LEFT JOIN account.user u ON w.id = u.id AND u.active
+ LEFT JOIN account.account ac ON ac.id = u.id
+ WHERE w.id = NEW.salesPersonFk;
+ END IF;
+
+ IF NEW.salespersonFk IS NULL AND OLD.salespersonFk IS NOT NULL THEN
+ IF (SELECT COUNT(clientFk)
+ FROM clientProtected
+ WHERE clientFk = NEW.id
+ ) > 0 THEN
+ CALL util.throw("HAS_CLIENT_PROTECTED");
+ END IF;
+ END IF;
+
+ IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN
+ SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk);
+ END IF;
+
+ IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
+ SET NEW.isTaxDataChecked = 0;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterUpdate`
+ AFTER UPDATE ON `client`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
+ UPDATE `address` SET isDefaultAddress = 0
+ WHERE clientFk = NEW.id;
+
+ UPDATE `address` SET isDefaultAddress = 1
+ WHERE id = NEW.defaultAddressFk;
+ END IF;
+
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN
+ INSERT IGNORE INTO ticketRecalc (ticketFk)
+ SELECT id FROM ticket t
+ WHERE t.clientFk = NEW.id
+ AND t.refFk IS NULL;
+ END IF;
+
+ IF NOT NEW.isActive THEN
+ UPDATE account.`user`
+ SET active = FALSE
+ WHERE id = NEW.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterDelete`
+ AFTER DELETE ON `client`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'Client',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_beforeInsert`
+ BEFORE INSERT ON `clientContact`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_afterDelete`
+ AFTER DELETE ON `clientContact`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClientContact',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER clientCredit_AfterInsert
+AFTER INSERT
+ON clientCredit FOR EACH ROW
+BEGIN
+
+ DECLARE vSender VARCHAR(50);
+
+ SELECT u.name INTO vSender
+ FROM account.`user` u
+ WHERE u.id = NEW.workerFk;
+
+ IF vSender IN ('juanvi','pepe') THEN
+
+ CALL `vn`.`mail_insert`('pako@verdnatura.es',
+ NULL,
+ CONCAT('ClientCredit ',vSender, ' ', NEW.clientFk, ' ' , NEW.amount, ' €'),
+ CONCAT('ClientCredit ',vSender, ' ', NEW.clientFk, ' ' , NEW.amount, ' €'));
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeInsert`
+ BEFORE INSERT ON `clientDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeUpdate`
+ BEFORE UPDATE ON `clientDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_afterDelete`
+ AFTER DELETE ON `clientDms`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClientDms',
+ `changedModelId` = OLD.dmsFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeInsert`
+ BEFORE INSERT ON `clientObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeUpdate`
+ BEFORE UPDATE ON `clientObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_afterDelete`
+ AFTER DELETE ON `clientObservation`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClientObservation',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeInsert`
+ BEFORE INSERT ON `clientSample`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeUpdate`
+ BEFORE UPDATE ON `clientSample`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_afterDelete`
+ AFTER DELETE ON `clientSample`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'ClientSample',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`cmr_beforeDelete`
+ BEFORE DELETE ON `cmr`
+ FOR EACH ROW
+BEGIN
+ IF NOT (OLD.companyFk <=> NULL AND OLD.addressFromFk <=> NULL AND OLD.packagesList <=> NULL) THEN
+ CALL util.throw("Can not delete cmr, fields required not empty");
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collection_BEFORE_UPDATE`
+ BEFORE UPDATE ON `collection`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE vStateFk INT;
+ DECLARE vTotalLines INT;
+ DECLARE vPickedLines INT;
+
+ IF NEW.saleTotalCount <= NEW.salePickedCount
+ AND (NEW.saleTotalCount != OLD.saleTotalCount
+ OR NEW.salePickedCount != OLD.salePickedCount)
+ THEN
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE code = 'PREPARED';
+
+ SET NEW.stateFk = vStateFk;
+
+ END IF;
+
+ IF NEW.saleTotalCount > NEW.salePickedCount
+ AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE code = 'ON_PREPARATION';
+
+ SET NEW.stateFk = vStateFk;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER vn.collectionColors_beforeInsert
+BEFORE INSERT
+ON collectionColors FOR EACH ROW
+BEGIN
+ CALL util.checkHex(NEW.rgb);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionColors_beforeUpdate`
+ BEFORE UPDATE ON `collectionColors`
+ FOR EACH ROW
+BEGIN
+ CALL util.checkHex(NEW.rgb);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterInsert`
+ AFTER INSERT ON `collectionVolumetry`
+ FOR EACH ROW
+BEGIN
+ DECLARE vJSON JSON DEFAULT JSON_OBJECT();
+ DECLARE vUserFk INT DEFAULT account.myUser_getId();
+
+ SET vJSON = JSON_MERGE(JSON_OBJECT('id', NEW.id), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('level', NEW.level), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('lines', NEW.lines), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('liters', NEW.liters), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('height', NEW.height), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', NEW.itemPackingTypeFk), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', NEW.trainFk), vJSON);
+
+ SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'insert'), vJSON);
+
+ SET vJSON = util.notification_send(
+ 'modified-collection-volumetry',
+ JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')),
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterUpdate`
+ AFTER UPDATE ON `collectionVolumetry`
+ FOR EACH ROW
+BEGIN
+ DECLARE vJSON JSON DEFAULT JSON_OBJECT();
+ DECLARE vUserFk INT DEFAULT account.myUser_getId();
+
+ IF NOT (NEW.id <=> OLD.id) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('id', NEW.id), vJSON);
+ END IF;
+
+ IF NOT (NEW.`level` <=> OLD.`level`) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('level', NEW.`level`), vJSON);
+ END IF;
+
+ IF NOT (NEW.`lines` <=> OLD.`lines`) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('lines', NEW.`lines`), vJSON);
+ END IF;
+
+ IF NOT (NEW.liters <=> OLD.liters) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('liters', NEW.liters), vJSON);
+ END IF;
+
+ IF NOT (NEW.height <=> OLD.height) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('height', NEW.height), vJSON);
+ END IF;
+
+ IF NOT (NEW.itemPackingTypeFk <=> OLD.itemPackingTypeFk) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', NEW.itemPackingTypeFk), vJSON);
+ END IF;
+
+ IF NOT (NEW.trainFk <=> OLD.trainFk) THEN
+ SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', NEW.trainFk), vJSON);
+ END IF;
+
+ SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'update'), vJSON);
+
+ SET vJSON = util.notification_send(
+ 'modified-collection-volumetry',
+ JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')),
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterDelete`
+ AFTER DELETE ON `collectionVolumetry`
+ FOR EACH ROW
+BEGIN
+ DECLARE vJSON JSON DEFAULT JSON_OBJECT();
+ DECLARE vUserFk INT DEFAULT account.myUser_getId();
+
+ SET vJSON = JSON_MERGE(JSON_OBJECT('id', OLD.id), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('level', OLD.level), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('lines', OLD.lines), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('liters', OLD.liters), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('height', OLD.height), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', OLD.itemPackingTypeFk), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', OLD.trainFk), vJSON);
+
+ SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON);
+ SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'delete'), vJSON);
+
+ SET vJSON = util.notification_send(
+ 'modified-collection-volumetry',
+ JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')),
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeInsert`
+ BEFORE INSERT ON `country`
+ FOR EACH ROW
+BEGIN
+ SET NEW.geoFk = zoneGeo_new('country', NEW.country, NULL);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_AFTER_INSERT`
+ AFTER INSERT ON `country`
+ FOR EACH ROW
+BEGIN
+ UPDATE sage.Naciones
+ SET countryFk = NEW.id
+ WHERE Nacion = NEW.country;
+
+ IF ROW_COUNT() = 0 THEN
+ CALL mail_insert(
+ 'cau@verdnatura.es',
+ NULL,
+ 'Actualizar tabla sage.Naciones',
+ CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id)
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeUpdate`
+ BEFORE UPDATE ON `country`
+ FOR EACH ROW
+BEGIN
+ -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
+ -- CALL zoneGeo_throwNotEditable;
+ -- 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterUpdate`
+ AFTER UPDATE ON `country`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.country <=> NEW.country) THEN
+ UPDATE zoneGeo SET `name` = NEW.country
+ WHERE id = NEW.geoFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterDelete`
+ AFTER DELETE ON `country`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_delete(OLD.geoFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditClassification_beforeUpdate`
+ BEFORE UPDATE ON `creditClassification`
+ FOR EACH ROW
+BEGIN
+ IF NEW.client <> OLD.client THEN
+ CALL util.throw('NOT_ALLOWED_CHANGE_CLIENT');
+ END IF;
+ IF NEW.dateEnd IS NOT NULL AND OLD.dateEnd IS NULL THEN
+ UPDATE `client` c
+ SET creditInsurance = NULL WHERE c.id = NEW.client;
+ 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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditInsurance_beforeInsert`
+ BEFORE INSERT ON `creditInsurance`
+ FOR EACH ROW
+BEGIN
+ IF NEW.creditClassificationFk THEN
+ SET NEW.creditClassification = NEW.creditClassificationFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditInsurance_afterInsert`
+ AFTER INSERT ON `creditInsurance`
+ FOR EACH ROW
+BEGIN
+ UPDATE `client` c
+ JOIN vn.creditClassification cc ON cc.client = c.id
+ SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification;
+
+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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeInsert`
+ BEFORE INSERT ON `delivery`
+ FOR EACH ROW
+BEGIN
+
+ IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
+ THEN
+ UPDATE address
+ SET longitude = NEW.longitude,
+ latitude = NEW.latitude
+ WHERE id IN (
+ SELECT addressFK
+ FROM ticket
+ WHERE id = NEW.ticketFk
+ );
+ 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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeUpdate`
+ BEFORE UPDATE ON `delivery`
+ FOR EACH ROW
+BEGIN
+
+IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
+ THEN
+ UPDATE address
+ SET longitude = NEW.longitude,
+ latitude = NEW.latitude
+ WHERE id IN (
+ SELECT addressFK
+ FROM ticket
+ WHERE id = NEW.ticketFk
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeInsert`
+ BEFORE INSERT ON `department`
+ FOR EACH ROW
+BEGIN
+ UPDATE vn.department_recalc SET isChanged = 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterUpdate`
+ AFTER UPDATE ON `department`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.parentFk <=> NEW.parentFk) THEN
+ UPDATE vn.department_recalc SET isChanged = TRUE;
+ END IF;
+
+ IF !(OLD.twoFactor <=> NEW.twoFactor) THEN
+ UPDATE account.user u
+ JOIN vn.workerDepartment wd ON wd.workerFk = u.id
+ SET u.twoFactor = NEW.twoFactor
+ WHERE wd.departmentFk = NEW.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeDelete`
+ BEFORE DELETE ON `department`
+ FOR EACH ROW
+BEGIN
+
+ UPDATE vn.business b
+ JOIN vn.department d ON d.id = b.departmentFk
+ SET b.departmentFk = d.parentFk
+ WHERE b.departmentFk = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterDelete`
+ AFTER DELETE ON `department`
+ FOR EACH ROW
+BEGIN
+
+ UPDATE vn.department_recalc SET isChanged = TRUE;
+
+ UPDATE vn.business b
+ JOIN vn.department d ON d.id = b.departmentFk
+ SET b.departmentFk = d.parentFk
+ WHERE b.departmentFk = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeInsert`
+ BEFORE INSERT ON `deviceProduction`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeUpdate`
+ BEFORE UPDATE ON `deviceProduction`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_afterDelete`
+ AFTER DELETE ON `deviceProduction`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO deviceProductionLog
+ SET `action` = 'delete',
+ `changedModel` = 'DeviceProduction',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionConfig_afterUpdate`
+ AFTER UPDATE ON `deviceProductionConfig`
+ FOR EACH ROW
+BEGIN
+ IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN
+ SET @username := (SELECT account.myUser_getName());
+ INSERT INTO vn.mail (receiver, subject, body)
+ VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app',
+ CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones'));
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeInsert`
+ BEFORE INSERT ON `deviceProductionModels`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeUpdate`
+ BEFORE UPDATE ON `deviceProductionModels`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeInsert`
+ BEFORE INSERT ON `deviceProductionState`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeUpdate`
+ BEFORE UPDATE ON `deviceProductionState`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeInsert`
+ BEFORE INSERT ON `deviceProductionUser`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate`
+ BEFORE UPDATE ON `deviceProductionUser`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterDelete`
+ AFTER DELETE ON `deviceProductionUser`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO deviceProductionLog
+ SET `action` = 'delete',
+ `changedModel` = 'DeviceProductionUser',
+ `changedModelId` = OLD.deviceProductionFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeInsert`
+ BEFORE INSERT ON `dms`
+ FOR EACH ROW
+BEGIN
+ DECLARE vHardCopyNumber INT;
+ DECLARE vDmsTypeCode INT;
+
+ IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN
+ CALL util.throw('this warehouse has not dms');
+ END IF;
+
+ IF NEW.hasFile THEN
+ SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber
+ FROM dms
+ WHERE warehouseFk = NEW.warehouseFk;
+
+ SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1);
+ END IF;
+
+ SELECT code INTO vDmsTypeCode
+ FROM dmsType WHERE NEW.dmsTypeFk = id;
+ IF (vDmsTypeCode ='ticket') THEN
+ UPDATE ticket SET isSigned = 1 WHERE id = NEW.reference;
+ 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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeUpdate`
+ BEFORE UPDATE ON `dms`
+ FOR EACH ROW
+BEGIN
+ DECLARE vHardCopyNumber INT;
+
+ IF (NEW.hasFile <> 0) AND (OLD.hasFile = 0) AND (NEW.hardCopyNumber IS NULL)
+ OR
+ (NEW.hardCopyNumber = OLD.hardCopyNumber AND OLD.warehouseFk <> NEW.warehouseFk) THEN
+
+ IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN
+ SET NEW.warehouseFk = (SELECT id FROM warehouse WHERE name = 'Algemesi');
+ END IF;
+
+ SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber
+ FROM dms
+ WHERE warehouseFk = NEW.warehouseFk;
+
+ SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1);
+ END IF;
+
+ IF ((NEW.hardCopyNumber = 0) OR NEW.hardCopyNumber IS NULL) AND (OLD.hardCopyNumber <> 0) THEN
+
+ SET NEW.hasFile = 0;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeDelete`
+ BEFORE DELETE ON `dms`
+ FOR EACH ROW
+BEGIN
+ DECLARE vCanNotBeDeleted INT;
+ SELECT COUNT(*) INTO vCanNotBeDeleted
+ FROM dmsType dt
+ WHERE NOT (code <=> 'trash')
+ AND dt.id = OLD.dmsTypeFk;
+
+ IF vCanNotBeDeleted THEN
+ CALL util.throw('A dms can not be deleted');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_BEFORE_INSERT`
+ BEFORE INSERT ON `duaTax`
+ FOR EACH ROW
+BEGIN
+ SET NEW.rate = duaTax_getRate(NEW.duaFk, NEW.taxClassFk);
+ SET NEW.tax = NEW.base * NEW.rate / 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_BEFORE_UPDATE`
+ BEFORE UPDATE ON `duaTax`
+ FOR EACH ROW
+BEGIN
+ SET NEW.rate = duaTax_getRate(NEW.duaFk, NEW.taxClassFk);
+ SET NEW.tax = NEW.base * NEW.rate / 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER ektEntryAssign_afterInsert
+AFTER INSERT
+ON ektEntryAssign FOR EACH ROW
+ UPDATE entry SET reference = NEW.`ref` WHERE id = NEW.entryFk */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER vn.ektEntryAssign_afterUpdate
+ AFTER UPDATE ON ektEntryAssign
+ FOR EACH ROW
+BEGIN
+ IF NOT(NEW.`ref` <=> OLD.`ref`) OR NOT(NEW.`entryFk` <=> OLD.`entryFk`) THEN
+ UPDATE entry SET reference = NEW.`ref` WHERE id = NEW.entryFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeInsert`
+ BEFORE INSERT ON `entry`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ CALL supplier_checkIsActive(NEW.supplierFk);
+ SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
+ SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterInsert`
+ AFTER INSERT ON `entry`
+ FOR EACH ROW
+BEGIN
+ CALL travel_requestRecalc(NEW.travelFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeUpdate`
+ BEFORE UPDATE ON `entry`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsVirtual BOOL;
+ DECLARE vPrintedCount INT;
+ DECLARE vHasDistinctWarehouses BOOL;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF !(NEW.travelFk <=> OLD.travelFk) THEN
+ SELECT COUNT(*) > 0 INTO vIsVirtual
+ FROM entryVirtual WHERE entryFk = NEW.id;
+
+ SELECT !(o.warehouseInFk <=> n.warehouseInFk)
+ OR !(o.warehouseOutFk <=> n.warehouseOutFk)
+ INTO vHasDistinctWarehouses
+ FROM travel o, travel n
+ WHERE o.id = OLD.travelFk
+ AND n.id = NEW.travelFk;
+
+ IF vIsVirtual AND vHasDistinctWarehouses THEN
+ SIGNAL SQLSTATE '45000'
+ SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
+ END IF;
+
+ IF NEW.travelFk IS NULL THEN
+ SELECT COUNT(*) INTO vPrintedCount
+ FROM buy
+ WHERE entryFk = OLD.id
+ AND printedStickers > 0;
+
+ IF vPrintedCount > 0 THEN
+ SIGNAL SQLSTATE '45000'
+ SET MESSAGE_TEXT = 'An entry that contains lines with printed labels cannot be deleted';
+ END IF;
+ END IF;
+ END IF;
+
+ IF NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
+ CALL supplier_checkIsActive(NEW.supplierFk);
+ SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
+ END IF;
+
+ IF NOT (NEW.travelFk <=> OLD.travelFk)
+ OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
+ SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterUpdate`
+ AFTER UPDATE ON `entry`
+ FOR EACH ROW
+BEGIN
+ IF NOT(NEW.id <=> OLD.id)
+ OR NOT(NEW.travelFk <=> OLD.travelFk)
+ OR NOT(NEW.isRaid <=> OLD.isRaid) THEN
+ CALL stock.log_add('entry', NEW.id, OLD.id);
+ END IF;
+
+ IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
+ CALL travel_requestRecalc(OLD.travelFk);
+ CALL travel_requestRecalc(NEW.travelFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeDelete`
+ BEFORE DELETE ON `entry`
+ FOR EACH ROW
+BEGIN
+ DELETE FROM buy WHERE entryFk = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterDelete`
+ AFTER DELETE ON `entry`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO entryLog
+ SET `action` = 'delete',
+ `changedModel` = 'Entry',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL travel_requestRecalc(OLD.travelFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeInsert`
+ BEFORE INSERT ON `entryObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeUpdate`
+ BEFORE UPDATE ON `entryObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_afterDelete`
+ AFTER DELETE ON `entryObservation`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO entryLog
+ SET `action` = 'delete',
+ `changedModel` = 'EntryObservation',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeInsert`
+ BEFORE INSERT ON `expedition`
+ FOR EACH ROW
+BEGIN
+ DECLARE intcounter INT;
+ DECLARE vShipFk INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.freightItemFk IS NOT NULL THEN
+
+ UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
+
+ SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
+ FROM expedition e
+ INNER JOIN ticket t1 ON e.ticketFk = t1.id
+ LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
+ INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
+ AND t1.warehouseFk = t2.warehouseFk
+ WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
+ AND t1.agencyModeFk = t2.agencyModeFk;
+
+ SET NEW.`counter` = intcounter;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeUpdate`
+ BEFORE UPDATE ON `expedition`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.counter <> OLD.counter THEN
+ IF (SELECT COUNT(*) FROM expedition e
+ INNER JOIN ticket t1 ON e.ticketFk = t1.id
+ INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
+ WHERE t1.id = NEW.ticketFk AND counter = NEW.counter) > 0 THEN
+ SET NEW.id = NULL;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeDelete`
+ BEFORE DELETE ON `expedition`
+ FOR EACH ROW
+BEGIN
+ UPDATE ticket t
+ SET packages = (SELECT COUNT(counter)-1
+ FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.freightItemFk)
+ WHERE t.id = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_afterDelete`
+ AFTER DELETE ON `expedition`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'Expedition',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionPallet_BEFORE_INSERT`
+ BEFORE INSERT ON `expeditionPallet`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE vNewPosition INT;
+
+ SELECT MAX(position) + 1 INTO vNewPosition
+ FROM vn.expeditionPallet
+ WHERE truckFk = NEW.truckFk;
+
+ SET NEW.position = IFNULL(vNewPosition,1);
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionScan_BEFORE_INSERT`
+ BEFORE INSERT ON `expeditionScan`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.workerFk = 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionState_BeforeInsert`
+ BEFORE INSERT ON `expeditionState`
+ FOR EACH ROW
+BEGIN
+ SET NEW.userFk = IFNULL(NEW.userFk, 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER expeditionState_AfterInsert
+AFTER INSERT
+ON expeditionState FOR EACH ROW
+BEGIN
+
+ UPDATE vn.expedition e
+ SET e.stateTypeFk = NEW.typeFk
+ WHERE e.id = NEW.expeditionFk;
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_BEFORE_INSERT`
+ BEFORE INSERT ON `expeditionTruck`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.description = UCASE(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_BEFORE_UPDATE`
+ BEFORE UPDATE ON `expeditionTruck`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.description = UCASE(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`floramondoConfig_AFTER_INSERT`
+ AFTER INSERT ON `floramondoConfig`
+ FOR EACH ROW
+BEGIN
+ CALL util.throw ("Tabla config no permite añadir más registros");
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`gregue_beforeInsert`
+ BEFORE INSERT ON greuge
+ FOR EACH ROW
+BEGIN
+ IF NEW.userFk IS NULL THEN
+ SET NEW.userFk = account.myUser_getId();
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeInsert`
+ BEFORE INSERT ON `greuge`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeUpdate`
+ BEFORE UPDATE ON `greuge`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_afterDelete`
+ AFTER DELETE ON `greuge`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'Greuge',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`host_beforeUpdate`
+ BEFORE UPDATE ON `host`
+ FOR EACH ROW
+BEGIN
+ SET new.updated = util.VN_NOW();
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_bi`
+ BEFORE INSERT ON `invoiceIn`
+ FOR EACH ROW
+BEGIN
+ DECLARE vSerie CHAR(1) DEFAULT 'R';
+ DECLARE vNumReceived INT;
+ DECLARE vIssuingCountry, vhostCountry INT;
+ DECLARE vActive TINYINT;
+ DECLARE vWithholdingSageFk INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ SELECT withholdingSageFk INTO vWithholdingSageFk
+ FROM vn.supplier
+ WHERE id = NEW.supplierFk;
+
+ SET NEW.withholdingSageFk = vWithholdingSageFk;
+
+ SELECT countryFk, isActive INTO vIssuingCountry, vActive
+ FROM vn.supplier
+ WHERE id = NEW.supplierFk;
+
+ SELECT countryFk INTO vhostCountry
+ FROM vn.supplier
+ WHERE id = NEW.companyFk;
+
+ IF vActive = 0 THEN
+ CALL util.throw('INACTIVE_PROVIDER');
+ END IF;
+
+ IF (SELECT COUNT(*) FROM vn.invoiceIn
+ WHERE supplierRef = NEW.supplierRef
+ AND supplierFk = NEW.supplierFk
+ AND YEAR(issued) = YEAR(NEW.issued)
+ ) THEN
+ CALL util.throw('reference duplicated');
+ END IF;
+
+ SELECT CASE WHEN (SELECT account FROM vn.supplier where id = NEW.supplierFk) LIKE '___3______' THEN 'C'
+ WHEN (SELECT vIssuingCountry=vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry
+ where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'R'
+ WHEN (SELECT vIssuingCountry <> vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry
+ where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'E'
+ WHEN (SELECT vIssuingCountry<>vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry
+ where NOT p1.CEE < 2 AND not p1.id = 1) = 1 THEN 'W'
+ END INTO vSerie;
+
+ SET NEW.serial = IFNULL(vSerie,'R');
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_bu`
+ BEFORE UPDATE ON `invoiceIn`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE vWithholdingSageFk INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF (SELECT COUNT(*) FROM vn.invoiceIn
+ WHERE supplierRef = NEW.supplierRef
+ AND supplierFk = NEW.supplierFk
+ AND YEAR(issued) = YEAR(NEW.issued)
+ AND id <> NEW.id
+ ) THEN
+ CALL util.throw('reference duplicated');
+ END IF;
+
+ IF NEW.supplierFk != OLD.supplierFk THEN
+ CALL supplier_checkIsActive(NEW.supplierFk);
+ SELECT withholdingSageFk INTO vWithholdingSageFk
+ FROM vn.supplier
+ WHERE id = NEW.supplierFk;
+ SET NEW.withholdingSageFk = vWithholdingSageFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_au`
+ AFTER UPDATE ON `invoiceIn`
+ FOR EACH ROW
+BEGIN
+
+ IF NEW.issued != OLD.issued
+ OR NEW.currencyFk != OLD.currencyFk THEN
+
+ UPDATE invoiceInTax iit
+ JOIN invoiceIn ii ON ii.id = iit.invoiceInFk
+ LEFT JOIN referenceRate rr ON rr.dated = ii.issued
+ AND rr.currencyFk = ii.currencyFk
+ SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value)
+ WHERE ii.id = NEW.id;
+
+ UPDATE invoiceInDueDay iidd
+ JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk
+ LEFT JOIN referenceRate rr ON rr.dated = ii.issued
+ AND rr.currencyFk = ii.currencyFk
+ SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value)
+ WHERE ii.id = NEW.id;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterDelete`
+ AFTER DELETE ON `invoiceIn`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO invoiceInLog
+ SET `action` = 'delete',
+ `changedModel` = 'InvoiceIn',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeInsert`
+ BEFORE INSERT ON `invoiceInDueDay`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsNotified BOOLEAN;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ SELECT isNotified INTO vIsNotified
+ FROM vn.invoiceIn ii
+ JOIN vn.supplier s ON s.id = ii.supplierFk
+ JOIN vn.payMethod pm ON pm.id = s.payMethodFk
+ WHERE ii.id = NEW.invoiceInFk;
+
+ IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified)
+ THEN
+ CALL mail_insert(
+ 'begonya@verdnatura.es',
+ 'begonya@verdnatura.es',
+ 'Añadido vencimiento en el pasado',
+ CONCAT(
+ account.myUser_getName(), ' ha añadido un vencimiento de ',
+ NEW.amount, '€ en una fecha pasada en la recibida ', NEW.invoiceInFk
+ )
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeUpdate`
+ BEFORE UPDATE ON `invoiceInDueDay`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsNotified BOOLEAN;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ SELECT isNotified INTO vIsNotified
+ FROM vn.invoiceIn ii
+ JOIN vn.supplier s ON s.id = ii.supplierFk
+ JOIN vn.payMethod pm ON pm.id = s.payMethodFk
+ WHERE ii.id = NEW.invoiceInFk;
+
+ IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified)
+ THEN
+ CALL mail_insert(
+ 'begonya@verdnatura.es',
+ 'begonya@verdnatura.es',
+ 'Añadido vencimiento en el pasado',
+ CONCAT(
+ account.myUser_getName(), ' ha añadido un vencimiento de ',
+ NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk
+ )
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_afterDelete`
+ AFTER DELETE ON `invoiceInDueDay`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO invoiceInLog
+ SET `action` = 'delete',
+ `changedModel` = 'InvoiceInDueDay',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeInsert`
+ BEFORE INSERT ON `invoiceInTax`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeUpdate`
+ BEFORE UPDATE ON `invoiceInTax`
+ FOR EACH ROW
+BEGIN
+ IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
+ CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
+ END IF;
+
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_afterDelete`
+ AFTER DELETE ON `invoiceInTax`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO invoiceInLog
+ SET `action` = 'delete',
+ `changedModel` = 'InvoiceInTax',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeInsert`
+ BEFORE INSERT ON `invoiceOut`
+ FOR EACH ROW
+BEGIN
+/**
+ * Generates the next reference for the invoice serial. There cannot be gaps
+ * between identifiers of the same serial!
+ *
+ * Reference format:
+ * {0} Invoice serial
+ * {1} The company code
+ * {2-3} Last two digits of issue year
+ * {4-$} Autoincrement identifier
+ */
+ DECLARE vRef INT DEFAULT 0;
+ DECLARE vRefLen INT;
+ DECLARE vRefPrefix VARCHAR(255);
+ DECLARE vLastRef VARCHAR(255);
+ DECLARE vCompanyCode INT;
+ DECLARE vYearLen INT DEFAULT 2;
+ DECLARE vPrefixLen INT;
+
+ SELECT companyCode INTO vCompanyCode
+ FROM company
+ WHERE id = NEW.companyFk;
+
+ IF vCompanyCode IS NULL THEN
+ CALL util.throw('companyCodeNotDefined');
+ END IF;
+
+ SELECT MAX(i.ref) INTO vLastRef
+ FROM invoiceOut i
+ WHERE i.serial = NEW.serial
+ AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.lastDayOfYear(NEW.issued)
+ AND i.companyFk = NEW.companyFk;
+
+ IF vLastRef IS NOT NULL THEN
+ SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
+ SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
+ SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
+ SET vRef = RIGHT(vLastRef, vRefLen);
+ ELSE
+ SELECT refLen INTO vRefLen FROM invoiceOutConfig;
+ SET vRefPrefix = CONCAT(
+ NEW.serial,
+ vCompanyCode,
+ RIGHT(YEAR(NEW.issued), vYearLen)
+ );
+ END IF;
+
+ SET vRef = vRef + 1;
+ IF LENGTH(vRef) > vRefLen THEN
+ CALL util.throw('refIdLenExceeded');
+ END IF;
+
+ SET NEW.ref = CONCAT(vRefPrefix, LPAD(vRef, vRefLen, '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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert`
+ AFTER INSERT ON `invoiceOut`
+ FOR EACH ROW
+BEGIN
+ CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate`
+ BEFORE UPDATE ON `invoiceOut`
+ FOR EACH ROW
+BEGIN
+CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount);
+CALL clientRisk_update (NEW.clientFk, NEW.companyFk, NEW.amount);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeDelete`
+ BEFORE DELETE ON `invoiceOut`
+ FOR EACH ROW
+BEGIN
+ CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeInsert`
+ BEFORE INSERT ON `item`
+ FOR EACH ROW
+BEGIN
+ DECLARE vItemPackingType VARCHAR(1);
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.itemPackingTypeFk IS NULL THEN
+ SELECT itemPackingTypeFk INTO vItemPackingType
+ FROM vn.itemType it
+ WHERE id = NEW.typeFk;
+
+ SET NEW.itemPackingTypeFk = vItemPackingType;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterInsert`
+ AFTER INSERT ON `item`
+ FOR EACH ROW
+BEGIN
+ CALL hedera.image_ref('catalog', NEW.image);
+
+ INSERT INTO vn.itemTaxCountry(itemFk, countryFk) VALUES
+ (NEW.id, 1),
+ (NEW.id, 5);
+
+ DELETE ifr.*
+ FROM edi.item_free ifr
+ WHERE ifr.id = NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeUpdate`
+ BEFORE UPDATE ON `item`
+ FOR EACH ROW
+BEGIN
+ DECLARE vNewPackingShelve INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN
+ SELECT NEW.packingOut * vc.shelveVolume / vc.standardFlowerBox
+ INTO vNewPackingShelve
+ FROM vn.volumeConfig vc;
+
+ SET NEW.packingShelve = vNewPackingShelve;
+ END IF;
+
+ IF NEW.itemPackingTypeFk = '' THEN
+ SET NEW.itemPackingTypeFk = NULL;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate`
+ AFTER UPDATE ON `item`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.image <=> OLD.image) THEN
+ CALL hedera.image_unref('catalog', OLD.image);
+ CALL hedera.image_ref('catalog', NEW.image);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterDelete`
+ AFTER DELETE ON `item`
+ FOR EACH ROW
+BEGIN
+ CALL hedera.image_unref('catalog', OLD.image);
+
+ IF OLD.isFloramondo THEN
+ INSERT IGNORE edi.item_free
+ SET id = OLD.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeInsert`
+ BEFORE INSERT ON `itemBarcode`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeUpdate`
+ BEFORE UPDATE ON `itemBarcode`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_afterDelete`
+ AFTER DELETE ON `itemBarcode`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO itemLog
+ SET `action` = 'delete',
+ `changedModel` = 'ItemBarcode',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert`
+ BEFORE INSERT ON `itemBotanical`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate`
+ BEFORE UPDATE ON `itemBotanical`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_afterDelete`
+ AFTER DELETE ON `itemBotanical`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO itemLog
+ SET `action` = 'delete',
+ `changedModel` = 'ItemBotanical',
+ `changedModelId` = OLD.itemFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCategory_AFTER_INSERT`
+ AFTER INSERT ON `itemCategory`
+ FOR EACH ROW
+BEGIN
+ CALL mail_insert('cau@verdnatura.es',
+ NULL,
+ CONCAT('Se ha añadido la familia: ', NEW.name),
+ 'Hay que añadir la familia en el formulario gastos');
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeInsert`
+ BEFORE INSERT ON `itemCost`
+ FOR EACH ROW
+BEGIN
+ IF NEW.itemFk IN (95, 98) THEN
+ SET NEW.cm3 = 0;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeUpdate`
+ BEFORE UPDATE ON `itemCost`
+ FOR EACH ROW
+BEGIN
+ IF NEW.itemFk IN (95, 98) THEN
+ SET NEW.cm3 = 0;
+ END IF;
+
+ IF !(NEW.cm3delivery <=> OLD.cm3delivery) THEN
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.itemCost ic
+ JOIN vn.sale s ON s.itemFk = ic.itemFk
+ JOIN vn.ticket t ON t.id = s.ticketFk AND t.warehouseFk = ic.warehouseFk
+ JOIN vn.route r ON r.id = t.routeFk
+ WHERE r.isOk = FALSE
+ AND ic.itemFk = NEW.itemFk
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN
+ CALL mail_insert(
+ 'jgallego@verdnatura.es',
+ NULL,
+ 'update cm3Delivery',
+ CONCAT('articulo: ', NEW.itemFk));
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_INSERT`
+ BEFORE INSERT ON `itemShelving`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.userFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_INSERT`
+ AFTER INSERT ON `itemShelving`
+ FOR EACH ROW
+INSERT INTO vn.itemShelvingLog( itemShelvingFk,
+ workerFk,
+ accion,
+ itemFk,
+ shelvingFk,
+ visible,
+ `grouping`,
+ packing)
+ VALUES( NEW.id,
+ NEW.userFk,
+ 'CREA REGISTRO',
+ NEW.itemFk,
+ NEW.shelvingFk,
+ NEW.visible,
+ NEW.`grouping`,
+ NEW.packing
+ ) */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE`
+ BEFORE UPDATE ON `itemShelving`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ IF NEW.userFk IS NULL THEN
+ SET NEW.userFk = account.myUser_getId();
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_UPDATE`
+ AFTER UPDATE ON `itemShelving`
+ FOR EACH ROW
+
+ INSERT INTO itemShelvingLog
+ SET itemShelvingFk = NEW.id,
+ workerFk = account.myUser_getId(),
+ accion = 'CAMBIO',
+ itemFk = NEW.itemFk,
+ shelvingFk = NEW.shelvingFk,
+ visible = NEW.visible,
+ `grouping` = NEW.`grouping`,
+ packing = NEW.packing */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_DELETE`
+ BEFORE DELETE ON `itemShelving`
+ FOR EACH ROW
+INSERT INTO vn.itemShelvingLog(itemShelvingFk,
+ workerFk,
+ accion,
+ shelvingFk,
+ itemFk)
+ VALUES( OLD.id,
+ account.myUser_getId(),
+ 'ELIMINADO',
+ OLD.shelvingFk,
+ OLD.itemFk) */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving _afterDelete`
+ AFTER DELETE ON `itemShelving`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO shelvingLog
+ SET `action` = 'delete',
+ `changedModel` = 'itemShelving',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_AFTER_INSERT`
+ AFTER INSERT ON `itemShelvingSale`
+ FOR EACH ROW
+BEGIN
+
+ UPDATE vn.sale
+ SET isPicked = TRUE
+ WHERE id = NEW.saleFk;
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeInsert`
+ BEFORE INSERT ON `itemTag`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.intValue = itemTag_getIntValue(NEW.`value`);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterInsert`
+ AFTER INSERT ON `itemTag`
+ FOR EACH ROW
+trig: BEGIN
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ CALL item_refreshFromTags(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeUpdate`
+ BEFORE UPDATE ON `itemTag`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF !(OLD.`value` <=> NEW.`value`)
+ OR !(OLD.intValue <=> NEW.intValue) THEN
+ SET NEW.intValue = itemTag_getIntValue(NEW.`value`);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterUpdate`
+ AFTER UPDATE ON `itemTag`
+ FOR EACH ROW
+trig: BEGIN
+ DECLARE vItemFk INT;
+ DECLARE visTriggerDisabled BOOL;
+
+ SELECT isItemTagTriggerDisabled INTO visTriggerDisabled
+ FROM vn.itemConfig;
+
+ IF @isTriggerDisabled OR visTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ SET vItemFk = NEW.itemFk;
+ DROP TEMPORARY TABLE IF EXISTS tmp.item;
+ CREATE TEMPORARY TABLE tmp.item
+ SELECT vItemFk id;
+
+ CALL item_refreshTags();
+ DROP TEMPORARY TABLE tmp.item;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterDelete`
+ AFTER DELETE ON `itemTag`
+ FOR EACH ROW
+trig: BEGIN
+ INSERT INTO itemLog
+ SET `action` = 'delete',
+ `changedModel` = 'ItemTag',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ CALL item_refreshFromTags(OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeInsert`
+ BEFORE INSERT ON `itemTaxCountry`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeUpdate`
+ BEFORE UPDATE ON `itemTaxCountry`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_afterDelete`
+ AFTER DELETE ON `itemTaxCountry`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO itemLog
+ SET `action` = 'delete',
+ `changedModel` = 'ItemTaxCountry',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeUpdate`
+ BEFORE UPDATE ON `itemType`
+ FOR EACH ROW
+BEGIN
+ IF NEW.itemPackingTypeFk = '' THEN
+
+ SET NEW.itemPackingTypeFk = NULL;
+
+ END IF;
+
+ IF NEW.itemPackingTypeFk != OLD.itemPackingTypeFk THEN
+ UPDATE vn.item
+ SET itemPackingTypeFk = NEW.itemPackingTypeFk
+ WHERE typeFk = NEW.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`machine_BI`
+ BEFORE INSERT ON `machine`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.workerFk = 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`mail_beforeInsert`
+ BEFORE INSERT ON `mail`
+ FOR EACH ROW
+BEGIN
+
+ IF NEW.sender IS NOT NULL THEN
+
+ SET NEW.receiver = NEW.sender;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`mandate_beforeInsert`
+ BEFORE INSERT ON `mandate`
+ FOR EACH ROW
+BEGIN
+ IF (NEW.code IS NULL) THEN
+ SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT
+ FROM information_schema.TABLES
+ WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate'));
+ 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_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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeInsert`
+ BEFORE INSERT ON `operator`
+ FOR EACH ROW
+BEGIN
+ CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeUpdate`
+ BEFORE UPDATE ON `operator`
+ FOR EACH ROW
+BEGIN
+ IF NOT (NEW.labelerFk <=> OLD.labelerFk AND NEW.sectorFk <=> OLD.sectorFk) THEN
+ CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeInsert`
+ BEFORE INSERT ON `packaging`
+ FOR EACH ROW
+BEGIN
+ SET NEW.value = packaging_calculate(NEW.isPackageReturnable, NEW.packagingReturnFk, NEW.base, NEW.price, NEW.upload);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeUpdate`
+ BEFORE UPDATE ON `packaging`
+ FOR EACH ROW
+BEGIN
+ SET NEW.value = packaging_calculate(NEW.isPackageReturnable, NEW.packagingReturnFk, NEW.base, NEW.price, NEW.upload);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeInsert`
+ BEFORE INSERT ON `packingSite`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeUpdate`
+ BEFORE UPDATE ON `packingSite`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_afterDelete`
+ AFTER DELETE ON `packingSite`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO packingSiteDeviceLog
+ SET `action` = 'delete',
+ `changedModel` = 'PackingSite',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_BEFORE_INSERT`
+ BEFORE INSERT ON `parking`
+ FOR EACH ROW
+BEGIN
+
+ -- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_BEFORE_UPDATE`
+ BEFORE UPDATE ON `parking`
+ FOR EACH ROW
+BEGIN
+
+ -- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
+
+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_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW
+BEGIN
+ DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
+ DECLARE vNewBookEntry INT;
+ DECLARE bolCASH BOOLEAN;
+ DECLARE isSupplierActive BOOLEAN;
+
+ -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
+ SELECT (at2.code = 'cash') INTO bolCASH
+ FROM vn.bank b
+ JOIN vn.accountingType at2 ON at2.id = b.cash
+ WHERE b.id = NEW.bankFk;
+
+ IF bolCASH THEN
+
+ SELECT account INTO cuenta_banco
+ FROM bank
+ WHERE id = NEW.bankFk;
+
+ SELECT account INTO cuenta_proveedor
+ FROM supplier
+ WHERE id = NEW.supplierFk;
+
+ CALL vn.ledger_next(vNewBookEntry);
+
+ INSERT INTO XDiario ( ASIEN,
+ FECHA,
+ SUBCTA,
+ CONTRA,
+ CONCEPTO,
+ EURODEBE,
+ EUROHABER,
+ empresa_id)
+ SELECT vNewBookEntry,
+ NEW.received,
+ SUBCTA,
+ CONTRA,
+ NEW.concept,
+ EURODEBE,
+ EUROHABER,
+ NEW.companyFk
+ FROM ( SELECT cuenta_banco SUBCTA,
+ cuenta_proveedor CONTRA,
+ 0 EURODEBE,
+ NEW.amount + NEW.bankingFees EUROHABER
+ UNION ALL
+ SELECT cuenta_proveedor SUBCTA,
+ cuenta_banco CONTRA,
+ NEW.amount EURODEBE,
+ 0 EUROHABER) gf;
+
+ IF NEW.bankingFees <> 0 THEN
+ INSERT INTO XDiario ( ASIEN,
+ FECHA,
+ SUBCTA,
+ CONTRA,
+ CONCEPTO,
+ EURODEBE,
+ EUROHABER,
+ empresa_id)
+ SELECT vNewBookEntry,
+ NEW.received,
+ IF(c.id = 1,6260000002,
+ IF(CEE = 1,6260000003,6260000004)),
+ cuenta_banco,
+ NEW.concept,
+ NEW.bankingFees,
+ 0,
+ NEW.companyFk
+ FROM supplier s
+ JOIN country c ON s.countryFk = c.id
+ WHERE s.id = NEW.supplierFk;
+ END IF;
+ END IF;
+
+ SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
+
+ SELECT isActive INTO isSupplierActive
+ FROM supplier
+ WHERE id = NEW.supplierFk;
+
+ IF isSupplierActive = FALSE THEN
+ CALL util.throw('SUPPLIER_INACTIVE');
+ END IF;
+
+ IF ISNULL(NEW.workerFk) THEN
+ SET NEW.workerFk = account.myUser_getId();
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_afterInsert`
+ AFTER INSERT ON `payment`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsPayMethodChecked BOOLEAN;
+ DECLARE vEmail VARCHAR(150);
+
+ SELECT isPayMethodChecked INTO vIsPayMethodChecked
+ FROM supplier
+ WHERE id = NEW.supplierFk;
+
+
+ IF vIsPayMethodChecked = FALSE THEN
+
+ SELECT notificationEmail INTO vEmail
+ FROM department
+ WHERE name = 'FINANZAS';
+
+ CALL mail_insert(
+ vEmail,
+ NULL,
+ 'Pago con método sin verificar',
+ CONCAT(
+ 'Se ha realizado el pago ',
+ NEW.id,
+ ' al proveedor ',
+ NEW.supplierFk,
+ ' con el método de pago sin verificar.'
+ )
+ );
+ 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_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER payment_beforeUpdate BEFORE UPDATE ON payment FOR EACH ROW
+BEGIN
+ IF ISNULL(NEW.workerFk) THEN
+ SET NEW.workerFk = account.myUser_getId();
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeInsert`
+ BEFORE INSERT ON `postCode`
+ FOR EACH ROW
+BEGIN
+ SET NEW.geoFk = zoneGeo_new('postCode', NEW.`code`,
+ (SELECT geoFk FROM town WHERE id = NEW.townFk));
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeUpdate`
+ BEFORE UPDATE ON `postCode`
+ FOR EACH ROW
+BEGIN
+ -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
+ -- CALL zoneGeo_throwNotEditable;
+ -- 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterUpdate`
+ AFTER UPDATE ON `postCode`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.townFk <=> NEW.townFk) THEN
+ CALL zoneGeo_setParent(NEW.geoFk,
+ (SELECT geoFk FROM town WHERE id = NEW.townFk));
+ END IF;
+
+ IF !(OLD.`code` <=> NEW.`code`) THEN
+ UPDATE zoneGeo SET `name` = NEW.`code`
+ WHERE id = NEW.geoFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterDelete`
+ AFTER DELETE ON `postCode`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_delete(OLD.geoFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeInsert`
+ BEFORE INSERT ON `priceFixed`
+ FOR EACH ROW
+BEGIN
+ DECLARE vDated DATE;
+ IF NEW.started > NEW.ended THEN
+ SET vDated = NEW.started;
+ SET NEW.started = NEW.ended;
+ SET NEW.ended = vDated;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeUpdate`
+ BEFORE UPDATE ON `priceFixed`
+ FOR EACH ROW
+BEGIN
+ DECLARE vDated DATE;
+ IF NEW.started > NEW.ended THEN
+ SET vDated = NEW.started;
+ SET NEW.started = NEW.ended;
+ SET NEW.ended = vDated;
+ 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_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER projectNotes_BeforeInsert
+BEFORE INSERT
+ON projectNotes FOR EACH ROW
+BEGIN
+
+ IF ISNULL(NEW.userFk) THEN
+
+ SET NEW.userFk = account.myUser_getId();
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeInsert`
+ BEFORE INSERT ON `province`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.geoFk = zoneGeo_new('province', NEW.`name`,
+ (SELECT geoFk FROM autonomy WHERE id = NEW.autonomyFk));
+
+ SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk);
+
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeUpdate`
+ BEFORE UPDATE ON `province`
+ FOR EACH ROW
+BEGIN
+
+ IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN
+
+ SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk);
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterUpdate`
+ AFTER UPDATE ON `province`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN
+ CALL zoneGeo_setParent(NEW.geoFk,
+ (SELECT geoFk FROM autonomy WHERE id = NEW.autonomyFk));
+ END IF;
+
+ IF !(OLD.`name` <=> NEW.`name`) THEN
+ UPDATE zoneGeo SET `name` = NEW.`name`
+ WHERE id = NEW.geoFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterDelete`
+ AFTER DELETE ON `province`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_delete(OLD.geoFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeInsert`
+ BEFORE INSERT ON `rate`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeUpdate`
+ BEFORE UPDATE ON `rate`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_afterDelete`
+ AFTER DELETE ON `rate`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO rateLog
+ SET `action` = 'delete',
+ `changedModel` = 'Rate',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeInsert`
+ BEFORE INSERT ON `receipt`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsAutoConciliated BOOLEAN;
+
+ IF NEW.isConciliate = FALSE THEN
+ SELECT isAutoConciliated INTO vIsAutoConciliated
+ FROM accounting a
+ JOIN accountingType at2 ON at2.id = a.accountingTypeFk
+ WHERE a.id = NEW.bankFk;
+
+ SET NEW.isConciliate = vIsAutoConciliated;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert`
+ AFTER INSERT ON `receipt`
+ FOR EACH ROW
+CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid) */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate`
+ BEFORE UPDATE ON `receipt`
+ FOR EACH ROW
+BEGIN
+ CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid);
+ CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid);
+ SET NEW.workerFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate`
+ AFTER UPDATE ON `receipt`
+ FOR EACH ROW
+BEGIN
+ IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN
+ CALL mail_insert(
+ 'finanzas@verdnatura.es',
+ NULL,
+ CONCAT('Cambios de recibos del cliente: ', NEW.clientFk),
+ CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed)
+ );
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete`
+ BEFORE DELETE ON `receipt`
+ FOR EACH ROW
+CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid) */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeInsert`
+ BEFORE INSERT ON `recovery`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeUpdate`
+ BEFORE UPDATE ON `recovery`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_afterDelete`
+ AFTER DELETE ON `recovery`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'Recovery',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert`
+ BEFORE INSERT ON `route`
+ FOR EACH ROW
+BEGIN
+ DECLARE vDefaultAgencyModeFk INT;
+ DECLARE vUserFk INT ;
+
+ SET vUserFk = account.myUser_getId();
+ SET NEW.editorFk = vUserFk;
+ SET NEW.firstEditorFk = vUserFk;
+
+ SET NEW.commissionWorkCenterFk = (
+ SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk)
+ FROM vn.routeConfig r
+ LEFT JOIN vn.business b ON b.workerFk = vUserFk
+ AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created));
+
+ IF ISNULL(NEW.agencyModeFk) THEN
+ SELECT r.agencyModeFk INTO vDefaultAgencyModeFk
+ FROM routeDefaultAgencyMode r
+ JOIN business b ON b.workCenterFk = r.workCenterFK
+ JOIN worker w ON w.businessFk = b.id
+ WHERE b.workerFk = vUserFk;
+
+ SET NEW.agencyModeFk = vDefaultAgencyModeFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterInsert`
+ AFTER INSERT ON `route`
+ FOR EACH ROW
+BEGIN
+ CALL route_calcCommission(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeUpdate`
+ BEFORE UPDATE ON `route`
+ FOR EACH ROW
+BEGIN
+ DECLARE vKmMax INT;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.isOk <> FALSE AND OLD.isOk = FALSE THEN
+ SET NEW.m3 = ( SELECT SUM(litros)/1000
+ FROM vn.saleVolume s
+ JOIN vn.ticket t ON s.ticketFk = t.id
+ WHERE t.routeFk = NEW.id);
+ END IF;
+
+ IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN
+ CALL util.throw ('KmEnd menor que kmStart');
+ END IF;
+
+ SELECT kmMax INTO vKmMax
+ FROM routeConfig rc;
+
+ IF ((NEW.kmEnd - NEW.kmStart) > vKmMax) AND NEW.kmEnd <> 0 THEN
+ CALL util.throw (CONCAT('The km can not exceed ', vKmMax));
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterUpdate`
+ AFTER UPDATE ON `route`
+ FOR EACH ROW
+BEGIN
+ IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
+ -- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
+
+ -- Inserta el gestdoc en todos los tickets de la ruta
+ INSERT INTO ticketDms(ticketFk,dmsFk)
+ SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
+ ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
+
+ -- Update del firmado
+ UPDATE ticket t
+ JOIN ticketDms tg ON t.id = tg.ticketFk
+ SET isSigned = 1 WHERE t.routeFk = NEW.id;
+ END IF;
+
+ IF !(NEW.kmStart <=> OLD.kmStart)
+ OR !(NEW.kmEnd <=> OLD.kmEnd)
+ OR !(NEW.workerFk <=> OLD.workerFk)
+ OR !(NEW.m3 <=> OLD.m3)
+ OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN
+ CALL route_calcCommission(NEW.id);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterDelete`
+ AFTER DELETE ON `route`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO routeLog
+ SET `action` = 'delete',
+ `changedModel` = 'Route',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeInsert`
+ BEFORE INSERT ON `routesMonitor`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeUpdate`
+ BEFORE UPDATE ON `routesMonitor`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_afterDelete`
+ AFTER DELETE ON `routesMonitor`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO routeLog
+ SET `action` = 'delete',
+ `changedModel` = 'RoutesMonitor',
+ `changedModelId` = OLD.routeFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeInsert`
+ BEFORE INSERT ON `sale`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.originalQuantity = NEW.quantity;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterInsert`
+ AFTER INSERT ON `sale`
+ FOR EACH ROW
+BEGIN
+ IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN
+ CALL util.throw('Cannot insert a service item into a ticket');
+ END IF;
+
+ CALL stock.log_add('sale', NEW.id, NULL);
+ CALL ticket_requestRecalc(NEW.ticketFk);
+
+ IF NEW.quantity > 0 THEN
+
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id
+ AND tc.ticketFk = NEW.ticketFk
+ JOIN vn.item i ON i.id = NEW.itemFk
+ AND (c.itemPackingTypeFk = i.itemPackingTypeFk
+ OR c.itemPackingTypeFk IS NULL)
+ SET c.saleTotalCount = c.saleTotalCount + 1;
+
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.route r ON r.id = t.routeFk
+ WHERE r.isOk = FALSE
+ AND s.id = NEW.id
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeUpdate`
+ BEFORE UPDATE ON `sale`
+ FOR EACH ROW
+BEGIN
+/*
+ IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN
+ CALL util.throw('Cannot insert a service item into a ticket');
+ END IF;
+*/
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.discount > 100 THEN
+ SET NEW.discount = 0;
+ END IF;
+
+ IF old.discount > 0 AND NEW.discount = 0 THEN
+ INSERT INTO ticketLog
+ SET originFk = NEW.ticketFk, userFk = account.myUser_getId(), `action` = 'insert',
+ description = CONCAT('Cambio de descuento del item :', ' ', new.itemFk, ' de ', old.discount ,' a 0 ');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterUpdate`
+ AFTER UPDATE ON `sale`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsToSendMail BOOL;
+ DECLARE vUserRole VARCHAR(255);
+
+ IF !(NEW.id <=> OLD.id)
+ OR !(NEW.ticketFk <=> OLD.ticketFk)
+ OR !(NEW.itemFk <=> OLD.itemFk)
+ OR !(NEW.quantity <=> OLD.quantity)
+ OR !(NEW.created <=> OLD.created)
+ OR !(NEW.isPicked <=> OLD.isPicked) THEN
+ CALL stock.log_add('sale', NEW.id, OLD.id);
+ END IF;
+
+ IF !(NEW.price <=> OLD.price)
+ OR !(NEW.ticketFk <=> OLD.ticketFk)
+ OR !(NEW.itemFk <=> OLD.itemFk)
+ OR !(NEW.quantity <=> OLD.quantity)
+ OR !(NEW.discount <=> OLD.discount) THEN
+ CALL ticket_requestRecalc(NEW.ticketFk);
+ CALL ticket_requestRecalc(OLD.ticketFk);
+ END IF;
+
+ IF !(OLD.ticketFk <=> NEW.ticketFk) THEN
+ UPDATE ticketRequest SET ticketFk = NEW.ticketFk
+ WHERE saleFk = NEW.id;
+ END IF;
+
+ SELECT account.myUser_getName() INTO vUserRole;
+ SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole;
+
+ IF !(OLD.quantity <=> NEW.quantity) THEN
+ SELECT COUNT(*) INTO vIsToSendMail
+ FROM ticketTracking tt
+ JOIN vn.state s ON s.id = tt.stateFk
+ WHERE s.code='PACKED'
+ AND tt.ticketFk = OLD.ticketFk
+ AND vUserRole IN ('salesPerson', 'salesTeamBoss')
+ LIMIT 1;
+
+ IF vIsToSendMail THEN
+ CALL vn.mail_insert('jefesventas@verdnatura.es',
+ 'noreply@verdnatura.es',
+ CONCAT('Ticket ', OLD.ticketFk ,' modificada cantidad tras encajado'),
+ CONCAT('Ticket ', OLD.ticketFk ,'.
',
+ 'Modificada la catidad de ', OLD.quantity, ' a ' , NEW.quantity,
+ ' del artículo ', OLD.itemFk, ' tras estado encajado del ticket.
',
+ 'Este email se ha generado automáticamente' )
+ );
+ END IF;
+ IF (OLD.quantity > NEW.quantity) THEN
+ INSERT INTO saleComponent(saleFk, componentFk, value)
+ SELECT NEW.id, cm.id, sc.value
+ FROM saleComponent sc
+ JOIN component cd ON cd.id = sc.componentFk
+ JOIN component cm ON cm.code = 'mana'
+ WHERE saleFk = NEW.id AND cd.code = 'lastUnitsDiscount'
+ ON DUPLICATE KEY UPDATE value = sc.value + VALUES(value);
+
+ DELETE sc.*
+ FROM vn.saleComponent sc
+ JOIN component c ON c.id = sc.componentFk
+ WHERE saleFk = NEW.id AND c.code = 'lastUnitsDiscount';
+ END IF;
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.route r ON r.id = t.routeFk
+ WHERE r.isOk = FALSE
+ AND s.id = NEW.id
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ END IF;
+
+ IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
+ SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1);
+ END IF;
+
+ IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
+ SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_BEFORE_DELETE`
+ BEFORE DELETE ON `sale`
+ FOR EACH ROW
+BEGIN
+ IF OLD.quantity > 0 THEN
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.route r ON r.id = t.routeFk
+ WHERE r.isOk = FALSE
+ AND s.id = OLD.id
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterDelete`
+ AFTER DELETE ON `sale`
+ FOR EACH ROW
+BEGIN
+ DECLARE vIsToSendMail BOOL;
+ DECLARE vUserRole VARCHAR(255);
+
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'Sale',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL stock.log_add('sale', NULL, OLD.id);
+ CALL ticket_requestRecalc(OLD.ticketFk);
+
+ SELECT account.myUser_getName() INTO vUserRole;
+ SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole;
+
+ SELECT COUNT(*) INTO vIsToSendMail
+ FROM ticketTracking tt
+ JOIN vn.state s ON s.id = tt.stateFk
+ WHERE s.code='PACKED'
+ AND tt.ticketFk = OLD.ticketFk
+ AND vUserRole IN ('salesPerson', 'salesBoss')
+ LIMIT 1;
+
+ IF vIsToSendMail THEN
+ CALL vn.mail_insert('jefesventas@verdnatura.es',
+ 'noreply@verdnatura.es',
+ CONCAT('Ticket ', OLD.ticketFk ,' eliminado artículo tras encajado' ),
+ CONCAT('Ticket ', OLD.ticketFk ,'.
',
+ 'Eliminado artículo ', OLD.itemFk, ' tras estado encajado del ticket.
Este email se ha generado automáticamente' )
+ );
+ END IF;
+
+ IF OLD.quantity > 0 THEN
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = OLD.ticketFk
+ JOIN vn.item i ON i.id = OLD.itemFk
+ AND (c.itemPackingTypeFk = i.itemPackingTypeFk
+ OR ISNULL(c.itemPackingTypeFk))
+ SET c.saleTotalCount = c.saleTotalCount - 1,
+ c.salePickedCount = c.salePickedCount - ABS(OLD.isPicked);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`BEFORE_INSERT`
+ BEFORE INSERT ON `saleBuy`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.workerFk = 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleBuy_AI`
+ AFTER INSERT ON `saleBuy`
+ FOR EACH ROW
+BEGIN
+/* Activar de nuevo cuando volvamos a vender fruta y verdura
+ *
+ UPDATE vn.sale s
+ SET s.concept = CONCAT(s.concept, ' Lote: ', NEW.buyFk)
+ WHERE s.id = NEW.saleFk;
+*/
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeInsert`
+ BEFORE INSERT ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeUpdate`
+ BEFORE UPDATE ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_afterDelete`
+ AFTER DELETE ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'SaleGroup',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleTracking_After_Insert`
+ AFTER INSERT ON `saleTracking`
+ FOR EACH ROW
+BEGIN
+
+ IF NEW.isChecked THEN
+
+ UPDATE vn.sale s
+ SET s.isPicked = TRUE
+ WHERE s.id = NEW.saleFk
+ AND s.isPicked = 0;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeInsert`
+ BEFORE INSERT ON `sharingCart`
+ FOR EACH ROW
+BEGIN
+ IF NEW.workerFk = NEW.workerSubstitute THEN
+ CALL util.throw ('worker and workerSubstitute must be different');
+ ELSE
+ INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated)
+ SELECT NEW.workerFk, NEW.workerSubstitute, dated
+ FROM time
+ WHERE dated BETWEEN NEW.started AND NEW.ended;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeUpdate`
+ BEFORE UPDATE ON `sharingCart`
+ FOR EACH ROW
+BEGIN
+ IF NEW.workerFk = NEW.workerSubstitute THEN
+ CALL util.throw ('worker and workerSubstitute must be different');
+ ELSE
+ DELETE sc FROM sharingCartDaily sc
+ WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND
+ sc.ownerFk = OLD.workerFk AND
+ sc.substituteFk = OLD.workerSubstitute;
+
+ INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated)
+ SELECT NEW.workerFk, NEW.workerSubstitute, dated
+ FROM time
+ WHERE dated BETWEEN NEW.started AND NEW.ended;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeDelete`
+ BEFORE DELETE ON `sharingCart`
+ FOR EACH ROW
+BEGIN
+ DELETE sc FROM sharingCartDaily sc
+ WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND
+ sc.ownerFk = OLD.workerFk AND
+ sc.substituteFk = OLD.workerSubstitute;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeInsert`
+ BEFORE INSERT ON `sharingClient`
+ FOR EACH ROW
+BEGIN
+ SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended);
+ SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeUpdate`
+ BEFORE UPDATE ON `sharingClient`
+ FOR EACH ROW
+BEGIN
+ SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended);
+ SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_beforeInsert`
+ BEFORE INSERT ON `shelving`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.code = "" THEN
+ CALL util.throw('NOT_EMPTY_CODE_ALLOWED');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_BEFORE_UPDATE`
+ BEFORE UPDATE ON `shelving`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.code = "" THEN
+ CALL util.throw('NOT_EMPTY_CODE_ALLOWED');
+ END IF;
+
+ IF NOT(OLD.parkingFk <=> NEW.parkingFK) THEN
+ SET NEW.isMoving = FALSE;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_afterDelete`
+ AFTER DELETE ON `shelving`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO shelvingLog
+ SET `action` = 'delete',
+ `changedModel` = 'Shelving',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_AFTER_INSERT`
+ AFTER INSERT ON `solunionCAP`
+ FOR EACH ROW
+BEGIN
+ UPDATE vn2008.Clientes c
+ JOIN creditClassification cc ON c.Id_Cliente = cc.client
+ JOIN creditInsurance ci ON ci.creditClassification = cc.id
+ SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_AFTER_UPDATE`
+ AFTER UPDATE ON `solunionCAP`
+ FOR EACH ROW
+BEGIN
+ IF NEW.dateLeaving IS NOT NULL THEN
+ UPDATE vn2008.Clientes c
+ JOIN creditClassification cc ON c.Id_Cliente = cc.client
+ JOIN creditInsurance ci ON ci.creditClassification = cc.id
+ SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
+ ELSE
+ UPDATE vn2008.Clientes c
+ JOIN creditClassification cc ON c.Id_Cliente = cc.client
+ JOIN creditInsurance ci ON ci.creditClassification = cc.id
+ SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_BEFORE_DELETE`
+ BEFORE DELETE ON `solunionCAP`
+ FOR EACH ROW
+BEGIN
+ UPDATE vn2008.Clientes c
+ JOIN creditClassification cc ON c.Id_Cliente = cc.client
+ JOIN creditInsurance ci ON ci.creditClassification = cc.id
+ SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_INSERT`
+ BEFORE INSERT ON `specie`
+ FOR EACH ROW
+BEGIN
+ SET NEW.name = LCASE(NEW.name);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_UPDATE`
+ BEFORE UPDATE ON `specie`
+ FOR EACH ROW
+BEGIN
+ SET NEW.name = LCASE(NEW.name);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeInsert`
+ BEFORE INSERT ON `supplier`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeUpdate`
+ BEFORE UPDATE ON `supplier`
+ FOR EACH ROW
+BEGIN
+ DECLARE vHasChange BOOL;
+ DECLARE vPayMethodChanged BOOL;
+ DECLARE vPayMethodHasVerified BOOL;
+ DECLARE vParams JSON;
+ DECLARE vOldPayMethodName VARCHAR(20);
+ DECLARE vNewPayMethodName VARCHAR(20);
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ SELECT hasVerified INTO vPayMethodHasVerified
+ FROM payMethod
+ WHERE id = NEW.payMethodFk;
+
+ SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk);
+
+ IF vPayMethodChanged THEN
+ SELECT name INTO vOldPayMethodName
+ FROM payMethod
+ WHERE id = OLD.payMethodFk;
+ SELECT name INTO vNewPayMethodName
+ FROM payMethod
+ WHERE id = NEW.payMethodFk;
+
+ SET vParams = JSON_OBJECT(
+ 'name', NEW.name,
+ 'oldPayMethod', vOldPayMethodName,
+ 'newPayMethod', vNewPayMethodName
+ );
+ SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id;
+ END IF;
+
+ SET vHasChange = NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged;
+
+ IF vHasChange AND vPayMethodHasVerified THEN
+ SET NEW.isPayMethodChecked = FALSE;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterDelete`
+ AFTER DELETE ON `supplier`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO supplierLog
+ SET `action` = 'delete',
+ `changedModel` = 'Supplier',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeInsert`
+ BEFORE INSERT ON `supplierAccount`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeUpdate`
+ BEFORE UPDATE ON `supplierAccount`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_afterDelete`
+ AFTER DELETE ON `supplierAccount`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO supplierLog
+ SET `action` = 'delete',
+ `changedModel` = 'SupplierAccount',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeInsert`
+ BEFORE INSERT ON `supplierAddress`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeUpdate`
+ BEFORE UPDATE ON `supplierAddress`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_afterDelete`
+ AFTER DELETE ON `supplierAddress`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO supplierLog
+ SET `action` = 'delete',
+ `changedModel` = 'SupplierAddress',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeInsert`
+ BEFORE INSERT ON `supplierContact`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeUpdate`
+ BEFORE UPDATE ON `supplierContact`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_afterDelete`
+ AFTER DELETE ON `supplierContact`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO supplierLog
+ SET `action` = 'delete',
+ `changedModel` = 'SupplierContact',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`tag_BEFORE_INSERT`
+ BEFORE INSERT ON `tag`
+ FOR EACH ROW
+BEGIN
+ IF NEW.ediTypeFk IS NULL AND (SELECT COUNT(*) FROM tag WHERE `name` = NEW.`name`) THEN
+ CALL util.throw('name duplicated');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeInsert`
+ BEFORE INSERT ON `ticket`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterInsert`
+ AFTER INSERT ON `ticket`
+ FOR EACH ROW
+BEGIN
+
+ DECLARE vClientType VARCHAR(255);
+ DECLARE vStateCode VARCHAR(255);
+ DECLARE vTransferorFirstShipped DATE;
+
+ -- Borrar cuando se cambie el insert ticket en la APP móvil
+
+ SELECT typeFk INTO vClientType
+ FROM vn.`client` WHERE id = NEW.clientFk;
+
+ IF vClientType = 'loses' THEN
+ SET vStateCode = 'DELIVERED';
+ ELSE
+ SET vStateCode = 'FREE';
+ END IF;
+
+ CALL ticket_setState(NEW.id, vStateCode);
+
+ IF YEAR(NEW.shipped) > 2000 THEN
+
+ SELECT cnb.firstShipped INTO vTransferorFirstShipped
+ FROM bs.clientNewBorn cnb
+ JOIN `client` c ON c.transferorFk = cnb.clientFk
+ WHERE c.id = NEW.clientFk;
+
+ INSERT INTO bs.clientNewBorn(clientFk, firstShipped, lastShipped)
+ VALUES(NEW.clientFk, IFNULL(vTransferorFirstShipped, util.VN_CURDATE()), util.VN_CURDATE())
+ ON DUPLICATE KEY UPDATE lastShipped = util.VN_CURDATE();
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeUpdate`
+ BEFORE UPDATE ON `ticket`
+ FOR EACH ROW
+BEGIN
+ DECLARE vNewTime TIME;
+ DECLARE vHasTicketRefund BOOL;
+
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.route r
+ WHERE r.isOk = FALSE
+ AND r.id IN (OLD.routeFk,NEW.routeFk)
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ END IF;
+
+ IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
+ IF YEAR(NEW.shipped) < 2000 THEN
+ SIGNAL SQLSTATE '46000'
+ SET MESSAGE_TEXT = 'Year cannot be lesser than 2000';
+ END IF;
+
+ IF YEAR(NEW.shipped) = 2000 THEN
+ SET NEW.isDeleted = TRUE;
+ END IF;
+
+ END IF;
+
+ IF NOT (NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.ticket t
+ JOIN vn.route r ON r.id = t.routeFk
+ WHERE r.isOk = FALSE
+ AND t.id = NEW.id
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+ SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T');
+ SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T');
+ SET NEW.routeFk = NULL;
+ SET NEW.zoneFk = NULL;
+ END IF;
+
+ IF NEW.routeFk AND NEW.isDeleted THEN
+ CALL util.throw ('This ticket is deleted');
+ END IF;
+
+ IF NOT (NEW.routeFk <=> OLD.routeFk) AND NEW.routeFk IS NOT NULL THEN
+ SELECT MAX(TIME(shipped)) INTO vNewTime
+ FROM vn.ticket
+ WHERE routeFk = NEW.routeFk
+ HAVING MAX(TIME(shipped)) > TIME(NEW.shipped);
+
+ IF vNewTime THEN
+ SET NEW.shipped = TIMESTAMP(DATE(NEW.shipped), vNewTime);
+ END IF;
+ INSERT IGNORE INTO zoneAgencyMode (agencyModeFk,zoneFk)
+ SELECT r.agencyModeFk, NEW.zoneFk FROM route r
+ WHERE r.id = NEW.routeFk;
+
+ CALL vn.routeUpdateM3(NEW.routeFk);
+ END IF;
+
+ SELECT COUNT(*) INTO vHasTicketRefund
+ FROM ticketRefund
+ WHERE originalTicketFk = NEW.id
+ OR refundTicketFk = NEW.id;
+
+ IF vHasTicketRefund AND NEW.clientFk <> OLD.clientFk THEN
+ CALL util.throw('The ticket has a refund associated');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterUpdate`
+ AFTER UPDATE ON `ticket`
+ FOR EACH ROW
+BEGIN
+
+ IF !(NEW.id <=> OLD.id)
+ OR !(NEW.warehouseFk <=> OLD.warehouseFk)
+ OR !(NEW.shipped <=> OLD.shipped) THEN
+ CALL stock.log_add('ticket', NEW.id, OLD.id);
+ END IF;
+
+ IF !(NEW.clientFk <=> OLD.clientFk)
+ OR !(NEW.addressFk <=> OLD.addressFk)
+ OR !(NEW.companyFk <=> OLD.companyFk) THEN
+ CALL ticket_requestRecalc(NEW.id);
+ END IF;
+
+ IF NEW.routeFk <> OLD.routeFk THEN
+ UPDATE expedition
+ SET hasNewRoute = TRUE
+ WHERE ticketFk = NEW.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeDelete`
+ BEFORE DELETE ON `ticket`
+ FOR EACH ROW
+BEGIN
+ INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
+ SELECT r.id
+ FROM vn.route r
+ WHERE r.isOk = FALSE
+ AND r.id = OLD.routeFk
+ AND r.created >= util.VN_CURDATE()
+ GROUP BY r.id;
+
+ DELETE FROM sale WHERE ticketFk = OLD.id;
+
+ DELETE FROM ticketDms WHERE ticketFk = OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterDelete`
+ AFTER DELETE ON `ticket`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'Ticket',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER ticketCollection_afterDelete
+AFTER DELETE
+ON ticketCollection FOR EACH ROW
+BEGIN
+
+ DECLARE vSalesRemaining INT;
+
+ SELECT count(*) INTO vSalesRemaining
+ FROM vn.ticketCollection tc
+ JOIN sale s ON s.ticketFk = tc.ticketFk
+ WHERE collectionFk = OLD.collectionFk
+ AND tc.id != OLD.id;
+
+ IF NOT vSalesRemaining THEN
+
+ DELETE FROM vn.collection WHERE id = OLD.collectionFk;
+
+ ELSE
+
+ UPDATE vn.collection
+ SET saleTotalCount = vSalesRemaining
+ WHERE id = OLD.collectionFk;
+
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeInsert`
+ BEFORE INSERT ON `ticketDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeUpdate`
+ BEFORE UPDATE ON `ticketDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeDelete`
+ BEFORE DELETE ON `ticketDms`
+ FOR EACH ROW
+BEGIN
+ UPDATE dms
+ SET dmsTypeFk = (SELECT id
+ FROM dmsType
+ WHERE `code` = 'trash'
+ )
+ WHERE id = OLD.dmsFk AND ( SELECT IF(COUNT(*) > 0, FALSE, TRUE)
+ FROM ticketDms
+ WHERE dmsFk = OLD.dmsFk
+ ) ;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_afterDelete`
+ AFTER DELETE ON `ticketDms`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'ticketDms',
+ `changedModelId` = OLD.ticketFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeInsert`
+ BEFORE INSERT ON `ticketObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeUpdate`
+ BEFORE UPDATE ON `ticketObservation`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_afterDelete`
+ AFTER DELETE ON `ticketObservation`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketObservation',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_BEFORE_INSERT`
+ BEFORE INSERT ON `ticketPackaging`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.workerFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeUpdate`
+ BEFORE UPDATE ON `ticketPackaging`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_afterDelete`
+ AFTER DELETE ON `ticketPackaging`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketPackaging',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketParking_BEFORE_INSERT`
+ BEFORE INSERT ON `ticketParking`
+ FOR EACH ROW
+BEGIN
+
+ SET NEW.workerFk = 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeInsert`
+ BEFORE INSERT ON `ticketRefund`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeUpdate`
+ BEFORE UPDATE ON `ticketRefund`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_afterDelete`
+ AFTER DELETE ON `ticketRefund`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketRefund',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeInsert`
+ BEFORE INSERT ON `ticketRequest`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.ticketFk IS NULL THEN
+ SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk);
+ END IF;
+
+ IF NEW.requesterFk IS NULL THEN
+ SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode);
+ END IF;
+
+ IF NEW.attenderFk IS NULL THEN
+ SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeUpdate`
+ BEFORE UPDATE ON `ticketRequest`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.saleFk <> OLD.saleFk THEN
+ SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk);
+ END IF;
+
+ IF NEW.salesPersonCode <> OLD.salesPersonCode THEN
+ SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode);
+ END IF;
+
+ IF NEW.buyerCode <> OLD.buyerCode THEN
+ SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_afterDelete`
+ AFTER DELETE ON `ticketRequest`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketRequest',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeInsert`
+ BEFORE INSERT ON `ticketService`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_ai`
+ AFTER INSERT ON `ticketService`
+ FOR EACH ROW
+BEGIN
+
+ CALL ticket_requestRecalc(NEW.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeUpdate`
+ BEFORE UPDATE ON `ticketService`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_au`
+ AFTER UPDATE ON `ticketService`
+ FOR EACH ROW
+BEGIN
+ IF !(NEW.price <=> OLD.price)
+ OR !(NEW.ticketFk <=> OLD.ticketFk)
+ OR !(NEW.quantity <=> OLD.quantity) THEN
+ CALL ticket_requestRecalc(NEW.ticketFk);
+ CALL ticket_requestRecalc(OLD.ticketFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_ad`
+ AFTER DELETE ON `ticketService`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketService',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL ticket_requestRecalc(OLD.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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeInsert`
+ BEFORE INSERT ON `ticketTracking`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterInsert`
+ AFTER INSERT ON `ticketTracking`
+ FOR EACH ROW
+BEGIN
+ DECLARE vNumTicketsPrepared INT;
+
+ REPLACE vn.ticketLastState(ticketFk, ticketTrackingFk, name)
+ SELECT NEW.ticketFk, NEW.id, `name`
+ FROM state
+ WHERE id = NEW.stateFk;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeUpdate`
+ BEFORE UPDATE ON `ticketTracking`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterUpdate`
+ AFTER UPDATE ON `ticketTracking`
+ FOR EACH ROW
+BEGIN
+ DECLARE vTicketFk INT;
+ DECLARE vTicketTrackingFk INT;
+ DECLARE vStateName VARCHAR(15);
+
+ IF NEW.stateFk <> OLD.stateFk THEN
+ REPLACE vn.ticketLastState(ticketFk, ticketTrackingFk, name)
+ SELECT NEW.ticketFk, NEW.id, `name`
+ FROM state
+ WHERE id = NEW.stateFk;
+ END IF;
+
+ IF NEW.ticketFk <> OLD.ticketFk THEN
+ SELECT i.ticketFk, i.id, s.`name`
+ INTO vTicketFk, vTicketTrackingFk, vStateName
+ FROM ticketTracking i
+ JOIN state s ON i.stateFk = s.id
+ WHERE ticketFk = NEW.ticketFk
+ ORDER BY created DESC
+ LIMIT 1;
+
+ IF vTicketFk > 0 THEN
+ REPLACE INTO ticketLastState(ticketFk, ticketTrackingFk,name)
+ VALUES(vTicketFk, vTicketTrackingFk, vStateName);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterDelete`
+ AFTER DELETE ON `ticketTracking`
+ FOR EACH ROW
+BEGIN
+ DECLARE vTicketFk INT;
+ DECLARE vTicketTrackingFk INT;
+ DECLARE vStateName VARCHAR(15);
+
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '23000'
+ BEGIN
+ DELETE FROM vn.ticketLastState
+ WHERE ticketFk = OLD.ticketFk;
+ END;
+
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketTracking',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+
+ CALL util.debugAdd('deletedState',
+ CONCAT('interFk: ', OLD.id,
+ ' ticketFk: ', OLD.ticketFk,
+ ' stateFk: ', OLD.stateFk));
+
+ SELECT i.ticketFk, i.id, s.`name`
+ INTO vTicketFk, vTicketTrackingFk, vStateName
+ FROM ticketTracking i
+ JOIN state s ON i.stateFk = s.id
+ WHERE ticketFk = OLD.ticketFk
+ ORDER BY created DESC
+ LIMIT 1;
+
+ IF vTicketFk > 0 THEN
+ REPLACE INTO ticketLastState(ticketFk, ticketTrackingFk,name)
+ VALUES(vTicketFk, vTicketTrackingFk, vStateName);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeInsert`
+ BEFORE INSERT ON `ticketWeekly`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeUpdate`
+ BEFORE UPDATE ON `ticketWeekly`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_afterDelete`
+ AFTER DELETE ON `ticketWeekly`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'TicketWeekly',
+ `changedModelId` = OLD.ticketFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`time_AFTER_UPDATE`
+ AFTER UPDATE ON `time`
+ FOR EACH ROW
+BEGIN
+ /*INSERT INTO vn.mail SET
+ `sender` = 'jgallego@verdnatura.es',
+ `replyTo` = 'jgallego@verdnatura.es',
+ `subject` = 'tabla time modificada',
+ `body` = CONCAT(account.myUser_getName(), ' ha modificado la tabla time ',
+ NEW.`dated`);*/
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeInsert`
+ BEFORE INSERT ON `town`
+ FOR EACH ROW
+BEGIN
+ SET NEW.geoFk = zoneGeo_new('town', NEW.`name`,
+ (SELECT geoFk FROM province WHERE id = NEW.provinceFk));
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeUpdate`
+ BEFORE UPDATE ON `town`
+ FOR EACH ROW
+BEGIN
+ -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
+ -- CALL zoneGeo_throwNotEditable;
+ -- 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterUpdate`
+ AFTER UPDATE ON `town`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.provinceFk <=> NEW.provinceFk) THEN
+ CALL zoneGeo_setParent(NEW.geoFk,
+ (SELECT geoFk FROM province WHERE id = NEW.provinceFk));
+ END IF;
+
+ IF !(OLD.`name` <=> NEW.`name`) THEN
+ UPDATE zoneGeo SET `name` = NEW.`name`
+ WHERE id = NEW.geoFk;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterDelete`
+ AFTER DELETE ON `town`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_delete(OLD.geoFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeInsert`
+ BEFORE INSERT ON `travel`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+
+ CALL travel_checkDates(NEW.shipped, NEW.landed);
+
+ CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeUpdate`
+ BEFORE UPDATE ON `travel`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+/*
+ IF ((NOT NEW.shipped <=> OLD.shipped )
+ OR (NOT NEW.landed <=> OLD.landed )
+ OR (NOT NEW.warehouseInFk <=> OLD.warehouseInFk )
+ OR (NOT NEW.warehouseOutFk <=> OLD.warehouseOutFk ))
+ AND (OLD.totalEntries AND OLD.landed < CURDATE()) THEN
+ CALL util.throw("Cannot past travels with entries");
+ END IF;
+*/
+ IF NOT (NEW.landed <=> OLD.landed)
+ OR NOT (NEW.shipped <=> OLD.shipped) THEN
+ CALL travel_checkDates(NEW.shipped, NEW.landed);
+ END IF;
+
+ IF NOT (NEW.isReceived <=> OLD.isReceived) THEN
+ CALL travel_checkPackaging(NEW.id);
+ END IF;
+
+ IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
+ CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterUpdate`
+ AFTER UPDATE ON `travel`
+ FOR EACH ROW
+BEGIN
+ CALL stock.log_add('travel', NEW.id, OLD.id);
+
+ IF !(NEW.shipped <=> OLD.shipped) THEN
+ UPDATE entry
+ SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
+ WHERE travelFk = NEW.id;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterDelete`
+ AFTER DELETE ON `travel`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO travelLog
+ SET `action` = 'delete',
+ `changedModel` = 'Travel',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeInsert`
+ BEFORE INSERT ON `travelThermograph`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeUpdate`
+ BEFORE UPDATE ON `travelThermograph`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_afterDelete`
+ AFTER DELETE ON `travelThermograph`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO travelLog
+ SET `action` = 'delete',
+ `changedModel` = 'TravelThermograph',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeInsert`
+ BEFORE INSERT ON `vehicle`
+ FOR EACH ROW
+BEGIN
+ CALL vehicle_checkNumberPlate(NEW.numberPlate, NEW.countryCodeFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeUpdate`
+ BEFORE UPDATE ON `vehicle`
+ FOR EACH ROW
+BEGIN
+ CALL vehicle_checkNumberPlate(NEW.numberPlate, NEW.countryCodeFk);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`warehouse_afterInsert`
+ BEFORE UPDATE ON `warehouse`
+ FOR EACH ROW
+BEGIN
+ IF NEW.isFeedStock AND NEW.isInventory THEN
+ CALL util.throw("isFeedStock and isInventory cannot both be true");
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`warehouse_afterUpdate`
+ AFTER UPDATE ON `warehouse`
+ FOR EACH ROW
+BEGIN
+ IF NEW.isFeedStock IS TRUE AND OLD.isFeedStock IS FALSE THEN
+ INSERT IGNORE INTO warehouseAlias(`name`) VALUES(NEW.`name`);
+ INSERT IGNORE INTO warehouseJoined(warehouseFk, warehouseAliasFk)
+ VALUES(NEW.id,LAST_INSERT_ID());
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeInsert`
+ BEFORE INSERT ON `worker`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeUpdate`
+ BEFORE UPDATE ON `worker`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_afterDelete`
+ AFTER DELETE ON `worker`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO workerLog
+ SET `action` = 'delete',
+ `changedModel` = 'Worker',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeInsert`
+ BEFORE INSERT ON `workerDocument`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeUpdate`
+ BEFORE UPDATE ON `workerDocument`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_afterDelete`
+ AFTER DELETE ON `workerDocument`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO workerLog
+ SET `action` = 'delete',
+ `changedModel` = 'WorkerDocument',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterInsert`
+ AFTER INSERT ON `workerIncome`
+ FOR EACH ROW
+BEGIN
+ CALL worker_updateBalance(NEW.workerFk,NEW.credit,NEW.debit);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterUpdate`
+ AFTER UPDATE ON `workerIncome`
+ FOR EACH ROW
+BEGIN
+ CALL worker_updateBalance(NEW.workerFk,-OLD.credit,-OLD.debit);
+
+ CALL worker_updateBalance(NEW.workerFk,NEW.credit,NEW.debit);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterDelete`
+ AFTER DELETE ON `workerIncome`
+ FOR EACH ROW
+BEGIN
+ CALL worker_updateBalance(OLD.workerFk,-OLD.credit,-OLD.debit);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_AI`
+ AFTER INSERT ON `workerTimeControl`
+ FOR EACH ROW
+BEGIN
+ IF NEW.timed > DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY) THEN
+ CALL util.throw('date in the future');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workingHoursBeforeInsert`
+ BEFORE INSERT ON `workingHours`
+ FOR EACH ROW
+BEGIN
+ IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = util.VN_CURDATE()) > 0 THEN
+ CALL util.throw ('ALREADY_LOGGED');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeInsert`
+ BEFORE INSERT ON `zone`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeUpdate`
+ BEFORE UPDATE ON `zone`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_afterDelete`
+ AFTER DELETE ON `zone`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO zoneLog
+ SET `action` = 'delete',
+ `changedModel` = 'Zone',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeInsert`
+ BEFORE INSERT ON `zoneEvent`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeUpdate`
+ BEFORE UPDATE ON `zoneEvent`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_afterDelete`
+ AFTER DELETE ON `zoneEvent`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO zoneLog
+ SET `action` = 'delete',
+ `changedModel` = 'zoneEvent',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_BI`
+ BEFORE INSERT ON `zoneExclusion`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.userFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_BU`
+ BEFORE UPDATE ON `zoneExclusion`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+ SET NEW.userFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_afterDelete`
+ AFTER DELETE ON `zoneExclusion`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO zoneLog
+ SET `action` = 'delete',
+ `changedModel` = 'zoneExclusion',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeInsert`
+ BEFORE INSERT ON `zoneGeo`
+ FOR EACH ROW
+BEGIN
+ CALL zoneGeo_checkName(NEW.`name`);
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeUpdate`
+ BEFORE UPDATE ON `zoneGeo`
+ FOR EACH ROW
+BEGIN
+ IF !(OLD.`name` <=> NEW.`name`) THEN
+ CALL zoneGeo_checkName(NEW.`name`);
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeInsert`
+ BEFORE INSERT ON `zoneIncluded`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeUpdate`
+ BEFORE UPDATE ON `zoneIncluded`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_afterDelete`
+ AFTER DELETE ON `zoneIncluded`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO zoneLog
+ SET `action` = 'delete',
+ `changedModel` = 'zoneIncluded',
+ `changedModelId` = OLD.zoneFk,
+ `userFk` = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeInsert`
+ BEFORE INSERT ON `zoneWarehouse`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeUpdate`
+ BEFORE UPDATE ON `zoneWarehouse`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = 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 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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_afterDelete`
+ AFTER DELETE ON `zoneWarehouse`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO zoneLog
+ SET `action` = 'delete',
+ `changedModel` = 'ZoneWarehouse',
+ `changedModelId` = OLD.id,
+ `userFk` = 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 */ ;
+
+--
+-- Current Database: `vn2008`
+--
+
+USE `vn2008`;
+/*!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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`Conteo_ai`
+ AFTER INSERT ON `Conteo`
+ FOR EACH ROW
+BEGIN
+ DECLARE intTravel INTEGER;
+ SELECT t.id INTO intTravel FROM Compres c JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
+ JOIN travel t ON t.id = e.travel_id
+ WHERE landing = util.VN_CURDATE() AND c.Id_Article = NEW.Id_Article AND warehouse_id = NEW.warehouse_id AND received <> TRUE LIMIT 1;
+ IF (intTravel) then
+ UPDATE travel SET received = TRUE WHERE id = intTravel;
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`account_conciliacion_BEFORE_INSERT`
+ BEFORE INSERT ON `account_conciliacion`
+ FOR EACH ROW
+set new.id_calculated = replace(
+ replace(
+ replace(
+ replace(
+ concat(new.Id_Proveedores_account,new.Fechaoperacion,new.importe,new.Concepto,new.DebeHaber)
+ ,' ','')
+ ,":",'')
+ ,'-','')
+ ,'.','') */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`agency_hourBeforeInsert`
+ BEFORE INSERT ON `agency_hour`
+ FOR EACH ROW
+BEGIN
+ DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
+ IF NEW.week_day IS NULL AND NEW.province_id IS NULL AND NEW.subtract_day = 0 AND NEW.max_hour = 0 THEN
+ CALL util.throw ('FILL_MORE_FIELDS');
+ END IF;
+
+ SELECT COUNT(*) INTO vAlreadyExists
+ FROM vn2008.agency_hour
+ WHERE NEW.week_day <=> week_day AND NEW.province_id <=> province_id
+ AND NEW.warehouse_id <=> warehouse_id AND NEW.max_hour <=> max_hour
+ AND NEW.agency_id <=> agency_id;
+
+ IF vAlreadyExists > 1 THEN
+ CALL util.throw('ALREADY_EXISTS');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`agency_hour_AFTER_UPDATE`
+ AFTER UPDATE ON `agency_hour`
+ FOR EACH ROW
+BEGIN
+DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
+
+ SELECT COUNT(*) INTO vAlreadyExists
+ FROM vn2008.agency_hour
+ WHERE NEW.week_day <=> week_day AND NEW.province_id <=> province_id
+ AND NEW.warehouse_id <=> warehouse_id AND NEW.max_hour <=> max_hour
+ AND NEW.agency_id <=> agency_id;
+
+ IF vAlreadyExists > 1 THEN
+ CALL util.throw('ALREADY_EXISTS');
+ 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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`awb_recibida_ad`
+ AFTER DELETE ON `awb_recibida`
+ FOR EACH ROW
+IF (SELECT COUNT(*) FROM recibida_iva where recibida_id = OLD.recibida_id) = 0
+ AND
+ (SELECT COUNT(*) FROM recibida_vencimiento where recibida_id = OLD.recibida_id) = 0
+ AND
+ (SELECT contabilizada FROM recibida WHERE id = OLD.recibida_id) = 0
+THEN
+ DELETE FROM recibida WHERE id = OLD.recibida_id;
+END IF */;;
+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_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 ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`movement_label_au`
+ AFTER UPDATE ON `movement_label`
+ FOR EACH ROW
+-- Edit trigger body code below this line. Do not edit lines above this one
+IF NEW.stem >= (SELECT Cantidad FROM Movimientos WHERE Id_Movimiento = NEW.Id_Movimiento) THEN
+ UPDATE Movimientos SET OK = 1 WHERE Id_Movimiento = NEW.Id_Movimiento;
+END IF */;;
+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 */ ;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-01-25 16:24:46
diff --git a/db/dump/Dockerfile b/db/dump/Dockerfile
index 72bcf54d5..91d0fde2c 100644
--- a/db/dump/Dockerfile
+++ b/db/dump/Dockerfile
@@ -1,4 +1,4 @@
-FROM mariadb:10.7.7
+FROM mariadb:10.11.6
ENV TZ Europe/Madrid
diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql
index 0f0edef86..d5eec544f 100644
--- a/db/dump/fixtures.after.sql
+++ b/db/dump/fixtures.after.sql
@@ -15,8 +15,8 @@ INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, max
-- XXX: eti
-INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,agencyFk,`ref`,m3,kg,cargoSupplierFk)
- VALUES (9,'2022-05-20','2022-05-20',13,4,1,'nine travel',69.0,600,1);
+INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,`ref`,m3,kg,cargoSupplierFk)
+ VALUES (9,'2022-05-20','2022-05-20',13,4,'nine travel',69.0,600,1);
INSERT INTO vn.entry (id, supplierFk, dated, invoiceNumber, evaNotes, travelFk, companyFk)
VALUES
@@ -25,9 +25,9 @@ INSERT INTO vn.entry (id, supplierFk, dated, invoiceNumber, evaNotes, travelFk,
INSERT INTO vn.buy (id,entryFk,itemFk,quantity,dispatched,buyingValue,freightValue,isIgnored,stickers,packing,`grouping`,groupingMode,comissionValue,packageValue,packagingFk,price1,price2,price3,minPrice,printedStickers,workerFk,isChecked,isPickedOff,created,`__cm2`,weight)
VALUES
- (16,8,1,100,0,50.0,1.5,0,1,1,1,0,0.0,1.5,'4',0.0,99.6,99.4,0.0,0,0,1,0,'2022-06-20 00:00:00',0,1.0),
- (17,9,2,450,0,5.0,1.0,0,1,10,10,0,0.0,1.0,'3',0.0,7.3,7.0,0.0,0,0,1,0,'2022-06-20 00:00:00',0,2.5),
- (18,9,15,500,0,55.0,1.0,0,1,1,1,0,0.0,1.0,'5',0.0,78.3,75.6,0.0,0,0,1,0,'2022-06-20 00:00:00',0,2.5),
+ (16,10,1,100,0,50.0,1.5,0,1,1,1,0,0.0,1.5,'4',0.0,99.6,99.4,0.0,0,0,1,0,'2022-06-20 00:00:00',0,1.0),
+ (17,10,2,450,0,5.0,1.0,0,1,10,10,0,0.0,1.0,'3',0.0,7.3,7.0,0.0,0,0,1,0,'2022-06-20 00:00:00',0,2.5),
+ (18,10,15,500,0,55.0,1.0,0,1,1,1,0,0.0,1.0,'5',0.0,78.3,75.6,0.0,0,0,1,0,'2022-06-20 00:00:00',0,2.5),
(19,10,11,5000,0,50.0,1.0,0,1,1,1,1,0.0,1.0,'4',0.0,99.6,99.4,0.0,0,0,1,0,'2022-06-20 00:00:00',0,2.5);
INSERT INTO vn2008.Splits (Id_Split,Id_Ticket,Id_Entrada,Fecha,Notas)
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index 9894275a3..6a58b60f5 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -6,6 +6,10 @@
*/
SET foreign_key_checks = 0;
+-- CREATE ROLE 'salix';
+-- GRANT 'salix' TO 'root'@'%';
+-- SET DEFAULT ROLE 'salix' FOR 'root'@'%';
+
CREATE SCHEMA IF NOT EXISTS `vn2008`;
CREATE SCHEMA IF NOT EXISTS `tmp`;
@@ -91,18 +95,17 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
(2, 'ENSEÑANZAS DE BACHILLERATO');
-INSERT INTO `vn`.`worker`
- SET `id` = 9,
- `code` = 009,
- `firstName` = 'developer',
- `lastName` = 'developer',
- `bossFk` = 9;
+INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
+ SELECT id,UPPER(LPAD(role, 3, '0')), name, name, NULL
+ FROM `account`.`user`
+ WHERE `id` = 9;
-INSERT IGNORE INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
+INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
- FROM `account`.`user`;
+ FROM `account`.`user`
+ WHERE `id` <> 9;
-UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 20;
+UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18;
@@ -175,51 +178,33 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
(1, 'Main Warehouse'),
(2, 'Gotham');
-INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`, isOrigin, isDestiny)
+INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
VALUES
- (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1),
- (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1, 1, 0),
- (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1, 1, 0),
- (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1, 0, 1),
- (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1, 0, 0),
- (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0, 0, 0),
- (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0, 0, 0);
+ (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1),
+ (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1),
+ (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
+ (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
+INSERT INTO `vn`.`sectorType` (id,description)
+ VALUES (1,'First type');
-INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`)
+INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`, `typeFk`)
VALUES
- (1, 'First sector', 1, 'FIRST'),
- (2, 'Second sector', 2, 'SECOND');
+ (1, 'First sector', 1, 'FIRST', 1),
+ (2, 'Second sector', 2, 'SECOND',1);
-INSERT INTO vn.printerModel (code)
- VALUES ('pcode1'),
- ('pcode2');
-
-INSERT INTO vn.screenModel (code)
- VALUES ('scode1'),
- ('scode2');
-
-INSERT INTO vn.screen (name,modelFk)
- VALUES ('screen1','scode1'),
- ('screen1','scode2');
-
-INSERT INTO vn.scannerModel (code)
- VALUES ('sscode1'),
- ('sscode2');
-
-INSERT INTO vn.scanner (name,modelFk)
- VALUES ('scanner1','sscode1'),
- ('scanner2','sscode2');
-
-
-INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `modelFk`, `isLabeler`, `sectorFk`, `ipAddress`)
+INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`)
VALUES
- (1, 'printer1', 'path1','pcode1', 0, 1 , NULL),
- (2, 'printer2', 'path2','pcode1', 1, 1 , NULL),
- (4, 'printer4', 'path4','pcode2', 0, 1, '10.1.10.4');
+ (1, 'printer1', 'path1', 0, 1 , NULL),
+ (2, 'printer2', 'path2', 1, 1 , NULL),
+ (4, 'printer4', 'path4', 0, NULL, '10.1.10.4');
UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
+
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
VALUES
(1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
@@ -390,20 +375,20 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
(4, 'GCN Channel'),
(5, 'The Newspaper');
-INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`)
+INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`)
VALUES
- (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'),
- (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'),
- (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others'),
- (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others');
+ (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
+ (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
+ (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
+ (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
+ (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
+ (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
+ (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
+ (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
+ (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'),
+ (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'),
+ (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'),
+ (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses');
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
@@ -437,7 +422,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
(6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
(7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
- (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
+ (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
(9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
(10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
(11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
@@ -469,7 +454,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
(126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
(127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
- (128, 'Cerebro', 'address 28', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
+ (128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
(129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
(130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
@@ -502,7 +487,24 @@ CREATE TEMPORARY TABLE tmp.address
WHERE `defaultAddressFk` IS NULL;
DROP TEMPORARY TABLE tmp.address;
-INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
+INSERT INTO `vn`.`clientCredit`(`clientFk`, `workerFk`, `amount`, `created`)
+ VALUES
+ (1101, 5, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 MONTH)),
+ (1101, 5, 900, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 MONTH)),
+ (1101, 5, 800, DATE_ADD(util.VN_CURDATE(), INTERVAL -9 MONTH)),
+ (1101, 5, 700, DATE_ADD(util.VN_CURDATE(), INTERVAL -8 MONTH)),
+ (1101, 5, 600, DATE_ADD(util.VN_CURDATE(), INTERVAL -7 MONTH)),
+ (1101, 5, 500, DATE_ADD(util.VN_CURDATE(), INTERVAL -6 MONTH)),
+ (1101, 5, 400, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 MONTH)),
+ (1101, 9, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (1101, 9, 200, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (1101, 9, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (1101, 9, 50 , DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (1102, 9, 800, util.VN_CURDATE()),
+ (1104, 9, 90 , util.VN_CURDATE()),
+ (1105, 9, 90 , util.VN_CURDATE());
+
+INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`)
VALUES
(1, 9999999, 20),
(2, 10000, 21),
@@ -609,20 +611,24 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`
('NATIONAL', 0, 1),
('WORLD', 2, 15);
+INSERT INTO vn.invoiceOutConfig
+ SET parallelism = 8;
+
INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
VALUES
- ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
- ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
- ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
- ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
- ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
+ ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
+ ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
+ ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
+ ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
+ ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL),
+ ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
VALUES
- (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
(2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
(3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
- (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
(5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0);
UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1;
@@ -631,30 +637,6 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3;
UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
-
-INSERT INTO vn.siiTrascendencyInvoiceOut (id, description)
- VALUES
- (1, 'Operación de régimen general'),
- (2, 'Exportación'),
- (3, 'Operaciones a las que se aplique el régimen especial de bienes usados, objetos de arte, antigüedades y objetos de colección (135 - 139 de LIVA)'),
- (4, 'Régimen especial oro de inversión'),
- (5, 'Régimen especial agencias de viajes'),
- (6, 'Régimen especial grupo de entidades en IVA (Nivel Avanzado)'),
- (7, 'Régimen especial criterio de caja'),
- (8, 'Operaciones sujetas al IPSI / IGIC'),
- (9, 'Facturación de las prestaciones de servicios de agencias de viaje que actúan como mediadoras en nombre y por cuenta ajena (D.A.4ª RD 1619/2012)'),
- (10, 'Cobros por cuenta de terceros de honorarios profesionales o de Dº derivados de la propiedad industrial, de autor u otros por cuenta de sus socios, asociados,colegiados efectuados por sociedades, asociaciones, colegios profesionales u otras entidades '),
- (11, 'Operaciones de arrendamiento de local de negocio sujetas a retención'),
- (12, 'Operaciones de arrendamiento de local de negocio no sujetos a retención'),
- (13, 'Operaciones de arrendamiento de local de negocio sujetas y no sujetas a retención'),
- (14, 'Factura con IVA pendiente de devengo (certificaciones de obra cuyo destinatario sea una Administración Pública)'),
- (15, 'Factura con IVA pendiente de devengo - operaciones de tracto sucesivo'),
- (16, 'Primer semestre 2017');
-
-
-INSERT INTO vn.invoiceOutConfig
- SET parallelism = 8;
-
INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
VALUES
(1, 895.76, 89.58, 4722000010),
@@ -688,19 +670,20 @@ INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`)
VALUES
- (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
- (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
+ (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
+ (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
(3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
(4, 'Zone 247 B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
(5, 'Zone expensive A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
(6, 'Zone expensive B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
- (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100),
- (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100),
- (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100),
- (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100),
- (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
- (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100),
- (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100);
+ (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 1, 0, 100),
+ (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 1, 0, 100),
+ (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 1, 0, 100),
+ (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 1, 0, 100),
+ (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
+ (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 1, 0, 100),
+ (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 1, 0, 100);
+
INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`)
VALUES
@@ -748,38 +731,38 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`)
VALUES
- (1 , 3, 1, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
- (2 , 1, 1, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
- (3 , 1, 7, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
- (4 , 3, 2, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL),
- (5 , 3, 3, 3, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL),
- (6 , 1, 3, 3, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
- (7 , NULL, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (8 , NULL, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (9 , NULL, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (10, 1, 1, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (11, 1, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (12, 1, 8, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (13, 1, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
+ (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
+ (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
+ (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL),
+ (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL),
+ (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
+ (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
(14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL),
- (15, 1, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (16, 1, 7, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (17, 1, 7, 2, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (18, 1, 4, 4, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL),
+ (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL),
(19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL),
- (20, 1, 5, 5, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (21, NULL, 5, 5, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (22, NULL, 5, 5, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (23, NULL, 8, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
- (24 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
+ (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
+ (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
(25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
(26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (28, 1, 8, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (29, 1, 8, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (30, 1, 8, 1, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (31, 1, 8, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (32, 1, 8, 1, NULL, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL);
+ (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL);
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
@@ -801,7 +784,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
-- FIX for state hours on local, inter_afterInsert
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
-INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
+INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
VALUES
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
(2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
@@ -845,6 +828,7 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
VALUES
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
+
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
VALUES
(1, 'Diff', 'diff'),
@@ -907,7 +891,9 @@ INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
('SLV', 'Silver', 1, 4, 'CACFD2'),
('BRW', 'Brown', 1, 5, 'DC7633'),
('BLK', 'Black', 1, 6, '000000'),
- ('BAS', 'Blue/Silver', 1, 7, '5DADE2');
+ ('BAS', 'Blue/Silver', 1, 7, '5DADE2'),
+ ('GRN', 'Green', 1, 8, '28A745'),
+ ('WHT', 'White', 1, 9, 'FFFFFF');
INSERT INTO `vn`.`origin`(`id`,`code`, `name`)
VALUES
@@ -954,26 +940,26 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
('SER', 'Services'),
('VT', 'Sales');
-INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
- `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
+INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
+ `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
VALUES
- (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3),
- (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2),
- (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5),
- (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
- (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL,NULL),
- (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
- (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
- (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
- (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
+ (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 15,3),
+ (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 10,2),
+ (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5,5),
+ (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
+ (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
+ (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL,NULL),
+ (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
+ (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
+ (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
+ (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
-- Update the taxClass after insert of the items
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
@@ -1000,6 +986,10 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack
('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00),
('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00);
+INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`)
+ VALUES
+ ('10', 1, 'pallet 100');
+
INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
VALUES
(1, 'En reparto', 'ON DELIVERY'),
@@ -1041,45 +1031,45 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`,
INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`)
VALUES
- (1, 1, 1, 'Ranged weapon longbow 2m', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
(2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3, 1, 1, 'Ranged weapon longbow 2m', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, util.VN_CURDATE()),
- (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
- (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()),
+ (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
+ (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
- (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, util.VN_CURDATE()),
+ (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()),
(13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()),
- (14, 1, 8, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (15, 1, 19, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
(16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()),
(17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (19, 1, 4, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
- (20, 1, 5, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
- (21, 1, 6, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (22, 1, 7, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (23, 1, 9, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (24, 1, 10, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (25, 4, 12, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (26, 4, 13, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (27, 4, 14, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (28, 4, 15, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()),
- (32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()),
(33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()),
- (34, 4, 28, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (35, 4, 29, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (37, 4, 31, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (36, 4, 30, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (39, 1, 32, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
+ (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
VALUES
@@ -1295,7 +1285,7 @@ INSERT INTO `vn`.`tag`(`id`, `code`, `name`, `isFree`, `isQuantitatif`, `sourceT
(5, NULL, 'Diámetro', 1, 1, NULL, 'mm',NULL, 'diameter'),
(7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm',NULL, NULL),
(23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems'),
- (27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, NULL),
+ (27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, 'size'),
(36, 'producer', 'Proveedor', 1, 0, NULL, NULL, NULL, 'producer'),
(56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL),
(58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL),
@@ -1306,7 +1296,7 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
VALUES
(1, 1, 56, 'Ranged weapon', 1),
(2, 1, 58, 'longbow', 2),
- (3, 1, 27, '2m', 3),
+ (3, 1, 27, '200cm', 3),
(4, 1, 36, 'Stark Industries', 4),
(5, 1, 1, 'Brown', 5),
(6, 1, 67, '+1 precission', 6),
@@ -1320,42 +1310,42 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
(14, 2, 23, '2', 7),
(15, 3, 56, 'Ranged weapon', 1),
(16, 3, 58, 'sniper rifle', 2),
- (17, 3, 4, '300mm', 3),
+ (17, 3, 4, '113cm', 3),
(18, 3, 36, 'Stark Industries', 4),
(19, 3, 1, 'Green', 5),
(20, 3, 67, 'precission', 6),
(21, 3, 23, '3', 7),
(22, 4, 56, 'Melee weapon', 1),
(23, 4, 58, 'heavy shield', 2),
- (24, 4, 4, '1x0.5m', 3),
+ (24, 4, 4, '100cm', 3),
(25, 4, 36, 'Stark Industries', 4),
(26, 4, 1, 'Black', 5),
(27, 4, 67, 'containtment', 6),
(28, 4, 23, '4', 7),
(29, 5, 56, 'Ranged weapon', 1),
(30, 5, 58, 'pistol', 2),
- (31, 5, 27, '9mm', 3),
+ (31, 5, 67, '9mm', 3),
(32, 5, 36, 'Stark Industries', 4),
(33, 5, 1, 'Silver', 5),
- (34, 5, 67, 'rapid fire', 6),
+ (34, 5, 27, '15cm', 6),
(35, 5, 23, '5', 7),
(36, 6, 56, 'Container', 1),
(37, 6, 58, 'ammo box', 2),
- (38, 6, 27, '1m', 3),
+ (38, 6, 27, '100cm', 3),
(39, 6, 36, 'Stark Industries', 4),
(40, 6, 1, 'Green', 5),
(41, 6, 67, 'supply', 6),
(42, 6, 23, '6', 7),
(43, 7, 56, 'Container', 1),
(44, 7, 58, 'medical box', 2),
- (45, 7, 27, '1m', 3),
+ (45, 7, 27, '100cm', 3),
(46, 7, 36, 'Stark Industries', 4),
(47, 7, 1, 'White', 5),
(48, 7, 67, 'supply', 6),
(49, 7, 23, '7', 7),
(50, 8, 56, 'Ranged Reinforced weapon', 1),
(51, 8, 58, '+1 longbow', 2),
- (52, 8, 27, '2m', 3),
+ (52, 8, 27, '200cm', 3),
(53, 8, 36, 'Stark Industries', 4),
(54, 8, 1, 'Brown', 5),
(55, 8, 67, 'precission', 6),
@@ -1369,14 +1359,14 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
(63, 9, 23, '9', 7),
(64, 10, 56, 'Ranged Reinforced weapon', 1),
(65, 10, 58, 'sniper rifle', 2),
- (66, 10, 4, '300mm', 3),
+ (66, 10, 67, '700mm', 3),
(67, 10, 36, 'Stark Industries', 4),
(68, 10, 1, 'Green', 5),
- (69, 10, 67, 'precission', 6),
+ (69, 10, 27, '130cm', 6),
(70, 10, 23, '10', 7),
(71, 11, 56, 'Melee Reinforced weapon', 1),
(72, 11, 58, 'heavy shield', 2),
- (73, 11, 4, '1x0.5m', 3),
+ (73, 11, 4, '120cm', 3),
(74, 11, 36, 'Stark Industries', 4),
(75, 11, 1, 'Black', 5),
(76, 11, 67, 'containtment', 6),
@@ -1386,18 +1376,18 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
(80, 12, 27, '9mm', 3),
(81, 12, 36, 'Stark Industries', 4),
(82, 12, 1, 'Silver', 5),
- (83, 12, 67, 'rapid fire', 6),
+ (83, 12, 67, '23cm', 6),
(84, 12, 23, '12', 7),
(85, 13, 56, 'Chest', 1),
(86, 13, 58, 'ammo box', 2),
- (87, 13, 27, '1m', 3),
+ (87, 13, 27, '100cm', 3),
(88, 13, 36, 'Stark Industries', 4),
(89, 13, 1, 'Green', 5),
(90, 13, 67, 'supply', 6),
(91, 13, 23, '13', 7),
(92, 14, 56, 'Chest', 1),
(93, 14, 58, 'medical box', 2),
- (94, 14, 27, '1m', 3),
+ (94, 14, 27, '100cm', 3),
(95, 14, 36, 'Stark Industries', 4),
(96, 14, 1, 'White', 5),
(97, 14, 67, 'supply', 6),
@@ -1443,23 +1433,34 @@ INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_
INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
VALUES
- (1, 0),
(2, 1),
(3, 2),
- (4, 4),
(5, 6),
(15, 6);
-INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
+INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
VALUES
- (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
- (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
- (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1),
- (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2),
- (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1),
- (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2),
- (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1),
- (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2);
+ (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
+ (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
+ (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
+ (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
+ (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
+ (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
+ (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
+ (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
+ (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
+ (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
+
+INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`)
+ VALUES
+ (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1),
+ (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2),
+ (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3),
+ (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4),
+ (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
+ (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
VALUES
@@ -1963,9 +1964,9 @@ INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`)
INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`)
VALUES
- (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
+ (1, 'Ranged weapon longbow 200cm', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
(2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
- (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()),
+ (3, 'Melee weapon heavy shield 100cm', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()),
(4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()),
(5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE());
@@ -2001,6 +2002,8 @@ INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
VALUES
(1, 'General schedule', 40, 0);
+INSERT INTO `vn`.`workerBusinessAgreement` (`id`, `name`, `monthHolidays`, `yearHours`, `started`, `ended`)
+ VALUES(1, 'flowers', 2.5, 1830, '2001-01-01', NULL);
DROP TEMPORARY TABLE IF EXISTS tmp.worker;
CREATE TEMPORARY TABLE tmp.worker
@@ -2037,6 +2040,10 @@ UPDATE `vn`.`business` b
SET b.`departmentFk` = 43
WHERE b.id IN(18, 19);
+UPDATE `vn`.`business` b
+ SET b.`started` = b.`started` - INTERVAL 100 DAY
+ WHERE b.id = 1107;
+
INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
VALUES
('1', '27.5', YEAR(util.VN_CURDATE())),
@@ -2085,22 +2092,22 @@ INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlement
INSERT INTO `vn`.`calendar` (`businessFk`, `dayOffTypeFk`, `dated`)
VALUES
- (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))),
- (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))),
- (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))),
- (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))),
- (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))),
- (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY));
+ (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)),
+ (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)),
+ (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)),
+ (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)),
+ (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)),
+ (1107, 2, util.VN_CURDATE() - INTERVAL 16 DAY);
INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
VALUES
@@ -2367,9 +2374,11 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`)
(8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'),
(10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun');
-INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`)
+INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`, `weekDays`)
VALUES
- (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR));
+ (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR), 'mon'),
+ (9, 'range', util.VN_CURDATE(), NULL, 'tue'),
+ (9, 'range', NULL, util.VN_CURDATE(), 'wed');
INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `isSendMail`)
VALUES
@@ -2382,28 +2391,28 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
(1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1),
(1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1);
-INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
+INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
VALUES
- (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'),
- (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'),
- (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'),
- (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'),
- (5, 'Otros', 'otros', 1, 1, 'miscellaneous'),
- (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'),
- (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'),
- (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'),
- (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'),
- (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'),
- (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'),
- (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'),
- (13, 'Basura', 'basura', 1, 1, 'trash'),
- (14, 'Ticket', 'tickets', 1, 1, 'ticket'),
- (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'),
- (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
- (17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
- (18, 'dua', 'dua', NULL, NULL, 'dua'),
- (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'),
- (20, 'Reclamación', 'reclamacion', 1, 1, 'claim');
+ (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
+ (2, 'Doc oficial', NULL, NULL, 'officialDoc'),
+ (3, 'Laboral', 37, 37, 'hhrrData'),
+ (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'),
+ (5, 'Otros', 1, 1, 'miscellaneous'),
+ (6, 'Pruebas', NULL, NULL, 'tests'),
+ (7, 'IAE Clientes', 1, 1, 'economicActivitiesTax'),
+ (8, 'Fiscal', NULL, NULL, 'fiscal'),
+ (9, 'Vehiculos', NULL, NULL, 'vehicles'),
+ (10, 'Plantillas', NULL, NULL, 'templates'),
+ (11, 'Contratos', NULL, NULL, 'contracts'),
+ (12, 'ley de pagos', 1, 1, 'paymentsLaw'),
+ (13, 'Basura', 1, 1, 'trash'),
+ (14, 'Ticket', 1, 1, 'ticket'),
+ (15, 'Presupuestos', NULL, NULL, 'budgets'),
+ (16, 'Logistica', NULL, NULL, 'logistics'),
+ (17, 'cmr', NULL, NULL, 'cmr'),
+ (18, 'dua', NULL, NULL, 'dua'),
+ (19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
+ (20, 'Reclamación', 1, 1, 'claim');
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
@@ -2515,20 +2524,7 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate
(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
(util.VN_CURDATE(), 1, 12, 17, 22, 27);
-INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
- VALUES
- (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
- (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
- (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
- (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
- (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
- (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
- (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
- (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
- (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
- (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
-
-INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
+INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
VALUES
(1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
(2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
@@ -2541,6 +2537,17 @@ INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried,
(9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
(10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
+INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`)
+ VALUES
+ (1, 1, 1.00, 1.00, 1.00),
+ (2, 2, 1.00, 1.00, 1.00),
+ (3, 3, 1.00, 1.00, 1.00),
+ (4, 4, 1.00, 1.00, 1.00),
+ (5, 5, 1.00, 1.00, 1.00),
+ (6, 6, 1.00, 1.00, 1.00),
+ (7, 7, 1.00, 1.00, 1.00),
+ (8, 8, 1.00, 1.00, 1.00);
+
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
VALUES
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
@@ -2788,19 +2795,17 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk
VALUES
(1, 1);
-INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`)
+INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`, `maxTimeToBreak`, `maxWorkShortCycle`, `maxWorkLongCycle`)
VALUES
- (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13, 28800, 32400);
+ (1, 43200, 32400, 129600, 259200, 1080000, '', 'imap.verdnatura.es', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.00, 0.33, 40, '22:00:00', '06:00:00', 72000, 1200, 18000, 72000, 6, 13, 28800, 32400, 3600, 561600, 950400);
INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
VALUES
(1, 'pc1', 'pc host', 1, 1);
-INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`, `printerFk`)
+INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
VALUES
- (1, 'h1', 1, '', 1);
-
-INSERT INTO vn.packingSiteLog (packingSiteFk, hostFk, workerFk, printerModelFk) VALUES('h1', '1', 1, 'pcode1');
+ (1, 'h1', 1, '');
INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
VALUES
@@ -2814,11 +2819,18 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
- (5, 'modified-entry', 'An entry has been modified');
+ (5, 'modified-entry', 'An entry has been modified'),
+ (6, 'book-entry-deleted', 'accounting entries deleted');
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
- (1, 9);
+ (1, 9),
+ (1, 1),
+ (2, 1),
+ (3, 9),
+ (4, 1),
+ (5, 9),
+ (6, 9);
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES
@@ -2830,9 +2842,12 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES
(1, 1109),
(1, 1110),
+ (2, 1110),
+ (4, 1110),
(2, 1109),
- (1,9),
- (1,3);
+ (1, 9),
+ (1, 3),
+ (6, 9);
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
@@ -2865,24 +2880,24 @@ UPDATE `account`.`user`
INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`)
VALUES
- (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL),
- (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL),
- (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL),
- (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"),
- (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 5689, 'Shield');
+ (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 22, NULL),
+ (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 22, NULL),
+ (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 22, NULL),
+ (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 100cm de '5' a '10'"),
+ (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 12, 'Shield');
INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description)
VALUES
(1, NULL, 'delete', '2001-06-09 11:00:04', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL),
(1, 18, 'select', '2001-06-09 11:00:03', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL),
- (1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 69854, 'Armor' , '{"isPicked": false}','{"isPicked": true}', NULL),
- (1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 69854, 'Armor' , NULL, NULL, 'Armor quantity changed from ''15'' to ''10'''),
- (1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 5689, 'Shield' , '{"quantity":10,"concept":"Shield"}', NULL, NULL),
- (1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 69854, 'Armor' , NULL,'{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL),
+ (1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 5, 'Armor' , '{"isPicked": false}','{"isPicked": true}', NULL),
+ (1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 5, 'Armor' , NULL, NULL, 'Armor quantity changed from ''15'' to ''10'''),
+ (1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 4, 'Shield' , '{"quantity":10,"concept":"Shield"}', NULL, NULL),
+ (1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 1, 'Armor' , NULL,'{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL),
(1, 18, 'update', '2000-12-28 08:40:45', 'Ticket', 45, 'Spider Man' , '{"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"isBlocked":false,"hasPriority":false,"companyFk":442,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}','{"warehouseFk":61,"shipped":"2023-05-17T22:00:00.000Z","nickname":"Spider Man","isSigned":false,"isLabeled":false,"isPrinted":false,"packages":1,"hour":0,"isBlocked":true,"hasPriority":true,"companyFk":443,"landed":"2023-05-18T22:00:00.000Z","isBoxed":false,"isDeleted":false,"zoneFk":713,"zonePrice":13,"zoneBonus":1}', NULL),
(1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL),
- (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 5689, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL),
+ (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 4, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL),
(1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL);
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
VALUES
@@ -2900,6 +2915,7 @@ INSERT INTO `vn`.`profileType` (`id`, `name`)
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
VALUES
('lilium', 'development', 'http://localhost:9000/#/'),
+ ('hedera', 'development', 'http://localhost:9090/'),
('salix', 'development', 'http://localhost:5000/#!/');
INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`)
@@ -2908,7 +2924,9 @@ INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`)
INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
VALUES
- (1, 1);
+ (1, 1),
+ (2, 20),
+ (7, 1);
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`)
VALUES
@@ -2916,8 +2934,7 @@ INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
VALUES
- (1, 12),
- (8, 10);
+ (24, 8);
INSERT INTO `vn`.`deviceProductionModels` (`code`)
VALUES
@@ -2934,11 +2951,11 @@ INSERT INTO `vn`.`deviceProductionState` (`code`, `description`)
('retired', 'retirada');
INSERT INTO `vn`.`deviceProduction` (`imei`, `modelFk`, `macWifi`, `serialNumber`, `android_id`, `purchased`, `stateFk`, `isInScalefusion`, `description`)
- VALUES
- ('ime1', 'BLACKVIEW', 'macWifi1', 'serialNumber1', 'androidId0000001', util.VN_NOW(), 'active', 0, NULL),
- ('ime2', 'DODGEE', 'macWifi2', 'serialNumber2', 'androidId0000002', util.VN_NOW(), 'idle', 0, NULL),
- ('ime3', 'ZEBRA', 'macWifi3', 'serialNumber3', 'androidId0000003', util.VN_NOW(), 'active', 0, NULL),
- ('ime4', 'BLACKVIEW', 'macWifi4', 'serialNumber4', 'androidId0000004', util.VN_NOW(), 'idle', 0, NULL);
+VALUES
+ ('ime1', 'BLACKVIEW', 'macWifi1', 'serialNumber1', 'androidid11234567890', util.VN_NOW(), 'active', 0, NULL),
+ ('ime2', 'DODGEE', 'macWifi2', 'serialNumber2', 'androidid21234567890', util.VN_NOW(), 'idle', 0, NULL),
+ ('ime3', 'ZEBRA', 'macWifi3', 'serialNumber3', 'androidid31234567890', util.VN_NOW(), 'active', 0, NULL),
+ ('ime4', 'BLACKVIEW', 'macWifi4', 'serialNumber4', 'androidid41234567890', util.VN_NOW(), 'idle', 0, NULL);
INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `created`)
VALUES
@@ -2973,9 +2990,9 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
(2, 1, 50, 2),
(3, 1, 0, 3);
-INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `renewInterval`)
+INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
VALUES
- (1, 21600, 300);
+ (1, 21600, 60, 300);
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
VALUES
@@ -2996,3 +3013,56 @@ INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `t
INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`)
VALUES
(1, 0, 0, 'marvel.com');
+
+INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, BASEEURO, SERIE, FACTURA, IVA, RECEQUIV, CLAVE, CAMBIO, DEBEME, HABERME, AUXILIAR, MONEDAUSO, TIPOOPE, NFACTICK, TERIDNIF, TERNIF, TERNOM, OPBIENES, L340, enlazado, FECHA_EX, LRECT349, empresa_id, LDIFADUAN, METAL, METALIMP, CLIENTE, METALEJE, FECHA_OP, FACTURAEX, TIPOCLAVE, TIPOEXENCI, TIPONOSUJE, TIPOFACT, TIPORECTIF, SERIE_RT, FACTU_RT, BASEIMP_RT, BASEIMP_RF, RECTIFICA, FECHA_RT, FECREGCON, enlazadoSage)
+ VALUES
+ (1, 1.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T3333333', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
+ (2, 1.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T3333333 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
+ (3, 1.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T3333333 Tony Stark', NULL, 0.81, 8.07, 'T', '3333333', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
+ (4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
+ (5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
+ (6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
+
+INSERT INTO `vn`.`mistakeType` (`id`, `description`)
+ VALUES
+ (1, 'Incorrect quantity');
+
+INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
+ VALUES
+ (1, 'Error in VAT calculation'),
+ (2, 'Error in sales details'),
+ (3, 'Error in customer data');
+
+UPDATE `vn`.`client`
+ SET fi='65004204V'
+ WHERE id=1;
+
+UPDATE `vn`.`worker`
+ SET fi='59328808D'
+ WHERE id=1106;
+
+
+INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
+ VALUES
+ (1, 1),
+ (2, 9),
+ (3, 15);
+
+INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
+ VALUES
+ ('Tablet1','Jarvis tablet'),
+ ('Tablet2','Avengers tablet');
+
+INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
+ VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()),
+ (2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()),
+ (3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()),
+ (4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE());
+
+INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
+ VALUES(1, 1103, 1, NULL),
+ (2, 1103, 2, NULL),
+ (3, 1103, 3, 32),
+ (4, 1103, 4, 32),
+ (13, 1101, 1, NULL),
+ (14, 1101, 4, 27);
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
deleted file mode 100644
index dae737466..000000000
--- a/db/dump/fixtures.sql
+++ /dev/null
@@ -1,3060 +0,0 @@
-CREATE ROLE 'salix';
-GRANT 'salix' TO 'root'@'%';
-SET DEFAULT ROLE 'salix' FOR 'root'@'%';
-
-CREATE SCHEMA IF NOT EXISTS `vn2008`;
-CREATE SCHEMA IF NOT EXISTS `tmp`;
-
-UPDATE `util`.`config`
- SET `environment`= 'development';
-
--- FOR MOCK vn.time
-
-DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`;
-
-DELIMITER $$
-$$
-CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mockVnTime`()
-BEGIN
-
- DECLARE vDate DATE;
- SET vDate = '2000-01-01';
-
- WHILE ( YEAR(vDate) <= 2002 ) DO
- INSERT IGNORE INTO vn.`time` (dated, period, `month`, `year`, `day`, week, yearMonth, salesYear)
- VALUES (vDate, CONCAT(YEAR(vDate), (WEEK(vDate)+1)), MONTH(vDate), YEAR(vDate), DAY(vDate), WEEK(vDate)+1, CONCAT(YEAR(vDate), MONTH(vDate)), YEAR(vDate));
-
- SET vDate = DATE_ADD(vDate, INTERVAL 1 DAY);
- END WHILE;
-
-END$$
-DELIMITER ;
-
-CALL `vn`.`mockVnTime`();
-DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`;
--- END MOCK vn.time
-
-ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
-ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
-ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
-ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
-
-INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
- VALUES
- ('DEFAULT_TOKEN', '1209600', CURDATE(), 66);
-
-INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`)
- VALUES
- (1, 'it@gotamcity.com', 'incidences@gotamcity.com');
-
-INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
- VALUES
- ('1', '6');
-
-INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`)
- VALUES
- (1.30, 167.00, 138000, 71);
-
-INSERT INTO `vn`.`chatConfig` (`host`, `api`)
- VALUES
- ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1');
-
-INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`)
- VALUES
- ('1', '11');
-
-UPDATE `account`.`role` SET id = 100 WHERE id = 0;
-
-INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPrefix`, `userHost`, `tplUser`)
- VALUES
- (1, 'mysqlPassword', '$', '!', '%', 'any');
-
-CALL `account`.`role_sync`;
-
-INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `role`,`active`,`email`, `lang`, `image`, `password`)
- SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2'
- FROM `account`.`role`
- ORDER BY id;
-
-INSERT INTO `account`.`account`(`id`)
- SELECT `u`.`id`
- FROM `account`.`user` `u`
- JOIN `account`.`role` `r` ON `u`.`role` = `r`.`id`
- WHERE `r`.`name` <> 'customer';
-
-INSERT INTO `vn`.`educationLevel` (`id`, `name`)
- VALUES
- (1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
- (2, 'ENSEÑANZAS DE BACHILLERATO');
-
-INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
- SELECT id,UPPER(LPAD(role, 3, '0')), name, name, NULL
- FROM `account`.`user`
- WHERE `id` = 9;
-
-INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
- SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
- FROM `account`.`user`
- WHERE `id` <> 9;
-
-UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
-UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
-UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18;
-
-DELETE FROM `vn`.`worker` WHERE firstName ='customer';
-
-INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`, `maxAmount`, `employeeFk`, `testUrl`)
- VALUES
- (1, 978, 1, 0, 2000, 9, 0);
-
-INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
- VALUES
- (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL),
- (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL),
- (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL);
-
-UPDATE account.`user`
- SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR)
- WHERE name = 'maintenance';
-
-INSERT INTO `account`.`mailAlias`(`id`, `alias`, `description`, `isPublic`)
- VALUES
- (1, 'general', 'General mailing list', FALSE),
- (2, 'it' , 'IT department' , TRUE),
- (3, 'sales' , 'Sales department' , TRUE);
-
-INSERT INTO `account`.`mailAliasAccount`(`mailAlias`, `account`)
- VALUES
- (1, 1),
- (1, 18),
- (3, 18),
- (1, 9),
- (2, 9);
-
-INSERT INTO `account`.`mailForward`(`account`, `forwardTo`)
- VALUES
- (1, 'employee@domain.local');
-
-
-
-INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
- VALUES
- (1, 'EUR', 'Euro', 1),
- (2, 'USD', 'Dollar USA', 1.4),
- (3, 'GBP', 'Libra', 1),
- (4, 'JPY', 'Yen Japones', 1);
-
-INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
- VALUES
- (1, 'España', 1, 'ES', 1, 24, 4, 0, 1),
- (2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1),
- (3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1),
- (4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1),
- (5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1),
- (8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1),
- (13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2),
- (19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
- (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
-
-INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
- VALUES
- (1, 'Main Warehouse'),
- (2, 'Gotham');
-
-INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
- VALUES
- (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1),
- (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1),
- (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
- (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
- (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
- (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
- (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
-
-INSERT INTO `vn`.`sectorType` (id,description)
- VALUES (1,'First type');
-
-INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`, `typeFk`)
- VALUES
- (1, 'First sector', 1, 'FIRST', 1),
- (2, 'Second sector', 2, 'SECOND',1);
-
-INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`)
- VALUES
- (1, 'printer1', 'path1', 0, 1 , NULL),
- (2, 'printer2', 'path2', 1, 1 , NULL),
- (4, 'printer4', 'path4', 0, NULL, '10.1.10.4');
-
-UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
-
-
-INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
- VALUES
- (1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
- (1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107),
- (1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108),
- (1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
- (1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
-
-INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
- VALUES
- ('1', 700, '01', 1, '700-01', 70001),
- ('2', 700, '02', 2, '700-02', 70002),
- ('3', 100, '01', 1, '100-01', 1),
- (32397, 100, '02', 1, 'A-47-1', 1165),
- (34831, 200, '01', 1, 'K-26-2', 20220),
- (34965, 200, '02', 2, 'L-08-4', 21800),
- (39096, 200, '03', 2, 'LR-02-3', 99999);
-
-INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`)
- VALUES
- ('AA6', 34965, 1, 0, NULL, 0),
- ('AA7', 34965, 1, 0, NULL, 0),
- ('AA8', 34965, 1, 0, NULL, 0),
- ('AA9', NULL, 1, 0, NULL, 0),
- ('AAA', NULL, 0, 0, 1109, 1),
- ('AAB', NULL, 0, 0, 1109, 1),
- ('AAC', NULL, 1, 99, 1109, 1),
- ('AAD', NULL, 0, 0, 1109, 1),
- ('AAE', 39096, 1, 0, 1109, 1),
- ('AAF', 34831, 1, 0, 1109, 1),
- ('GVC', 1, 0, 1, 1106, 1),
- ('HEJ', 2, 0, 1, 1106, 1),
- ('UXN', 1, 0, 1, 1106, 1);
-
-INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`)
- VALUES
- (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1),
- (2, 'Cash', 'Cash', 'cash', 1000, 0),
- (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0),
- (4, 'Finalcial lines', NULL, NULL, NULL, 0),
- (5, 'Other products', NULL, NULL, NULL, 0),
- (6, 'Loans', NULL, NULL, NULL, 0),
- (7, 'Leasing', NULL, NULL, NULL, 0),
- (8, 'Compensations', 'Compensations', 'compensation', NULL, 0);
-
-INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`)
- VALUES
- (128, 1, 'The Best Bank', 'BBKKESMMMMMM'),
- (2100, 1, 'Caixa Bank', 'CAIXESBB');
-
-INSERT INTO `vn`.`accounting`(`id`, `bank`, `account`, `accountingTypeFk`, `entityFk`, `isActive`, `currencyFk`, `code`)
- VALUES
- (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1, 'payOnReceipt'),
- (2, 'Cash', '5700000001', 2, 128, 1, 1, 'cash'),
- (3, 'Compensation', '4000000000', 8, 128, 1, 1, 'compensation'),
- (4, 'Transfers', '4000000001', 1, 128, 1, 1, 'transfers'),
- (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 2100, 1, 1, 'cra');
-
-INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
- VALUES
- (1, 'AGENCY', 'Agencia'),
- (2, 'DELIVERY', 'Reparto'),
- (3, 'PICKUP', 'Recogida'),
- (4, 'OTHER', 'Otros');
-
-INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `warehouseAliasFk`)
- VALUES
- (1, 'inhouse pickup' , 1, 1),
- (2, 'Super-Man delivery' , 1, 1),
- (3, 'Teleportation device' , 1, 1),
- (4, 'Entanglement' , 1, 1),
- (5, 'Quantum break device' , 1, 1),
- (6, 'Walking' , 1, 1),
- (7, 'Gotham247' , 1, 1),
- (8, 'Gotham247Expensive' , 1, 1),
- (9, 'Refund' , 1, 1),
- (10, 'Other agency' , 1, 1);
-
-UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup';
-UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery';
-UPDATE `vn`.`agencyMode` SET `id` = 3 WHERE `name` = 'Teleportation device';
-UPDATE `vn`.`agencyMode` SET `id` = 4 WHERE `name` = 'Entanglement';
-UPDATE `vn`.`agencyMode` SET `id` = 5 WHERE `name` = 'Quantum break device';
-UPDATE `vn`.`agencyMode` SET `id` = 6 WHERE `name` = 'Walking';
-UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Gotham247';
-UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Gotham247Expensive';
-UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'Refund';
-UPDATE `vn`.`agencyMode` SET `id` = 10 WHERE `name` = 'Other agency';
-
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 3 WHERE `id` = 1;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 2;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 2 WHERE `id` = 3;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 4;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 5;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 2 WHERE `id` = 6;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 7;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23;
-UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10;
-
-UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com';
-
-UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
-
-INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`)
- VALUES
- (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0),
- (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1),
- (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0),
- (4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0, 0),
- (5, NULL, 'PayMethod five', 10, 001, 0, 0, 0),
- (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0);
-
-INSERT INTO `vn`.`payDem`(`id`, `payDem`)
- VALUES
- (1, 10),
- (2, 20),
- (7, 0);
-
-INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`)
- VALUES
- (1, 'Autonomy one', 1),
- (2, 'Autonomy two', 1),
- (3, 'Autonomy three', 2),
- (4, 'Autonomy four', 13);
-
-
-INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk`)
- VALUES
- (1, 'Province one', 1, 1, NULL),
- (2, 'Province two', 1, 1, NULL),
- (3, 'Province three', 30, 2, NULL),
- (4, 'Province four', 2, 3, NULL),
- (5, 'Province five', 13, 4, NULL);
-
-INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`)
- VALUES
- (1, 'Valencia', 1),
- (2, 'Gotham', 1),
- (3, 'Algemesi', 1),
- (4, 'Alzira', 1),
- (5, 'Quito', 5);
-
-INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`)
- VALUES
- ('46000', 1, 6),
- ('46460', 2, 6),
- ('46680', 3, 6),
- ('46600', 4, 7),
- ('EC170150', 5, 8);
-
-INSERT INTO `vn`.`clientType`(`id`, `code`, `type`)
- VALUES
- (1, 'normal', 'Normal'),
- (2, 'internalUse', 'Autoconsumo'),
- (3, 'handMaking', 'Confección'),
- (4, 'loses', 'Mermas');
-
-INSERT INTO `vn`.`cplusTerIdNif`(`id`, `description`)
- VALUES
- (1, 'NIF');
-
-INSERT INTO `vn`.`contactChannel`(`id`, `name`)
- VALUES
- (1, 'Rumors on the streets'),
- (2, 'Metropolis newspaper'),
- (3, 'Daily Bugle'),
- (4, 'GCN Channel'),
- (5, 'The Newspaper');
-
-INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`)
- VALUES
- (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
- (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
- (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
- (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
- (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
- (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
- (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
- (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
- (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'),
- (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'),
- (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'),
- (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses');
-
-INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
- SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
- FROM `account`.`role` `r`
- WHERE `r`.`hasLogin` = 1;
-
-INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
- VALUES
- (1101, 50, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (1102, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH));
-
-INSERT INTO `vn`.`mandateType`(`id`, `name`)
- VALUES
- (1, 'B2B'),
- (2, 'CORE'),
- (3, 'LCR');
-
-INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPriceIncreasingRatio`, `riskScope`, `defaultPayMethodFk`, `defaultDueDay`, `defaultCredit`, `defaultIsTaxDataChecked`, `defaultHasCoreVnl`, `defaultMandateTypeFk`)
- VALUES
- (1, 200, 10, 0.25, 2, 4, 5, 300.00, 1, 1, 2);
-
-
-INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`)
- VALUES
- (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1),
- (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
- (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
- (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1),
- (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
- (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
- (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
- (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
- (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
- (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
- (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
- (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1),
- (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0),
- (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0),
- (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0),
- (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0),
- (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
- (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
- (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
- (128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
- (129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
- (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
-
-INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`)
- SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1
- FROM `account`.`role` `r`
- WHERE `r`.`hasLogin` = 1;
-
-UPDATE `vn`.`client` SET defaultAddressFk = 1 WHERE id = 1101;
-UPDATE `vn`.`client` SET defaultAddressFk = 2 WHERE id = 1102;
-UPDATE `vn`.`client` SET defaultAddressFk = 3 WHERE id = 1103;
-UPDATE `vn`.`client` SET defaultAddressFk = 4 WHERE id = 1104;
-UPDATE `vn`.`client` SET defaultAddressFk = 5 WHERE id = 1105;
-UPDATE `vn`.`client` SET defaultAddressFk = 6 WHERE id = 1106;
-UPDATE `vn`.`client` SET defaultAddressFk = 7 WHERE id = 1107;
-UPDATE `vn`.`client` SET defaultAddressFk = 8 WHERE id = 1108;
-UPDATE `vn`.`client` SET defaultAddressFk = 9 WHERE id = 1109;
-UPDATE `vn`.`client` SET defaultAddressFk = 10 WHERE id = 1110;
-UPDATE `vn`.`client` SET defaultAddressFk = 11 WHERE id = 200;
-UPDATE `vn`.`client` SET defaultAddressFk = 12 WHERE id = 400;
-
-DROP TEMPORARY TABLE IF EXISTS tmp.address;
-
-CREATE TEMPORARY TABLE tmp.address
- SELECT * FROM `vn`.`address`;
-
- UPDATE `vn`.`client` `c`
- JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id`
- SET `c`.`defaultAddressFk` = `a`.`id`
- WHERE `defaultAddressFk` IS NULL;
-DROP TEMPORARY TABLE tmp.address;
-
-INSERT INTO `vn`.`clientCredit`(`clientFk`, `workerFk`, `amount`, `created`)
- VALUES
- (1101, 5, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 MONTH)),
- (1101, 5, 900, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 MONTH)),
- (1101, 5, 800, DATE_ADD(util.VN_CURDATE(), INTERVAL -9 MONTH)),
- (1101, 5, 700, DATE_ADD(util.VN_CURDATE(), INTERVAL -8 MONTH)),
- (1101, 5, 600, DATE_ADD(util.VN_CURDATE(), INTERVAL -7 MONTH)),
- (1101, 5, 500, DATE_ADD(util.VN_CURDATE(), INTERVAL -6 MONTH)),
- (1101, 5, 400, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 MONTH)),
- (1101, 9, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
- (1101, 9, 200, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
- (1101, 9, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (1101, 9, 50 , DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (1102, 9, 800, util.VN_CURDATE()),
- (1104, 9, 90 , util.VN_CURDATE()),
- (1105, 9, 90 , util.VN_CURDATE());
-
-INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`)
- VALUES
- (1, 9999999, 20),
- (2, 10000, 21),
- (3, 600, 13);
-
-INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
- VALUES
- (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE()),
- (2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE()),
- (3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE()),
- (4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE()),
- (5, 1105, 5, 'They do understand. Our mutant powers make us superior', util.VN_CURDATE()),
- (6, 1106, 5, 'My name is Legion, for we are many!', util.VN_CURDATE()),
- (7, 1107, 9, 'I think our first move should be calling the Avengers..', util.VN_CURDATE()),
- (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', util.VN_CURDATE()),
- (9, 1109, 18, 'HULK SMASH! ...', util.VN_CURDATE()),
- (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', util.VN_CURDATE());
-
-INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
- VALUES
- (1, 'ItemPicker', 'itemPicker'),
- (2, 'Packager', 'packager'),
- (3, 'Delivery', 'delivery'),
- (4, 'SalesPerson', 'salesPerson'),
- (5, 'Administrative', 'administrative'),
- (6, 'Weight', 'weight'),
- (7, 'InvoiceOut', 'invoiceOut');
-
-INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
- VALUES
- (1, 121, 1, 'under the floor'),
- (2, 121, 2, 'wears leather and goes out at night'),
- (3, 121, 3, 'care with the dog'),
- (5, 122, 5, 'Delivery after 10am');
-
-INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
- VALUES
- (1, 1101, util.VN_CURDATE(), util.VN_CURDATE()),
- (2, 1102, util.VN_CURDATE(), util.VN_CURDATE()),
- (3, 1103, util.VN_CURDATE(), util.VN_CURDATE()),
- (4, 1104, util.VN_CURDATE(), util.VN_CURDATE()),
- (5, 1105, util.VN_CURDATE(), util.VN_CURDATE());
-
-INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassificationFk`, `credit`, `creationDate`, `grade`)
- VALUES
- (1, 1, 3000, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
- (2, 2, 6000, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
- (3, 3, 10000, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL);
-
-INSERT INTO `vn`.`companyGroup`(`id`, `code`)
- VALUES
- (1, 'wayneIndustries'),
- (2, 'verdnatura');
-
-INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
- VALUES
- ('animals', 'Food and complements for pets'),
- ('complements', 'Other complements'),
- ('flowerPlants', 'Wholesale of flowers and plants'),
- ('vegetablesFruits', 'Fruit and vegetable trade');
-
-INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
- VALUES
- (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
- (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
- (69, 'Packaging', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
- (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
- (567, 'Holland', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
- (791, 'Bros SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
- (1381, 'Ornamentales', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
-
-INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
- VALUES
- (1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
- (2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
- (3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
- (4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'),
- (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'),
- (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222');
-
-INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
- VALUES
- (1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
- (2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'),
- (3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL),
- (4, 442, 321654987, NULL, NULL, 'observation442', NULL);
-
-INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
- VALUES
- (241, 442, 'ES111122333344111122221111', 128);
-
-INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`)
- VALUES
- (69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL),
- (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101),
- (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL),
- (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL),
- (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL);
-
-INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`)
- VALUES
- ('CEE', 1, 10),
- ('EQU', 0, 1),
- ('NATIONAL', 0, 1),
- ('WORLD', 2, 15);
-
-INSERT INTO vn.invoiceOutConfig
- SET parallelism = 8;
-
-INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
- VALUES
- ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
- ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
- ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
- ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
- ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL),
- ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
-
-INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
- VALUES
- (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
- (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
- (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
- (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
- (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0);
-
-UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1;
-UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2;
-UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3;
-UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
-UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
-
-INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
- VALUES
- (1, 895.76, 89.58, 4722000010),
- (1, 33.80, 7.10, 4722000021),
- (2, 110.33, 11.03, 4770000010),
- (3, 8.07, 0.81, 4770000010),
- (4, 8.07, 0.81, 4770000010),
- (5, 8.07, 0.81, 4770000010);
-
-INSERT INTO `vn`.`expense`(`id`, `name`, `isWithheld`)
- VALUES
- (2000000000, 'Inmovilizado pendiente', 0),
- (2000000001, 'Compra de bienes de inmovilizado', 0),
- (4751000000, 'Retenciones', 1),
- (4751000001, 'Retencion', 0),
- (6210000567, 'Alquiler VNH', 0),
- (6240000000, 'Transportes de ventas rutas', 0),
- (7001000000, 'Mercaderia', 0),
- (7050000000, 'Prestacion de servicios', 1);
-
-
-INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`)
- VALUES
- (1, 1, 813.06, 2000000000, util.VN_CURDATE()),
- (2, 1, 33.80, 4751000000, util.VN_CURDATE()),
- (3, 1, 70.70, 6210000567, util.VN_CURDATE()),
- (4, 2, 110.33, 2000000000, util.VN_CURDATE()),
- (5, 3, 8.07, 2000000000, util.VN_CURDATE()),
- (6, 4, 8.07, 2000000000, util.VN_CURDATE()),
- (7, 5, 8.07, 2000000000, util.VN_CURDATE());
-
-INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`)
- VALUES
- (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
- (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
- (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
- (4, 'Zone 247 B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
- (5, 'Zone expensive A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
- (6, 'Zone expensive B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
- (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 1, 0, 100),
- (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 1, 0, 100),
- (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 1, 0, 100),
- (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 1, 0, 100),
- (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100),
- (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 1, 0, 100),
- (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 1, 0, 100);
-
-
-INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`)
- VALUES
- (1, 1, 1),
- (2, 2, 2),
- (3, 3, 1),
- (4, 4, 2),
- (5, 5, 1),
- (6, 6, 2),
- (7, 7, 1),
- (8, 8, 1),
- (9, 9, 1),
- (10, 10, 3),
- (11, 11, 5),
- (12, 12, 4),
- (13, 13, 5);
-
-INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`)
- VALUES
- (1, util.VN_CURDATE(), '23:59'),
- (2, util.VN_CURDATE(), '23:59'),
- (3, util.VN_CURDATE(), '23:59'),
- (4, util.VN_CURDATE(), '23:59'),
- (5, util.VN_CURDATE(), '23:59'),
- (6, util.VN_CURDATE(), '23:59'),
- (7, util.VN_CURDATE(), '23:59'),
- (8, util.VN_CURDATE(), '23:59'),
- (9, util.VN_CURDATE(), '23:59'),
- (10, util.VN_CURDATE(), '23:59'),
- (11, util.VN_CURDATE(), '23:59'),
- (12, util.VN_CURDATE(), '23:59'),
- (13, util.VN_CURDATE(), '23:59');
-
-INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1');
-
-INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`)
- VALUES
- (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1),
- (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9),
- (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10),
- (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12),
- (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13),
- (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3),
- (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5);
-
-INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`)
- VALUES
- (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
- (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
- (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
- (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL),
- (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL),
- (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
- (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL),
- (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
- (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL),
- (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL),
- (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
- (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
- (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
- (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
- (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL);
-
-INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
- VALUES
- (1, 11, 1, 'ready'),
- (2, 2, 2, 'do it fast please'),
- (3, 3, 5, 'Faster faster fasteeeeeer!!!'),
- (4, 4, 5, 'Deliver before 8am'),
- (5, 13, 5, 'You can run from the disappointments you are trying to forget. But its only when you embrace your past that you truly move forward. Maybe I never get to go home again, but I found my way there. And I am glad I did.'),
- (6, 14, 5, 'Careful, armed warhead'),
- (7, 23, 1, 'under the floor'),
- (8, 23, 2, 'wears leather and goes out at night'),
- (9, 23, 5, 'care with the dog'),
- (10, 23, 4, 'Reclama ticket: 8'),
- (11, 24, 4, 'Reclama ticket: 7'),
- (12, 11, 3, 'Delivery after 10am'),
- (13, 1, 7, 'observation of ticket one'),
- (14, 2, 7, 'observation of ticket two');
-
--- FIX for state hours on local, inter_afterInsert
--- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
-
-INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
- VALUES
- (1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
- (2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
- (3, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -2 MONTH)),
- (4, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -3 MONTH)),
- (5, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -4 MONTH)),
- (6, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
- (7, 10, 18, util.VN_NOW()),
- (8, 5, 19, util.VN_NOW()),
- (9, 5, 19, util.VN_NOW()),
- (10, 5, 19, util.VN_NOW()),
- (11, 3, 19, util.VN_NOW()),
- (12, 3, 19, util.VN_NOW()),
- (13, 3, 19, util.VN_NOW()),
- (14, 3, 19, util.VN_NOW()),
- (15, 2, 19, util.VN_NOW()),
- (16, 3, 19, util.VN_NOW()),
- (17, 2, 19, util.VN_NOW()),
- (18, 2, 19, util.VN_NOW()),
- (19, 2, 19, util.VN_NOW()),
- (20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
- (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
- (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
- (23, 16, 21, util.VN_NOW()),
- (24, 16, 21, util.VN_NOW());
-
-INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
- VALUES
- (1, 'Gotham','1007 Mountain Drive, Gotham');
-
-INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`)
- VALUES
- (1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1),
- (2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1),
- (3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1),
- (4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1),
- (5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1),
- (6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1);
-
-INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
- VALUES
- (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
-
-
-INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
- VALUES
- (1, 'Diff', 'diff'),
- (2, 'Recover', 'recover'),
- (3, 'Mana', 'mana'),
- (4, 'Reclaim', 'reclaim'),
- (5, 'Heritage', 'heritage'),
- (6, 'Miscellaneous', 'miscellaneous'),
- (7, 'Freight Pickup', 'freightPickUp');
-
-INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk`)
- VALUES
- (1, 1101, 'some diff charges', -19.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1),
- (2, 1101, 'more diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1),
- (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1),
- (4, 1101, 'insane diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1),
- (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1),
- (6, 1101, 'diff charges', 88.30, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1),
- (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1),
- (8, 1101, 'some recovery charges', 29.35, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1),
- (9, 1101, 'some manna charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1),
- (10, 1101, 'some claim charges', 13.13, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1),
- (11, 1101, 'some heritage charges', -15.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1),
- (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1);
-
-INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`)
- VALUES
- (1, 1102, 442, '1-1', util.VN_CURDATE(), 2);
-
-INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`)
- VALUES
- (1, 'Plant', 1, 'B92A26', 'icon-plant', 'plant'),
- (2, 'Flower', 2, 'dcf711', 'icon-flower', 'flower'),
- (3, 'Logistic', 0, 'b9f711', NULL, 'logistical'),
- (4, 'Handmade', 1, NULL, 'icon-handmade', 'handmade'),
- (5, 'Artificial', 1, NULL, 'icon-artificial', 'artificial'),
- (6, 'Green', 1, NULL, 'icon-greenery', 'greenery'),
- (7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'),
- (8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit');
-
-INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
- VALUES
- ('warm', 'Warm', 'Warm'),
- ('cool', 'Cool', 'Cool');
-
-INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`, `isFragile`)
- VALUES
- (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool', 0),
- (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool', 1),
- (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool', 0),
- (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm', 0),
- (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0),
- (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1);
-
-INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
- VALUES
- ('YEL', 'Yellow', 1, 1, 'F4D03F'),
- ('BLU', 'Blue', 1, 2, '5DADE2'),
- ('RED', 'Red', 1, 3, 'EC7063'),
- ('SLV', 'Silver', 1, 4, 'CACFD2'),
- ('BRW', 'Brown', 1, 5, 'DC7633'),
- ('BLK', 'Black', 1, 6, '000000'),
- ('BAS', 'Blue/Silver', 1, 7, '5DADE2'),
- ('GRN', 'Green', 1, 8, '28A745'),
- ('WHT', 'White', 1, 9, 'FFFFFF');
-
-INSERT INTO `vn`.`origin`(`id`,`code`, `name`)
- VALUES
- (1, 'SPA', 'Spain'),
- (2, 'HOL', 'Holand'),
- (3, 'VLC', 'Valencia');
-
-INSERT INTO `vn`.`producer`(`id`, `name`)
- VALUES
- (1, 'Marvel Studios'),
- (2, 'Nordic Mythology');
-
-INSERT INTO `vn`.`taxType`(`id`, `nickname`, `isAccrued`, `serial`, `TIPOOPE`, `description`, `countryFk`)
- VALUES
- (1, 'National', 1, 'R', 'I', 'national VAT', 1),
- (2, 'European', 0, 'E', 'I', 'europe VAT', 1);
-
-INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equalizationTax`, `type`, `link`, `isActive`, `updated`, `transactionCode`)
- VALUES
- (1 , util.VN_CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, util.VN_CURDATE(), 1),
- (2 , util.VN_CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, util.VN_CURDATE(), 1),
- (21 , util.VN_CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, util.VN_CURDATE(), 1),
- (108, util.VN_CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, util.VN_CURDATE(), 1);
-
-INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`)
- VALUES
- (1, 'Reduced VAT', 'R'),
- (2, 'General VAT', 'G');
-
-INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`)
- VALUES
- (1, util.VN_CURDATE(), 1),
- (1, util.VN_CURDATE(), 21),
- (2, util.VN_CURDATE(), 2);
-
-INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`)
- VALUES
- (05080000, 'Coral y materiales similares', 2, 2),
- (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1);
-
-INSERT INTO `vn`.`itemFamily`(`code`, `description`)
- VALUES
- ('EMB', 'Packagings'),
- ('SER', 'Services'),
- ('VT', 'Sales');
-
-INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
- `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
- VALUES
- (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 15,3),
- (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 10,2),
- (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5,5),
- (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
- (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
- (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL,NULL),
- (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
- (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
- (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
- (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
-
--- Update the taxClass after insert of the items
-UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
- WHERE `itemFk` IN(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 71);
-
-INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`)
- VALUES
- (1, 1, 0, 0, 2.5, 2, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()),
- (2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()),
- (3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE());
-
-INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
- VALUES
- (71,0.141,1);
-
-INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`)
- VALUES
- (1, 0.00, 10, 10, 0, 1, util.VN_CURDATE(), 6, 1.50),
- (2, 100.00, 20, 20, 0, 1, util.VN_CURDATE(), 7, 1.00),
- (3, 14000.00, 0, 0, 0, 1, util.VN_CURDATE(), NULL, 0),
- (4, 218000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0),
- (5, 292000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0),
- (94, 140875.00, 49.00, 115.00, 25.00, 0, util.VN_CURDATE(), 71, 0.00),
- ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00),
- ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00);
-
-INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`)
- VALUES
- ('10', 1, 'pallet 100');
-
-INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
- VALUES
- (1, 'En reparto', 'ON DELIVERY'),
- (2, 'Entregada', 'DELIVERED'),
- (3, 'Perdida', 'LOST');
-
-
-INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
- VALUES
- (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'),
- (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL),
- (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL),
- (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL),
- (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL),
- (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL),
- (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL),
- (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL),
- (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL),
- (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
- (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
- (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
- (13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL);
-
-
-INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
- VALUES
- (1, util.VN_CURDATE(), 1, 1, 1),
- (2, util.VN_CURDATE(), 2, 1, 1),
- (3, util.VN_CURDATE(), 3, 1, 1),
- (4, util.VN_CURDATE(), 3, 2, 1106),
- (5, util.VN_CURDATE(), 5, 1, 1106),
- (6, util.VN_CURDATE(), 5, 3, 1106);
-
-INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
- VALUES
- (1, 1, 2, 2, util.VN_CURDATE(), NULL),
- (2, 2, 2, 1, util.VN_CURDATE(), NULL),
- (3, 3, 2, 4, util.VN_CURDATE(), NULL);
-
-INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`)
- VALUES
- (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()),
- (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
- (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
- (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()),
- (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()),
- (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
- (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()),
- (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
- (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
- (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()),
- (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()),
- (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()),
- (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
- (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
-
-INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
- VALUES
- (1, 28, 50),
- (1, 29, 49.4),
- (1, 39, 0.994),
- (2, 28, 5),
- (2, 29, 2),
- (2, 39, 0.07),
- (3, 28, 50),
- (3, 29, 49.4),
- (3, 39, 0.994),
- (4, 28, 1.25),
- (4, 29, 0.42),
- (4, 39, 0.017),
- (5, 17, 9.94),
- (5, 28, 50),
- (5, 29, 49.4),
- (5, 39, 0.994),
- (6, 17, 9.94),
- (6, 28, 50),
- (6, 29, 49.4),
- (6, 39, 0.994),
- (7, 15, 0.0199),
- (7, 17, 0.35),
- (7, 28, 5),
- (7, 29, 2),
- (7, 39, 0.07),
- (8, 15, 0.0199),
- (8, 17, 0.084),
- (8, 28, 1.25),
- (8, 29, 0.42),
- (8, 39, 0.017),
- (9, 15, 3.0949),
- (9, 21, 0.001),
- (9, 28, 53),
- (9, 29, 46.4),
- (9, 39, 0.994),
- (10, 15, 0.0199),
- (10, 28, 7),
- (10, 29, 0),
- (10, 39, 0.07),
- (11, 15, 3.0949),
- (11, 21, 0.001),
- (11, 28, 53),
- (11, 29, 46.4),
- (11, 39, 0.994),
- (12, 15, 0.0199),
- (12, 21, 0.003),
- (12, 28, 2.25),
- (12, 29, -0.58),
- (12, 39, 0.017),
- (13, 15, 0.114),
- (13, 28, 5),
- (13, 29, 2),
- (13, 39, 0.07),
- (14, 15, 3.0949),
- (14, 28, 50),
- (14, 29, 49.4),
- (14, 39, 0.994),
- (15, 15, 3.0949),
- (15, 28, 50),
- (15, 29, 49.4),
- (15, 39, 0.994),
- (16, 28, 5),
- (16, 29, 2),
- (16, 39, 0.07),
- (17, 28, 5),
- (17, 29, 2),
- (17, 39, 0.07),
- (18, 28, 1.25),
- (18, 29, 0.42),
- (18, 39, 0.017),
- (19, 17, 0.7),
- (19, 22, 0.3),
- (19, 28, 5),
- (19, 29, 2),
- (19, 39, 0.02),
- (20, 17, 0.7),
- (20, 22, 0.3),
- (20, 28, 5),
- (20, 29, 2),
- (20, 39, 0.02),
- (21, 17, 0.7),
- (21, 22, 0.3),
- (21, 28, 5),
- (21, 29, 2),
- (21, 39, 0.02),
- (22, 17, 0.7),
- (22, 22, 0.3),
- (22, 28, 5),
- (22, 29, 2),
- (22, 39, 0.02),
- (23, 17, 0.7),
- (23, 22, 0.3),
- (23, 28, 5),
- (23, 29, 2),
- (23, 39, 0.02),
- (24, 17, 0.7),
- (24, 22, 0.3),
- (24, 28, 5),
- (24, 29, 2),
- (24, 39, 0.02),
- (25, 17, 0.033),
- (25, 28, 1.25),
- (25, 29, 0.42),
- (25, 39, 0.017),
- (26, 17, 0.033),
- (26, 28, 1.25),
- (26, 29, 0.42),
- (26, 39, 0.017),
- (27, 17, 0.033),
- (27, 28, 1.25),
- (27, 29, 0.42),
- (27, 39, 0.017),
- (28, 17, 0.033),
- (28, 28, 1.25),
- (28, 29, 0.42),
- (28, 39, 0.017),
- (29, 17, 0.033),
- (29, 28, 1.25),
- (29, 29, 0.42),
- (29, 39, 0.017),
- (30, 17, 0.033),
- (30, 28, 1.25),
- (30, 29, 0.42),
- (30, 39, 0.017),
- (31, 28, 5),
- (31, 29, 2),
- (31, 36, 0.01),
- (31, 39, 0.07),
- (32, 28, 50),
- (32, 29, 49.4),
- (32, 36, -92.324),
- (32, 39, 0.994);
-
-INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`)
- VALUES
- (2, 'GVC', 1, 1, 1, 1106),
- (4, 'HEJ', 1, 1, 1, 1106),
- (1, 'UXN', 2, 12, 12, 1106);
-
-INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
- VALUES
- ('1', '1', '1', util.VN_CURDATE(), '1106'),
- ('2', '2', '5', util.VN_CURDATE(), '1106'),
- ('1', '7', '1', util.VN_CURDATE(), '1106'),
- ('2', '8', '5', util.VN_CURDATE(), '1106');
-
-INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `id`, `stateFk`)
- VALUES
- (1, 0, util.VN_CURDATE(), 5, 55, 1, 14),
- (1, 1, util.VN_CURDATE(), 5, 54, 2, 8),
- (2, 1, util.VN_CURDATE(), 10, 40, 3, 8),
- (3, 1, util.VN_CURDATE(), 2, 40, 4, 8),
- (31, 1, util.VN_CURDATE(), -5, 40, 5, 8);
-
-INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
- VALUES
- (1, 1, 1111111111),
- (2, 1, 2222222222),
- (3, 1, 3333333333),
- (4, 2, 4444444444);
-
-INSERT INTO `vn`.`train`(`id`, `name`)
- VALUES
- (1, 'Train1'),
- (2, 'Train2');
-
-INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`)
- VALUES
- ('1106', '1', '1', 'H', '1', '1', '1'),
- ('1107', '1', '1', 'V', '1', '1', '1');
-
-INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
- VALUES
- (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
- (2, 1106, 14, util.VN_CURDATE(), 1);
-
-INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
- VALUES
- (1, 1, 1),
- (2, 1, NULL),
- (3, 2, NULL),
- (23, 1, NULL);
-
-INSERT INTO `vn`.`genus`(`id`, `name`)
- VALUES
- (1, 'Abelia'),
- (2, 'Abies'),
- (3, 'Abutilon');
-
-INSERT INTO `vn`.`specie`(`id`, `name`)
- VALUES
- (1, 'grandiflora'),
- (2, 'procera'),
- (3, 'decurrens'),
- (4, 'dealbata');
-
-INSERT INTO `vn`.`itemBotanical`(`itemFk`, `genusFk`, `specieFk`)
- VALUES
- (1, 1, 1),
- (2, 2, 2),
- (3, 2, NULL),
- (4, 2, 1);
-
-INSERT INTO `vn`.`tag`(`id`, `code`, `name`, `isFree`, `isQuantitatif`, `sourceTable`, `unit`, `ediTypeFk`, `overwrite`)
- VALUES
- (1, 'color', 'Color', 0, 0, 'ink', NULL, NULL, 'inkFk'),
- (2, NULL, 'Forma', 1, 0, NULL, NULL,NULL, NULL),
- (3, NULL, 'Material', 1, 0, NULL, NULL,NULL, NULL),
- (4, NULL, 'Longitud', 1, 1, NULL, 'mm', NULL, 'size'),
- (5, NULL, 'Diámetro', 1, 1, NULL, 'mm',NULL, 'diameter'),
- (7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm',NULL, NULL),
- (23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems'),
- (27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, 'size'),
- (36, 'producer', 'Proveedor', 1, 0, NULL, NULL, NULL, 'producer'),
- (56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL),
- (58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL),
- (67, 'category', 'Categoria', 1, 0, NULL, NULL, NULL, NULL),
- (92, NULL, 'Nombre temporal', 1, 0, NULL, NULL, NULL, NULL);
-
-INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
- VALUES
- (1, 1, 56, 'Ranged weapon', 1),
- (2, 1, 58, 'longbow', 2),
- (3, 1, 27, '200cm', 3),
- (4, 1, 36, 'Stark Industries', 4),
- (5, 1, 1, 'Brown', 5),
- (6, 1, 67, '+1 precission', 6),
- (7, 1, 23, '1', 7),
- (8, 2, 56, 'Melee weapon', 1),
- (9, 2, 58, 'combat fist', 2),
- (10, 2, 27, '15cm', 3),
- (11, 2, 36, 'Stark Industries', 4),
- (12, 2, 1, 'Silver', 5),
- (13, 2, 67, 'Concussion', 6),
- (14, 2, 23, '2', 7),
- (15, 3, 56, 'Ranged weapon', 1),
- (16, 3, 58, 'sniper rifle', 2),
- (17, 3, 4, '113cm', 3),
- (18, 3, 36, 'Stark Industries', 4),
- (19, 3, 1, 'Green', 5),
- (20, 3, 67, 'precission', 6),
- (21, 3, 23, '3', 7),
- (22, 4, 56, 'Melee weapon', 1),
- (23, 4, 58, 'heavy shield', 2),
- (24, 4, 4, '100cm', 3),
- (25, 4, 36, 'Stark Industries', 4),
- (26, 4, 1, 'Black', 5),
- (27, 4, 67, 'containtment', 6),
- (28, 4, 23, '4', 7),
- (29, 5, 56, 'Ranged weapon', 1),
- (30, 5, 58, 'pistol', 2),
- (31, 5, 67, '9mm', 3),
- (32, 5, 36, 'Stark Industries', 4),
- (33, 5, 1, 'Silver', 5),
- (34, 5, 27, '15cm', 6),
- (35, 5, 23, '5', 7),
- (36, 6, 56, 'Container', 1),
- (37, 6, 58, 'ammo box', 2),
- (38, 6, 27, '100cm', 3),
- (39, 6, 36, 'Stark Industries', 4),
- (40, 6, 1, 'Green', 5),
- (41, 6, 67, 'supply', 6),
- (42, 6, 23, '6', 7),
- (43, 7, 56, 'Container', 1),
- (44, 7, 58, 'medical box', 2),
- (45, 7, 27, '100cm', 3),
- (46, 7, 36, 'Stark Industries', 4),
- (47, 7, 1, 'White', 5),
- (48, 7, 67, 'supply', 6),
- (49, 7, 23, '7', 7),
- (50, 8, 56, 'Ranged Reinforced weapon', 1),
- (51, 8, 58, '+1 longbow', 2),
- (52, 8, 27, '200cm', 3),
- (53, 8, 36, 'Stark Industries', 4),
- (54, 8, 1, 'Brown', 5),
- (55, 8, 67, 'precission', 6),
- (56, 8, 23, '8', 7),
- (57, 9, 56, 'Melee Reinforced weapon', 1),
- (58, 9, 58, 'combat fist', 2),
- (59, 9, 27, '15cm', 3),
- (60, 9, 36, 'Stark Industries', 4),
- (61, 9, 1, 'Silver', 5),
- (62, 9, 67, 'Concussion', 6),
- (63, 9, 23, '9', 7),
- (64, 10, 56, 'Ranged Reinforced weapon', 1),
- (65, 10, 58, 'sniper rifle', 2),
- (66, 10, 67, '700mm', 3),
- (67, 10, 36, 'Stark Industries', 4),
- (68, 10, 1, 'Green', 5),
- (69, 10, 27, '130cm', 6),
- (70, 10, 23, '10', 7),
- (71, 11, 56, 'Melee Reinforced weapon', 1),
- (72, 11, 58, 'heavy shield', 2),
- (73, 11, 4, '120cm', 3),
- (74, 11, 36, 'Stark Industries', 4),
- (75, 11, 1, 'Black', 5),
- (76, 11, 67, 'containtment', 6),
- (77, 11, 23, '11', 7),
- (78, 12, 56, 'Ranged Reinforced weapon', 1),
- (79, 12, 58, 'pistol', 2),
- (80, 12, 27, '9mm', 3),
- (81, 12, 36, 'Stark Industries', 4),
- (82, 12, 1, 'Silver', 5),
- (83, 12, 67, '23cm', 6),
- (84, 12, 23, '12', 7),
- (85, 13, 56, 'Chest', 1),
- (86, 13, 58, 'ammo box', 2),
- (87, 13, 27, '100cm', 3),
- (88, 13, 36, 'Stark Industries', 4),
- (89, 13, 1, 'Green', 5),
- (90, 13, 67, 'supply', 6),
- (91, 13, 23, '13', 7),
- (92, 14, 56, 'Chest', 1),
- (93, 14, 58, 'medical box', 2),
- (94, 14, 27, '100cm', 3),
- (95, 14, 36, 'Stark Industries', 4),
- (96, 14, 1, 'White', 5),
- (97, 14, 67, 'supply', 6),
- (98, 14, 23, '1', 7),
- (99, 15, 92, 'Trolley', 2),
- (100, 16, 92, 'Pallet', 2),
- (101, 71, 92, 'Shipping cost', 2);
-
-INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`)
- VALUES
- (1, 1, 1, 0),
- (2, 2, 2, 0),
- (3, 3, 3, 0),
- (4, 1, 4, 4),
- (5, 1, 5, 5);
-
-CALL `vn`.`itemRefreshTags`(NULL);
-
-INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`, `changedModelValue`)
- VALUES
- ('1', '1', '1', 'insert', 'We made a change!', 'Item', '{}', '{}', 1, '1');
-
-INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`)
- VALUES
- (1, 1101, DATE_ADD(util.VN_CURDATE(),INTERVAL -7 MONTH), DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), 50, 7),
- (2, 1102, DATE_ADD(util.VN_CURDATE(),INTERVAL -5 MONTH), util.VN_CURDATE(), 100, 1),
- (3, 1102, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(),INTERVAL 1 MONTH), 50, 7),
- (4, 1103, util.VN_CURDATE(), NULL, 50, 7);
-
-INSERT INTO `bs`.`clientAnnualConsumption`(`clientFk`, `invoiced`)
- VALUES
- (1101, 1500),
- (1102, 100),
- (1103, 1000),
- (1104, 500),
- (1105, 5000);
-
-INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
- VALUES
- (1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
- (2, 4, 'last_buy', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
- (3, 8, 'visible', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL);
-
-INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
- VALUES
- (2, 1),
- (3, 2),
- (5, 6),
- (15, 6);
-
-INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
- VALUES
- (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
- (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
- (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
- (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
- (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
- (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
- (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
- (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
- (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
- (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
-
-INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`)
- VALUES
- (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1),
- (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2),
- (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3),
- (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4),
- (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
- (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
- (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
- (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10);
-
-INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
- VALUES
- (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, ''),
- (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two'),
- (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three'),
- (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four'),
- (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
- (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
- (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
- (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '');
-
-INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
- VALUES
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
- ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
- ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
- ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
-
-INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
- VALUES
- (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
- (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
- (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
- (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
- (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
-
-INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
- VALUES
- (1, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (2, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (4, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
- (5, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
- (6, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (7, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (8, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (9, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (11, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (12, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (13, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (14, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (15, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (16, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (17, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (18, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (19, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
- (20, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (21, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (22, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH));
-
-INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`)
- VALUES
- (1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
- (2, 1, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
- (3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3),
- (4, 1, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4),
- (5, 2, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5),
- (6, 3, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 6),
- (7, 11, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 7),
- (8, 11, 4, 1, util.VN_CURDATE(), 10, 3.26, 0, util.VN_CURDATE(), 8),
- (9, 16, 1, 1, util.VN_CURDATE(), 5, 9.10, 0, util.VN_CURDATE(), 9),
- (10, 16, 2, 1, util.VN_CURDATE(), 10, 1.07, 0, util.VN_CURDATE(), 10),
- (11, 16, 1, 1, util.VN_CURDATE(), 2, 9.10, 0, util.VN_CURDATE(), 11),
- (12, 16, 4, 1, util.VN_CURDATE(), 20, 3.06, 0, util.VN_CURDATE(), 12),
- (13, 8, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 13),
- (14, 8, 1, 1, util.VN_CURDATE(), 10, 9.28, 0, util.VN_CURDATE(), 14),
- (15, 19, 1, 1, util.VN_CURDATE(), 10, 1.50, 0, util.VN_CURDATE(), 15),
- (16, 20, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 16),
- (17, 22, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 17),
- (18, 22, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 18),
- (19, 4, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 19),
- (20, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 20),
- (21, 6, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 21),
- (22, 7, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 22),
- (23, 9, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 23),
- (24, 10, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 24),
- (25, 12, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 25),
- (26, 13, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 26),
- (27, 14, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 27),
- (28, 15, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 28),
- (29, 17, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 29),
- (30, 18, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 30);
-
-INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
- VALUES
- (1, 15, 0.58),
- (1, 23, 6.5),
- (1, 28, 20.72),
- (1, 29, -18.72),
- (1, 39, 0.02),
- (2, 15, 0.058),
- (2, 21, 0.002),
- (2, 28, 5.6),
- (2, 29, -4.6),
- (2, 39, 0.01),
- (3, 15, 0.58),
- (3, 23, 6.5),
- (3, 28, 20.72),
- (3, 29, -18.72),
- (3, 39, 0.02),
- (4, 15, 0.051),
- (4, 21, -0.001),
- (4, 28, 20.72),
- (4, 29, -19.72),
- (4, 37, 2),
- (4, 39, 0.01),
- (5, 15, 0.58),
- (5, 23, 6.5),
- (5, 28, 20.72),
- (5, 29, -18.72),
- (5, 39, 0.02),
- (6, 23, 6.5),
- (7, 15, 0.0114),
- (7, 28, 5.6),
- (7, 29, -4.6),
- (7, 39, 0.01),
- (8, 15, 0.0016),
- (8, 28, 20.72),
- (8, 29, -19.72),
- (8, 37, 2),
- (8, 39, 0.01),
- (9, 15, 0.58),
- (9, 23, 6.5),
- (9, 28, 20.72),
- (9, 29, -18.72),
- (9, 39, 0.02),
- (10, 15, 0.058),
- (10, 21, 0.002),
- (10, 28, 5.6),
- (10, 29, -4.6),
- (10, 39, 0.01),
- (11, 15, 0.58),
- (11, 23, 6.5),
- (11, 28, 20.72),
- (11, 29, -18.72),
- (11, 39, 0.02),
- (12, 15, 0.051),
- (12, 22, -0.001),
- (12, 28, 20.72),
- (12, 29, -19.72),
- (12, 37, 2),
- (12, 39, 0.01),
- (13, 15, 0.2899),
- (13, 28, 5.6),
- (13, 29, -4.6),
- (13, 39, 0.01),
- (14, 15, 0.58),
- (14, 23, 6.5),
- (14, 28, 20.72),
- (14, 29, -18.72),
- (14, 39, 0.02),
- (15, 15, 0.58),
- (15, 23, 6.5),
- (15, 28, 20.72),
- (15, 29, -18.72),
- (15, 39, 0.02),
- (16, 15, 0.058),
- (16, 21, 0.002),
- (16, 28, 5.6),
- (16, 29, -4.6),
- (16, 39, 0.01),
- (17, 15, 0.058),
- (17, 21, 0.002),
- (17, 28, 5.6),
- (17, 29, -4.6),
- (17, 39, 0.01),
- (18, 15, 0.051),
- (18, 22, -0.001),
- (18, 28, 20.72),
- (18, 29, -19.72),
- (18, 37, 2),
- (18, 39, 0.01),
- (19, 15, 0.58),
- (19, 23, 6.5),
- (19, 28, 20.72),
- (19, 29, -18.72),
- (19, 39, 0.02),
- (20, 15, 0.58),
- (20, 23, 6.5),
- (20, 28, 20.72),
- (20, 29, -18.72),
- (20, 39, 0.02),
- (21, 15, 0.58),
- (21, 23, 6.5),
- (21, 28, 20.72),
- (21, 29, -18.72),
- (21, 39, 0.02),
- (22, 15, 0.58),
- (22, 23, 6.5),
- (22, 28, 20.72),
- (22, 29, -18.72),
- (22, 39, 0.02),
- (23, 15, 0.58),
- (23, 23, 6.5),
- (23, 28, 20.72),
- (23, 29, -18.72),
- (23, 39, 0.02),
- (24, 15, 0.58),
- (24, 23, 6.5),
- (24, 28, 20.72),
- (24, 29, -18.72),
- (24, 39, 0.02),
- (25, 15, 0.051),
- (25, 22, -0.001),
- (25, 28, 20.72),
- (25, 29, -19.72),
- (25, 37, 2),
- (25, 39, 0.01),
- (26, 15, 0.051),
- (26, 22, -0.001),
- (26, 28, 20.72),
- (26, 29, -19.72),
- (26, 37, 2),
- (26, 39, 0.01),
- (27, 15, 0.051),
- (27, 22, -0.001),
- (27, 28, 20.72),
- (27, 29, -19.72),
- (27, 37, 2),
- (27, 39, 0.01),
- (28, 15, 0.051),
- (28, 22, -0.001),
- (28, 28, 20.72),
- (28, 29, -19.72),
- (28, 37, 2),
- (28, 39, 0.01),
- (29, 15, 0.051),
- (29, 22, -0.001),
- (29, 28, 20.72),
- (29, 29, -19.72),
- (29, 37, 2),
- (29, 39, 0.01),
- (30, 15, 0.051),
- (30, 22, -0.001),
- (30, 28, 20.72),
- (30, 29, -19.72),
- (30, 37, 2),
- (30, 39, 0.01);
-
-INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`)
- VALUES
- (1, NULL),
- (2, NULL),
- (3, NULL),
- (4, NULL),
- (5, NULL),
- (6, NULL),
- (7, NULL),
- (8, NULL),
- (9, NULL),
- (10, NULL),
- (11, NULL);
-
-INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`)
- VALUES
- (1, 1),
- (2, 2),
- (3, 3),
- (4, 4),
- (5, 5),
- (6, 6),
- (7, 7),
- (8, 8),
- (9, 9),
- (10, 10),
- (11, 11);
-
-INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`)
- VALUES
- (1, 1, util.VN_CURDATE()),
- (2, 2, util.VN_CURDATE()),
- (3, 3, util.VN_CURDATE()),
- (4, 4, util.VN_CURDATE()),
- (5, 5, util.VN_CURDATE()),
- (6, 6, util.VN_CURDATE()),
- (7, 7, util.VN_CURDATE()),
- (8, 8, util.VN_CURDATE()),
- (9, 9, util.VN_CURDATE()),
- (10, 10, util.VN_CURDATE()),
- (11, 11, util.VN_CURDATE());
-
-INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`)
- VALUES
- (1, 1, 1101, util.VN_CURDATE()),
- (2, 2, 1101, util.VN_CURDATE()),
- (3, 3, 1101, util.VN_CURDATE()),
- (4, 4, 1102, util.VN_CURDATE()),
- (5, 5, 1102, util.VN_CURDATE()),
- (6, 6, 1102, util.VN_CURDATE()),
- (7, 7, 1103, util.VN_CURDATE()),
- (8, 8, 1103, util.VN_CURDATE()),
- (9, 9, 1103, util.VN_CURDATE()),
- (10, 10, 1102, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)),
- (11, 11, 1103, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY));
-
-INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`)
- VALUES
- (util.VN_CURDATE(), util.VN_CURDATE(), '121', 'data', 1),
- (util.VN_CURDATE(), util.VN_CURDATE(), '122', 'data', 2),
- (util.VN_CURDATE(), util.VN_CURDATE(), '123', 'data', 3),
- (util.VN_CURDATE(), util.VN_CURDATE(), '124', 'data', 4),
- (util.VN_CURDATE(), util.VN_CURDATE(), '125', 'data', 5),
- (util.VN_CURDATE(), util.VN_CURDATE(), '126', 'data', 6),
- (util.VN_CURDATE(), util.VN_CURDATE(), '127', 'data', 7),
- (util.VN_CURDATE(), util.VN_CURDATE(), '128', 'data', 8),
- (util.VN_CURDATE(), util.VN_CURDATE(), '129', 'data', 9);
-
-INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`)
- VALUES
- (1, 1101, 'contact 1', 666777888),
- (2, 1101, 'contact 2', 111222333),
- (3, 1101, 'contact 3', 222333444),
- (4, 1102, 'contact 1', 876543219);
-
-INSERT INTO `vn`.`workerManaExcluded`(`workerFk`)
- VALUES
- (9);
-/*
- el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes,
- pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto
-
- La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets
-*/
-
-call vn.manaSpellersRequery(19);
-call vn.manaSpellersRequery(18);
-
-INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`)
- VALUES
- (1, 1101, 1, util.VN_CURDATE(), 18, 18, 442),
- (2, 1101, 1, util.VN_CURDATE(), 18, 18, 442),
- (3, 1101, 2, util.VN_CURDATE(), 18, 18, 442),
- (4, 1102, 2, util.VN_CURDATE(), 18, 18, 567),
- (5, 1102, 3, util.VN_CURDATE(), 19, 19, 567);
-
-INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
- VALUES
- ( 1, 'pending', 'Pendiente', 1, 1, 0),
- ( 2, 'managed', 'Gestionado', 72, 5, 0),
- ( 3, 'resolved', 'Resuelto', 72, 7, 0),
- ( 4, 'canceled', 'Anulado', 72, 6, 1),
- ( 5, 'incomplete', 'Incompleta', 1, 3, 1),
- ( 6, 'mana', 'Mana', 72, 4, 0),
- ( 7, 'lack', 'Faltas', 72, 2, 0);
-
-INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`, `ticketFk`)
- VALUES
- (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183', 11),
- (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL, 16),
- (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL, 7),
- (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL, 8);
-
-INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`)
- VALUES
- (1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE()),
- (2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE()),
- (3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE()),
- (4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE());
-
-INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`)
- VALUES
- (1, 1, 7, 5),
- (2, 2, 10, 10),
- (3, 3, 22, 1),
- (4, 4, 13, 5);
-
-INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`)
- VALUES
- (1, 'Bueno', NULL),
- (2, 'Basura/Perd.', 12),
- (3, 'Confeccion', NULL),
- (4, 'Reclam.PRAG', 12),
- (5, 'Corregido', 11);
-
-INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`)
- VALUES
- (1, 1, 1, 21, 1, 1, 2, 5),
- (2, 1, 2, 21, 7, 2, 2, 5),
- (3, 2, 7, 21, 9, 3, 2, 5),
- (4, 3, 7, 21, 15, 8, 2, 5),
- (5, 4, 7, 21, 7, 8, 2, 5);
-
-INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestinationFk`)
- VALUES
- (1, 31, 4, 21, 2),
- (2, 32, 3, 21, 3);
-
-INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
- VALUES
- (1, 50),
- (2, 30);
-
-INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
- VALUES
- (1101, 500, NULL, 0.00, 0.00, 1.00),
- (1102, 1000, 2.00, 0.01, 0.05, 1.00),
- (1103, 2000, 0.00, 0.00, 0.02, 1.00),
- (1104, 2500, 150.00, 0.02, 0.10, 1.00);
-
-INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`)
- VALUES
- (1, '02676A049183', DEFAULT, 1106),
- (2, '02676A049183', DEFAULT, 1106),
- (3, '02676A049183', DEFAULT, 1107),
- (4, '02676A049183', DEFAULT, 1107),
- (5, '01837B023653', DEFAULT, 1106);
-
-INSERT INTO `vn`.`claimLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`)
- VALUES
- (1, 18, 'update', 'Claim', '{"hasToPickUp":false}', '{"hasToPickUp":true}', 1, NULL),
- (1, 18, 'update', 'ClaimObservation', '{}', '{"claimFk":1,"text":"Waiting for customer"}', 1, NULL),
- (1, 18, 'insert', 'ClaimBeginning', '{}', '{"claimFk":1,"saleFk":1,"quantity":10}', 1, NULL),
- (1, 18, 'insert', 'ClaimDms', '{}', '{"claimFk":1,"dmsFk":1}', 1, NULL);
-
-INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`)
- VALUES
- (1, 'Arkham Bank', 442, 1, 'h12387193H10238'),
- (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad');
-
-INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`)
- VALUES
- (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()),
- (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()),
- (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()),
- (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', util.VN_CURDATE()),
- (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', util.VN_CURDATE()),
- (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', util.VN_CURDATE());
-
-INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
- VALUES
- (1, 1),
- (2, 2),
- (3, 3),
- (4, 4),
- (5, 5),
- (6, 6),
- (7, 7),
- (8, 8),
- (9, 9),
- (10, 10),
- (11, 11),
- (12, 12),
- (13, 13),
- (14, 14),
- (15, 15),
- (16, 16),
- (17, 17),
- (18, 18),
- (19, 19),
- (20, 20),
- (21, 21),
- (22, 22);
-
-INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
- VALUES
- (1, 1, 69),
- (5, 1, 442),
- (9, 1, 442),
- (18, 3, 567);
-
-INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`)
- VALUES
- (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1),
- (2, 'Cobro web', 200.50, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 442, 1),
- (3, 'Cobro en efectivo', 300.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 442, 0),
- (4, 'Cobro en efectivo', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0),
- (5, 'Compensación', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 3, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0);
-
-INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`)
- VALUES
- (1, 1, 9),
- (2, 2, 18),
- (3, 2, 19),
- (4, 3, 1101),
- (5, 3, 1102),
- (6, 4, 1103),
- (7, 4, 1104);
-
-INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`)
- VALUES
- (1, 'Ranged weapon longbow 200cm', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
- (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
- (3, 'Melee weapon heavy shield 100cm', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()),
- (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()),
- (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE());
-
-INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenseFk`)
- VALUES
- (1, 'Porte Agencia', 7001000000),
- (2, 'Portes Retorno', 7001000000),
- (3, 'Porte Carry', 7001000000),
- (4, 'Cargo FITOSANITARIO', 4751000000),
- (5, 'Documentos', 2000000000);
-
-INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`, `ticketServiceTypeFk`)
- VALUES
- (1, 'Documentos', 1, 2.00, 1, 1, 1),
- (2, 'Porte Agencia', 1, 10.00, 1, 2, 1),
- (3, 'Documentos', 1, 5.50, 1, 11, 1),
- (4, 'Documentos', 1, 2.00, 1, 9, 1),
- (5, 'Documentos', 1, 2.00, 1, 8, 1);
-
-INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
- VALUES
- (1, 1010),
- (3, 1101),
- (5, 1102),
- (9, 1201);
-
-INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`)
- VALUES
- (1, 'employee', NULL, NULL),
- (2, 'florist', NULL, NULL);
-
-INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
- VALUES
- (1, 'General schedule', 40, 0);
-
-INSERT INTO `vn`.`workerBusinessAgreement` (`id`, `name`, `monthHolidays`, `yearHours`, `started`, `ended`)
- VALUES(1, 'flowers', 2.5, 1830, '2001-01-01', NULL);
-
-DROP TEMPORARY TABLE IF EXISTS tmp.worker;
-CREATE TEMPORARY TABLE tmp.worker
- (PRIMARY KEY (id))
- ENGINE = MEMORY
- SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-12-25') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
- FROM `vn`.`worker` `w`;
-
-INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`)
- SELECT * FROM tmp.worker;
-
-DROP TEMPORARY TABLE IF EXISTS tmp.worker;
-CREATE TEMPORARY TABLE tmp.worker
- (PRIMARY KEY (id))
- ENGINE = MEMORY
- SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
- FROM `vn`.`worker` `w`
- WHERE `w`.`id` = 1109;
-
-INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`)
- SELECT * FROM tmp.worker;
-
-DROP TEMPORARY TABLE IF EXISTS tmp.worker;
-
-UPDATE `vn`.`business`
- SET `payedHolidays`= 8
- WHERE `id`= 1106;
-
-UPDATE `vn`.`business` b
- SET b.`workerBusinessProfessionalCategoryFk` = 2
- WHERE b.`workerFk` = 1110;
-
-UPDATE `vn`.`business` b
- SET b.`departmentFk` = 43
- WHERE b.id IN(18, 19);
-
-UPDATE `vn`.`business` b
- SET b.`started` = b.`started` - INTERVAL 100 DAY
- WHERE b.id = 1107;
-
-INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
- VALUES
- ('1', '27.5', YEAR(util.VN_CURDATE())),
- ('5', '22', YEAR(util.VN_CURDATE())),
- ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))),
- ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)));
-
-INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`)
- VALUES
- (1, 'CONTRATO HOLANDA', 1, 0, 1),
- (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1),
- (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1);
-
-UPDATE `vn`.`business` b
- SET `rate` = 7,
- `workerBusinessTypeFk` = 100,
- `amount` = 900.50
- WHERE b.id = 1;
-
-UPDATE `vn`.`business` b
- SET `rate` = 7,
- `workerBusinessTypeFk` = 100,
- `amount` = 1263.03
- WHERE b.id = 1106;
-
-UPDATE `vn`.`business` b
- SET `rate` = 7,
- `workerBusinessTypeFk` = 100,
- `amount` = 2000
- WHERE b.id = 1107;
-
-UPDATE `vn`.`business` b
- SET `rate` = 7,
- `workerBusinessTypeFk` = 100,
- `amount` = 1500
- WHERE b.id = 1108;
-
-INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
- VALUES
- (1, 'Holidays', '#FF4444', 'holiday', 0, 0),
- (2, 'Leave of absence', '#C71585', 'absence', 0, 1),
- (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5),
- (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1),
- (20, 'Furlough', '#97B92F', 'furlough', 1, 1),
- (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1);
-
-INSERT INTO `vn`.`calendar` (`businessFk`, `dayOffTypeFk`, `dated`)
- VALUES
- (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)),
- (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)),
- (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)),
- (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)),
- (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)),
- (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)),
- (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)),
- (1107, 2, util.VN_CURDATE() - INTERVAL 16 DAY);
-
-INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
- VALUES
- ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523');
-
-INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`)
- VALUES
- (1, 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1101),
- (2, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1106);
-
-INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`)
- VALUES
- (1, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY));
-
-CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons
-
-INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
- VALUES
- (1, 3, 0),
- (1, 4, 0),
- (1, 5, 0),
- (1, 1, 1),
- (2, 3, 0),
- (2, 4, 0),
- (2, 5, 0),
- (2, 1, 1),
- (3, 3, 0),
- (3, 4, 0),
- (3, 5, 0),
- (3, 1, 1),
- (4, 3, 0),
- (4, 4, 0),
- (4, 5, 0),
- (4, 1, 1),
- (5, 3, 1),
- (5, 4, 0),
- (5, 5, 1),
- (5, 1, 1),
- (6, 3, 1),
- (6, 4, 0),
- (6, 5, 1),
- (6, 1, 1),
- (7, 3, 0),
- (7, 4, 0),
- (7, 5, 0),
- (7, 1, 1),
- (8, 3, 0),
- (8, 4, 0),
- (8, 5, 0),
- (8, 1, 1),
- (9, 7, 1),
- (10, 14, 1);
-
-INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`)
- VALUES
- (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
- (3, 'day', util.VN_CURDATE()),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
- (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
- (4, 'day', util.VN_CURDATE()),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
- (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
- (5, 'day', util.VN_CURDATE()),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
- (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
- (6, 'day', util.VN_CURDATE()),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
- (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
- (7, 'day', util.VN_CURDATE()),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
- (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY));
-
-INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`)
- VALUES
- (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'),
- (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun');
-
-INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`, `weekDays`)
- VALUES
- (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR), 'mon'),
- (9, 'range', util.VN_CURDATE(), NULL, 'tue'),
- (9, 'range', NULL, util.VN_CURDATE(), 'wed');
-
-INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `isSendMail`)
- VALUES
- (1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in', 0),
- (1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle', 0),
- (1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 0),
- (1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 0),
- (1107, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in', 1),
- (1107, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle', 1),
- (1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1),
- (1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1);
-
-INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
- VALUES
- (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'),
- (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'),
- (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'),
- (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'),
- (5, 'Otros', 'otros', 1, 1, 'miscellaneous'),
- (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'),
- (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'),
- (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'),
- (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'),
- (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'),
- (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'),
- (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'),
- (13, 'Basura', 'basura', 1, 1, 'trash'),
- (14, 'Ticket', 'tickets', 1, 1, 'ticket'),
- (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'),
- (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
- (17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
- (18, 'dua', 'dua', NULL, NULL, 'dua'),
- (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'),
- (20, 'Reclamación', 'reclamacion', 1, 1, 'claim');
-
-INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
- VALUES
- (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', util.VN_CURDATE()),
- (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()),
- (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()),
- (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()),
- (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
- (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
- (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
- (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE());
-
-INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
- VALUES
- (1, 7),
- (1, 8);
-
-INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`)
- VALUES
- (11, 1);
-
-INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
- VALUES
- (1104, 2),
- (1104, 3);
-
-INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`)
- VALUES
- (1, 1106, 4, TRUE),
- (2, 1107, 3, FALSE);
-
-INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`)
- VALUES
- ('aaa', 'android', '9');
-
-INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`)
- VALUES
- (1, 'Alta', 'high'),
- (2, 'Normal', 'normal'),
- (3, 'Baja', 'low');
-
-INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
- VALUES
- (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
-
-INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
-
-INSERT INTO `vn`.`thermograph`(`id`, `model`)
- VALUES
- ('TMM190901395', 'TEMPMATE'),
- ('TL.BBA85422', 'TL30'),
- ('TZ1905012010', 'DISPOSABLE'),
- ('138350-0', 'DISPOSABLE');
-
-
-INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`)
- VALUES
- ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
- ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
- ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
- ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
- ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5),
- ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL);
-
-REPLACE INTO `vn`.`incoterms`(`code`, `name`)
- VALUES
- ('FAS', 'Free Alongside Ship');
-
-REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`)
- VALUES
- (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'),
- (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com');
-
-INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`)
- VALUES
- ('1', 'TEST', 'ON THE FIXTURES', '0'),
- ('2', 'DEV', 'OTHER TABLET', '0');
-
-INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`)
- VALUES
- (1, 23),
- (2, 1);
-
-INSERT INTO `vn`.`campaign`(`code`, `dated`)
- VALUES
- ('valentinesDay', CONCAT(YEAR(util.VN_CURDATE()), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-02-14')),
- ('mothersDay', CONCAT(YEAR(util.VN_CURDATE()), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-05-05')),
- ('allSaints', CONCAT(YEAR(util.VN_CURDATE()), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-11-01'));
-
-INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`)
- VALUES
- (1, 4, 160, 160);
-
-INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`)
- VALUES
- (36, 31, 25, 21);
-
-INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`)
- VALUES
- (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
- (util.VN_CURDATE(), 1, 12, 17, 22, 27);
-
-INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
- VALUES
- (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
- (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
- (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442),
- (4, '19ES00280131955995', 4, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442),
- (5, '19ES00280132022070', 5, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442),
- (6, '19ES00280132032308', 6, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442),
- (7, '19ES00280132025489', 7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442),
- (8, '19ES00280132025490', 8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442),
- (9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
- (10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
-
-INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`)
- VALUES
- (1, 1, 1.00, 1.00, 1.00),
- (2, 2, 1.00, 1.00, 1.00),
- (3, 3, 1.00, 1.00, 1.00),
- (4, 4, 1.00, 1.00, 1.00),
- (5, 5, 1.00, 1.00, 1.00),
- (6, 6, 1.00, 1.00, 1.00),
- (7, 7, 1.00, 1.00, 1.00),
- (8, 8, 1.00, 1.00, 1.00);
-
-REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
- VALUES
- (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
- (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1),
- (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
- (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
- (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1),
- (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
- (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
- (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
- (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
- (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
-
-INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
- VALUES
- (1, -2, '2% retention', 2, 45);
-
-INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`)
- VALUES
- (1, util.VN_CURDATE(), 1, 336.99),
- (1, util.VN_CURDATE(), 1, 15.25),
- (2, util.VN_CURDATE(), 1, 168),
- (2, util.VN_CURDATE(), 1, 55.17),
- (3, util.VN_CURDATE(), 1, 87.95),
- (3, util.VN_CURDATE(), 1, 7.65),
- (4, util.VN_CURDATE(), 1, 373.27),
- (4, util.VN_CURDATE(), 1, 73.36),
- (5, util.VN_CURDATE(), 1, 64.23),
- (6, util.VN_CURDATE(), 1, 32.95),
- (7, util.VN_CURDATE(), 1, 58.64);
-
-INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`)
- VALUES
- (1, 1, 1),
- (2, 2, 2),
- (3, 3, 3),
- (4, 4, 4),
- (5, 5, 5),
- (6, 6, 6),
- (7, 7, 7),
- (8, 8, 8),
- (9, 9, 9),
- (10, 10, 10);
-
-INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenseFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`)
- VALUES
- (1, 99.99, '2000000000', NULL, NULL, NULL),
- (2, 999.99, '2000000000', NULL, NULL, NULL),
- (3, 1000.50, '2000000000', NULL, NULL, NULL),
- (4, 0.50, '2000000000', NULL, NULL, NULL),
- (5, 150.50, '2000000000', NULL, NULL, NULL),
- (1, 252.25, '4751000000', NULL, 7, 61),
- (2, 223.17, '6210000567', NULL, 8, 20),
- (3, 95.60, '7001000000', NULL, 8, 35),
- (4, 446.63, '7001000000', NULL, 6, 61),
- (5, 64.23, '6210000567', NULL, 8, 20),
- (6, 29.95, '7001000000', NULL, 7, 20),
- (7, 58.64, '6210000567', NULL, 8, 20);
-
-INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`)
- VALUES
- (1, 30.50, 5080000, 10.00, 162, 5),
- (1, 10, 6021010, 20.00, 205, 5),
- (2, 13.20, 5080000, 15.00, 580, 5),
- (2, 16.10, 6021010, 25.00, 80, 5);
-
-INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
- SELECT t.id
- FROM vn.ticket t
- LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id
- WHERE tr.ticketFk IS NULL;
-
-CALL `vn`.`ticket_doRecalc`();
-
-UPDATE `vn`.`ticket`
- SET refFk = 'T1111111'
- WHERE id IN (1,2);
-
-UPDATE `vn`.`ticket`
- SET refFk = 'T2222222'
- WHERE id = 3;
-
-UPDATE `vn`.`ticket`
- SET refFk = 'T3333333'
- WHERE id = 4;
-
-UPDATE `vn`.`ticket`
- SET refFk = 'T4444444'
- WHERE id = 5;
-
-UPDATE `vn`.`ticket`
- SET refFk = 'A1111111'
- WHERE id = 6;
-
-INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
- VALUES
- (1, 1, 1),
- (2, 1, 2),
- (3, 6, 5),
- (4, 7, 1);
-
-INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`)
- VALUES
- (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
- (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
- (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
-
-INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`)
- VALUES
- (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
- (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),
- (3, 1, 3, DATE_ADD(util.VN_NOW(), INTERVAL '1 4' DAY_HOUR), 'Third truck in fleet', 1),
- (4, 2, 1, DATE_ADD(util.VN_NOW(), INTERVAL 3 DAY), 'Truck red', 1);
-
-INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`)
- VALUES
- (1, 1, util.VN_CURDATE(), 1, 1);
-
-INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`)
- VALUES
- (1, 1, util.VN_CURDATE(), 1),
- (2, 2, util.VN_CURDATE(), 1),
- (3, 3, util.VN_CURDATE(), 1),
- (4, 4, util.VN_CURDATE(), 1),
- (5, 5, util.VN_CURDATE(), 1),
- (6, 6, util.VN_CURDATE(), 1),
- (7, 7, util.VN_CURDATE(), 1),
- (8, 8, util.VN_CURDATE(), 1),
- (9, 9, util.VN_CURDATE(), 1),
- (10, 10, util.VN_CURDATE(), 1);
-
-CALL `cache`.`last_buy_refresh`(FALSE);
-
-UPDATE `vn`.`item` SET `genericFk` = 9
- WHERE `id` = 2;
-
-INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`)
- VALUES
- (1101, 500, util.VN_CURDATE(), util.VN_CURDATE()),
- (1102, 500, util.VN_CURDATE(), util.VN_CURDATE()),
- (1103, 500, util.VN_CURDATE(), util.VN_CURDATE()),
- (1107, 500, util.VN_CURDATE(), util.VN_CURDATE()),
- (1109, 500, util.VN_CURDATE(), util.VN_CURDATE());
-
-UPDATE `vn`.`route`
- SET `invoiceInFk`=1
- WHERE `id`=1;
-
-UPDATE `vn`.`route`
- SET `invoiceInFk`=2
- WHERE `id`=2;
-
-INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
- VALUES
- (1, 501.95, util.VN_CURDATE(), 2, 1101),
- (2, 70.7, util.VN_CURDATE(), 2, 1101),
- (3, 200.78, util.VN_CURDATE(), 2, 1101),
- (4, 33.8, util.VN_CURDATE(), 1, 1101),
- (30, 34.4, util.VN_CURDATE(), 1, 1108);
-
-INSERT INTO `vn`.`docuwareConfig` (`url`)
- VALUES
- ('http://docuware.url/');
-
-INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`)
- VALUES
- (1, 'dayOfIT');
-
-INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`)
- VALUES
- (1, 'National', '#4169E1');
-
-INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`)
- VALUES
- (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1);
-
-INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
- VALUES
- (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23),
- (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33),
- (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
- (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
- (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
-
-INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`)
- VALUES
- (1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 'sent'),
- (1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending');
-
-
-INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
- VALUES
- ('delivery', '9.2', 0),
- ('warehouse', '8.1', 0);
-
-INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
- VALUES
- ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442),
- ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
-
-INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`)
- VALUES
- (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()),
- (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
- (1106, 2, util.VN_CURDATE(), NULL),
- (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY));
-
-INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
-VALUES
- (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
- (2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
-
-INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
- VALUES
- (2, 1);
-
-INSERT INTO `vn`.`mdbBranch` (`name`)
- VALUES
- ('test'),
- ('master');
-
-INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
- VALUES
- ('tpv', 'test', '1'),
- ('lab', 'master', '1');
-
-INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`)
- VALUES
- (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-01-01'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-01'));
-
-
-INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`)
- VALUES
- (1, 1, 1);
-
-INSERT INTO `vn`.`saleGroupDetail` (`saleFk`, `saleGroupFk`)
- VALUES
- (31, 1);
-
-INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`)
- VALUES
- (1, 1);
-
-INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`)
- VALUES
- (1, 1);
-
-INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`, `maxTimeToBreak`, `maxWorkShortCycle`, `maxWorkLongCycle`)
- VALUES
- (1, 43200, 32400, 129600, 259200, 1080000, '', 'imap.verdnatura.es', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.00, 0.33, 40, '22:00:00', '06:00:00', 72000, 1200, 18000, 72000, 6, 13, 28800, 32400, 3600, 561600, 950400);
-
-INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
- VALUES
- (1, 'pc1', 'pc host', 1, 1);
-
-INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
- VALUES
- (1, 'h1', 1, '');
-
-INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
- VALUES
- ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
-INSERT INTO `util`.`notificationConfig`
- SET `cleanDays` = 90;
-
-INSERT INTO `util`.`notification` (`id`, `name`, `description`)
- VALUES
- (1, 'print-email', 'notification fixture one'),
- (2, 'invoice-electronic', 'A electronic invoice has been generated'),
- (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
- (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
- (5, 'modified-entry', 'An entry has been modified'),
- (6, 'book-entry-deleted', 'accounting entries deleted');
-
-INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
- VALUES
- (1, 9),
- (1, 1),
- (2, 1),
- (3, 9),
- (4, 1),
- (5, 9),
- (6, 9);
-
-INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
- VALUES
- (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
- (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
- (3, 'print-email', null, null, 'pending', util.VN_CURDATE());
-
-INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
- VALUES
- (1, 1109),
- (1, 1110),
- (2, 1110),
- (4, 1110),
- (2, 1109),
- (1, 9),
- (1, 3),
- (6, 9);
-
-
-INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
- VALUES
- (1, 9);
-
-INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`)
- VALUES
- (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6);
-
-INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`)
- VALUES
- (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL);
-
-INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`)
- VALUES
- (0, 0, 24, '', '[1,2,3]', 2, 56, 60);
-
-INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
- VALUES
- (9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
-
-INSERT INTO `vn`.`saleCloned` (`saleClonedFk`, `saleOriginalFk`)
- VALUES
- (29, 25);
-
-UPDATE `account`.`user`
- SET `hasGrant` = 1
- WHERE `id` = 66;
-
-INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`)
- VALUES
- (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 22, NULL),
- (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 22, NULL),
- (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 22, NULL),
- (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 100cm de '5' a '10'"),
- (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 12, 'Shield');
-
-
-INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description)
- VALUES
- (1, NULL, 'delete', '2001-06-09 11:00:04', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL),
- (1, 18, 'select', '2001-06-09 11:00:03', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL),
- (1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 5, 'Armor' , '{"isPicked": false}','{"isPicked": true}', NULL),
- (1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 5, 'Armor' , NULL, NULL, 'Armor quantity changed from ''15'' to ''10'''),
- (1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 4, 'Shield' , '{"quantity":10,"concept":"Shield"}', NULL, NULL),
- (1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 1, 'Armor' , NULL,'{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL),
- (1, 18, 'update', '2000-12-28 08:40:45', 'Ticket', 45, 'Spider Man' , '{"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"isBlocked":false,"hasPriority":false,"companyFk":442,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}','{"warehouseFk":61,"shipped":"2023-05-17T22:00:00.000Z","nickname":"Spider Man","isSigned":false,"isLabeled":false,"isPrinted":false,"packages":1,"hour":0,"isBlocked":true,"hasPriority":true,"companyFk":443,"landed":"2023-05-18T22:00:00.000Z","isBoxed":false,"isDeleted":false,"zoneFk":713,"zonePrice":13,"zoneBonus":1}', NULL),
- (1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL),
- (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 4, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL),
- (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL);
-INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
- VALUES
- (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
-
-INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
- VALUES
- ('foo', 'master', NULL, NULL),
- ('bar', 'test', 9, util.VN_NOW());
-
-INSERT INTO `vn`.`profileType` (`id`, `name`)
- VALUES
- (1, 'working');
-
-INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
- VALUES
- ('lilium', 'development', 'http://localhost:9000/#/'),
- ('hedera', 'development', 'http://localhost:9090/'),
- ('salix', 'development', 'http://localhost:5000/#!/');
-
-INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`)
- VALUES
- (3, 'invoice', NULL, 'InvoiceOuts/{refFk}/invoice-out-pdf');
-
-INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
- VALUES
- (1, 1),
- (2, 20),
- (7, 1);
-
-INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`)
- VALUES
- (1, NULL, 1, 4, 'worker');
-
-INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
- VALUES
- (24, 8);
-
-INSERT INTO `vn`.`deviceProductionModels` (`code`)
- VALUES
- ('BLACKVIEW'),
- ('DODGEE'),
- ('ZEBRA');
-
-INSERT INTO `vn`.`deviceProductionState` (`code`, `description`)
- VALUES
- ('active', 'activo'),
- ('idle', 'inactivo'),
- ('lost', 'perdida'),
- ('repair', 'reparación'),
- ('retired', 'retirada');
-
-INSERT INTO `vn`.`deviceProduction` (`imei`, `modelFk`, `macWifi`, `serialNumber`, `android_id`, `purchased`, `stateFk`, `isInScalefusion`, `description`)
-VALUES
- ('ime1', 'BLACKVIEW', 'macWifi1', 'serialNumber1', 'androidid11234567890', util.VN_NOW(), 'active', 0, NULL),
- ('ime2', 'DODGEE', 'macWifi2', 'serialNumber2', 'androidid21234567890', util.VN_NOW(), 'idle', 0, NULL),
- ('ime3', 'ZEBRA', 'macWifi3', 'serialNumber3', 'androidid31234567890', util.VN_NOW(), 'active', 0, NULL),
- ('ime4', 'BLACKVIEW', 'macWifi4', 'serialNumber4', 'androidid41234567890', util.VN_NOW(), 'idle', 0, NULL);
-
-INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `created`)
- VALUES
- (1, 1, util.VN_NOW()),
- (3, 3, util.VN_NOW());
-
-INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `state`, `updated`, `sendedCounter`, `reason`)
- VALUES
- (1, 9, 2000, 49, 'REVISE', util.VN_NOW(), 1, 'test2'),
- (2, 9, 2000, 50, 'SENDED', util.VN_NOW(), 1, NULL),
- (3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL),
- (4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL);
-
-INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`)
- VALUES
- (1, 1350, 1900, 200, 50, 6);
-
-INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`)
- VALUES
- (1, 'white', '#ffffff'),
- (2, 'red', '#ff0000'),
- (3, 'green', '#00ff00'),
- (4, 'blue', '#0000ff');
-
-INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`)
- VALUES
- (1, 'Wagon Type #1', 1);
-
-INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
- VALUES
- (1, 1, 100, 1),
- (2, 1, 50, 2),
- (3, 1, 0, 3);
-
-INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
- VALUES
- (1, 21600, 60, 300);
-
-INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
- VALUES
- (1, 1, 1, 1, 442);
-
-INSERT INTO `vn`.`buyConfig` (`id`, `monthsAgo`)
- VALUES
- (1, 6);
-
-INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `taxAreaFk`)
- VALUES
- ('C', 'Asgard', 1, 'WORLD'),
- ('E', 'Midgard', 1, 'CEE'),
- ('R', 'Jotunheim', 1, 'NATIONAL'),
- ('W', 'Vanaheim', 1, 'WORLD');
-
-
-INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`)
- VALUES
- (1, 0, 0, 'marvel.com');
-
-INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, BASEEURO, SERIE, FACTURA, IVA, RECEQUIV, CLAVE, CAMBIO, DEBEME, HABERME, AUXILIAR, MONEDAUSO, TIPOOPE, NFACTICK, TERIDNIF, TERNIF, TERNOM, OPBIENES, L340, enlazado, FECHA_EX, LRECT349, empresa_id, LDIFADUAN, METAL, METALIMP, CLIENTE, METALEJE, FECHA_OP, FACTURAEX, TIPOCLAVE, TIPOEXENCI, TIPONOSUJE, TIPOFACT, TIPORECTIF, SERIE_RT, FACTU_RT, BASEIMP_RT, BASEIMP_RF, RECTIFICA, FECHA_RT, FECREGCON, enlazadoSage)
- VALUES
- (1, 1.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T3333333', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
- (2, 1.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T3333333 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
- (3, 1.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T3333333 Tony Stark', NULL, 0.81, 8.07, 'T', '3333333', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1),
- (4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
- (5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
- (6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
-
-INSERT INTO `vn`.`mistakeType` (`id`, `description`)
- VALUES
- (1, 'Incorrect quantity');
-
-INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
- VALUES
- (1, 'Error in VAT calculation'),
- (2, 'Error in sales details'),
- (3, 'Error in customer data');
-
-UPDATE `vn`.`client`
- SET fi='65004204V'
- WHERE id=1;
-
-UPDATE `vn`.`worker`
- SET fi='59328808D'
- WHERE id=1106;
-
-
-INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
- VALUES
- (1, 1),
- (2, 9),
- (3, 15);
-
-INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
- VALUES
- ('Tablet1','Jarvis tablet'),
- ('Tablet2','Avengers tablet');
-
-INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
- VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()),
- (2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()),
- (3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()),
- (4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE());
-
-INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
- VALUES(1, 1103, 1, NULL),
- (2, 1103, 2, NULL),
- (3, 1103, 3, 32),
- (4, 1103, 4, 32),
- (13, 1101, 1, NULL),
- (14, 1101, 4, 27);
diff --git a/db/routines/bs/procedures/clean.sql b/db/routines/bs/procedures/clean.sql
index 3c29553f5..eff2faadb 100644
--- a/db/routines/bs/procedures/clean.sql
+++ b/db/routines/bs/procedures/clean.sql
@@ -1,10 +1,11 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`clean`()
BEGIN
- DECLARE vFourYearsAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
- DECLARE vOneYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
- DECLARE vTwoYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 3 YEAR;
- DECLARE vThreeYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
+
+ DECLARE vOneYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
+ DECLARE vTwoYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
+ DECLARE vThreeYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 3 YEAR;
+ DECLARE vFourYearsAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
DECLARE vEighteenMonths DATE DEFAULT util.VN_CURDATE() - INTERVAL 18 MONTH;
DELETE FROM clientNewBorn
diff --git a/db/routines/bs/triggers/clientNewBorn_BEFORE_UPDATE.sql b/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
similarity index 92%
rename from db/routines/bs/triggers/clientNewBorn_BEFORE_UPDATE.sql
rename to db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
index ac68eedb8..a88567a21 100644
--- a/db/routines/bs/triggers/clientNewBorn_BEFORE_UPDATE.sql
+++ b/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`clientNewBorn_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`clientNewBorn_beforeUpdate`
BEFORE UPDATE ON `clientNewBorn`
FOR EACH ROW
BEGIN
diff --git a/db/routines/bs/triggers/nightTaskBeforeInsert.sql b/db/routines/bs/triggers/nightTask_beforeInsert.sql
similarity index 94%
rename from db/routines/bs/triggers/nightTaskBeforeInsert.sql
rename to db/routines/bs/triggers/nightTask_beforeInsert.sql
index b32aaf7f5..96f2b5291 100644
--- a/db/routines/bs/triggers/nightTaskBeforeInsert.sql
+++ b/db/routines/bs/triggers/nightTask_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTaskBeforeInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTask_beforeInsert`
BEFORE INSERT ON `nightTask`
FOR EACH ROW
BEGIN
diff --git a/db/routines/bs/triggers/nightTaskBeforeUpdate.sql b/db/routines/bs/triggers/nightTask_beforeUpdate.sql
similarity index 94%
rename from db/routines/bs/triggers/nightTaskBeforeUpdate.sql
rename to db/routines/bs/triggers/nightTask_beforeUpdate.sql
index fd7fdc0df..1da1da8c3 100644
--- a/db/routines/bs/triggers/nightTaskBeforeUpdate.sql
+++ b/db/routines/bs/triggers/nightTask_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTaskBeforeUpdate`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTask_beforeUpdate`
BEFORE UPDATE ON `nightTask`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql
index d07f45ba8..920226693 100644
--- a/db/routines/edi/procedures/ekt_load.sql
+++ b/db/routines/edi/procedures/ekt_load.sql
@@ -1,7 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_load`(IN `vSelf` INT)
proc:BEGIN
-
+/**
+ * Carga los datos esenciales para el sistema EKT.
+ * Inserta compras y ventas si es necesario.
+ *
+ * @param vSelf Id de ekt
+ */
DECLARE vRef INT;
DECLARE vBuy INT;
DECLARE vItem INT;
@@ -9,42 +14,37 @@ proc:BEGIN
DECLARE vPackage INT;
DECLARE vPutOrderFk INT;
DECLARE vIsLot BOOLEAN;
- DECLARE vForceToPacking INT DEFAULT 2;
- DECLARE vEntryFk INT;
- DECLARE vHasToChangePackagingFk BOOLEAN;
- DECLARE vIsFloramondoDirect BOOLEAN;
- DECLARE vTicketFk INT;
+ DECLARE vForceToPacking INT DEFAULT 2;
+ DECLARE vEntryFk INT;
+ DECLARE vHasToChangePackagingFk BOOLEAN;
+ DECLARE vIsFloramondoDirect BOOLEAN;
+ DECLARE vTicketFk INT;
DECLARE vHasItemGroup BOOL;
DECLARE vDescription VARCHAR(255);
DECLARE vSaleFk INT;
-- Carga los datos necesarios del EKT
-
- SELECT e.ref, qty, package, putOrderFk MOD 1000000, i2.id , NOT ISNULL(eea.addressFk), NOT ISNULL(igto.group_code),
+ SELECT e.ref, qty, package, putOrderFk MOD 1000000, i2.id , NOT ISNULL(eea.addressFk), NOT ISNULL(igto.group_code),
CONCAT(e.`ref`, ' ', e.item, ' ', e.sub, ' EktFk:', e.id)
INTO vRef, vQty, vPackage, vPutOrderFk, vItem, vIsFloramondoDirect, vHasItemGroup, vDescription
- FROM edi.ekt e
- LEFT JOIN edi.item i ON e.ref = i.id
- LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk
+ FROM ekt e
+ LEFT JOIN item i ON e.ref = i.id
+ LEFT JOIN putOrder po ON po.id = e.putOrderFk
LEFT JOIN vn.item i2 ON i2.supplyResponseFk = po.supplyResponseID
LEFT JOIN vn.ektEntryAssign eea ON eea.sub = e.sub
- LEFT JOIN edi.item_groupToOffer igto ON igto.group_code = i.group_id
+ LEFT JOIN item_groupToOffer igto ON igto.group_code = i.group_id
WHERE e.id = vSelf
LIMIT 1;
-
+
IF NOT vHasItemGroup THEN
-
CALL vn.mail_insert('logistica@verdnatura.es', 'nocontestar@verdnatura.es', 'Nuevo grupo en Floramondo', vDescription);
-
CALL vn.mail_insert('pako@verdnatura.es', 'nocontestar@verdnatura.es', CONCAT('Nuevo grupo en Floramondo: ', vDescription), vDescription);
-
LEAVE proc;
-
END IF;
-- Asigna la entrada
- SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk;
-
+ SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk;
+
-- Inserta el cubo si no existe
IF vPackage = 800 THEN
@@ -57,7 +57,7 @@ proc:BEGIN
ELSE
- SET vPackage = 8000 + vQty;
+ SET vPackage = 8000 + vQty;
INSERT IGNORE INTO vn.packaging(id, width, `depth`)
SELECT vPackage, vc.ccLength / vQty, vc.ccWidth
@@ -79,29 +79,25 @@ proc:BEGIN
`to` = 'ekt@verdnatura.es';
END IF;
END IF;
-
+
-- Si es una compra de Logiflora obtiene el articulo
IF vPutOrderFk THEN
-
SELECT i.id INTO vItem
- FROM edi.putOrder po
+ FROM putOrder po
JOIN vn.item i ON i.supplyResponseFk = po.supplyResponseID
WHERE po.id = vPutOrderFk
LIMIT 1;
-
END IF;
- INSERT IGNORE INTO item_track SET
- item_id = vRef;
+ INSERT IGNORE INTO item_track
+ SET item_id = vRef;
- IF IFNULL(vItem,0) = 0 THEN
-
+ IF vItem IS NULL THEN
-- Intenta obtener el artículo en base a los atributos holandeses
-
SELECT b.id, IFNULL(b.itemOriginalFk ,b.itemFk) INTO vBuy, vItem
- FROM edi.ekt e
- JOIN edi.item_track t ON t.item_id = e.ref
- LEFT JOIN edi.ekt l ON l.ref = e.ref
+ FROM ekt e
+ JOIN item_track t ON t.item_id = e.ref
+ LEFT JOIN ekt l ON l.ref = e.ref
LEFT JOIN vn.buy b ON b.ektFk = l.id
LEFT JOIN vn.item i ON i.id = b.itemFk
JOIN vn2008.config cfg
@@ -125,51 +121,44 @@ proc:BEGIN
LIMIT 1;
END IF;
-
+
-- Si no encuentra el articulo lo crea en el caso de las compras directas en Floramondo
- IF ISNULL(vItem) AND vIsFloramondoDirect THEN
-
- CALL edi.item_getNewByEkt(vSelf, vItem);
-
+ IF vItem IS NULL AND vIsFloramondoDirect THEN
+ CALL item_getNewByEkt(vSelf, vItem);
END IF;
- INSERT INTO vn.buy
- (
- entryFk
- ,ektFk
- ,buyingValue
- ,itemFk
- ,stickers
- ,packing
- ,`grouping`
- ,quantity
- ,groupingMode
- ,packagingFk
- ,weight
- )
- SELECT
- vEntryFk
- ,vSelf
- ,(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue
- ,IFNULL(vItem, cfg.generic_item) itemFk
- ,e.qty stickers
- ,@pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing
- ,IFNULL(b.`grouping`, e.pac)
- ,@pac * e.qty
- ,vForceToPacking
- ,IF(vHasToChangePackagingFk OR ISNULL(b.packagingFk), vPackage, b.packagingFk)
- ,(IFNULL(i.weightByPiece,0) * @pac)/1000
- FROM edi.ekt e
- LEFT JOIN vn.buy b ON b.id = vBuy
- LEFT JOIN vn.item i ON i.id = b.itemFk
- LEFT JOIN vn.supplier s ON e.pro = s.id
- JOIN vn2008.config cfg
- WHERE e.id = vSelf
- LIMIT 1;
+ INSERT INTO vn.buy (
+ entryFk,
+ ektFk,
+ buyingValue,
+ itemFk,
+ stickers,
+ packing,
+ `grouping`,
+ quantity,
+ groupingMode,
+ packagingFk,
+ weight)
+ SELECT vEntryFk,
+ vSelf,
+ (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue,
+ IFNULL(vItem, cfg.generic_item) itemFk,
+ e.qty stickers,
+ @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing,
+ IFNULL(b.`grouping`, e.pac),
+ @pac * e.qty,
+ vForceToPacking,
+ IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk),
+ (IFNULL(i.weightByPiece, 0) * @pac) / 1000
+ FROM ekt e
+ LEFT JOIN vn.buy b ON b.id = vBuy
+ LEFT JOIN vn.item i ON i.id = b.itemFk
+ LEFT JOIN vn.supplier s ON e.pro = s.id
+ JOIN vn2008.config cfg
+ WHERE e.id = vSelf
+ LIMIT 1;
- DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
-
- CREATE TEMPORARY TABLE tmp.buyRecalc
+ CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc
SELECT buy.id
FROM vn.buy
WHERE ektFk = vSelf;
@@ -178,31 +167,26 @@ proc:BEGIN
-- Si es una compra de Logiflora hay que informar la tabla vn.saleBuy
IF vPutOrderFk THEN
-
REPLACE vn.saleBuy(saleFk, buyFk, workerFk)
SELECT po.saleFk, b.id, account.myUser_getId()
- FROM edi.putOrder po
+ FROM putOrder po
JOIN vn.buy b ON b.ektFk = vSelf
WHERE po.id = vPutOrderFk;
-
END IF;
- -- Si es una compra directa en Floramondo hay que añadirlo al ticket
+ -- Si es una compra directa en Floramondo hay que añadirlo al ticket
IF vIsFloramondoDirect THEN
-
SELECT t.id INTO vTicketFk
- FROM vn.ticket t
- JOIN vn.ektEntryAssign eea
- ON eea.addressFk = t.addressFk
+ FROM vn.ticket t
+ JOIN vn.ektEntryAssign eea ON eea.addressFk = t.addressFk
AND t.warehouseFk = eea.warehouseInFk
- JOIN edi.ekt e
- ON e.sub = eea.sub
+ JOIN ekt e ON e.sub = eea.sub
AND e.id = vSelf
- WHERE e.fec = t.shipped
- LIMIT 1;
+ WHERE e.fec = t.shipped
+ LIMIT 1;
- IF ISNULL(vTicketFk) THEN
-
+ IF vTicketFk IS NULL THEN
+ SET @clientFk = NULL;
INSERT INTO vn.ticket (
clientFk,
shipped,
@@ -214,21 +198,19 @@ proc:BEGIN
landed,
zoneFk,
zonePrice,
- zoneBonus
- )
- SELECT
- a.clientFk,
- e.fec,
- a.id,
- a.agencyModeFk,
- a.nickname,
- eea.warehouseInFk,
- c.id,
- e.fec,
- z.id,
- z.price,
- z.bonus
- FROM edi.ekt e
+ zoneBonus)
+ SELECT @clientFk := a.clientFk,
+ e.fec,
+ a.id,
+ a.agencyModeFk,
+ a.nickname,
+ eea.warehouseInFk,
+ c.id,
+ e.fec,
+ z.id,
+ z.price,
+ z.bonus
+ FROM ekt e
JOIN vn.ektEntryAssign eea ON eea.sub = e.sub
JOIN vn.address a ON a.id = eea.addressFk
JOIN vn.company c ON c.code = 'VNL'
@@ -237,40 +219,37 @@ proc:BEGIN
LIMIT 1;
SET vTicketFk = LAST_INSERT_ID();
-
- INSERT INTO vn.ticketLog
- SET originFk = vTicketFk,
- userFk = account.myUser_getId(),
- `action` = 'insert',
- description = CONCAT('EktLoad ha creado el ticket:', ' ', vTicketFk);
+ IF @clientFk IS NULL THEN
+ CALL util.throw(CONCAT("Ticket creation failed: ", vSelf));
+ END IF;
END IF;
INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, price)
SELECT vItem, vTicketFk, e.item, e.qty * e.pac, e.pri * ( 1 + fhc.floramondoMargin )
- FROM edi.ekt e
- JOIN edi.floraHollandConfig fhc
- WHERE e.id = vSelf;
-
+ FROM ekt e
+ JOIN floraHollandConfig fhc
+ WHERE e.id = vSelf;
+
SELECT LAST_INSERT_ID() INTO vSaleFk;
-
+
REPLACE vn.saleBuy(saleFk, buyFk, workerFk)
SELECT vSaleFk, b.id, account.myUser_getId()
FROM vn.buy b
- WHERE b.ektFk = vSelf;
+ WHERE b.ektFk = vSelf;
INSERT INTO vn.saleComponent(saleFk, componentFk, value)
SELECT vSaleFk, c.id, e.pri
- FROM edi.ekt e
+ FROM ekt e
JOIN vn.component c ON c.code = 'purchaseValue'
- WHERE e.id = vSelf;
-
+ WHERE e.id = vSelf;
+
INSERT INTO vn.saleComponent(saleFk, componentFk, value)
SELECT vSaleFk, c.id, e.pri * fhc.floramondoMargin
- FROM edi.ekt e
- JOIN edi.floraHollandConfig fhc
+ FROM ekt e
+ JOIN floraHollandConfig fhc
JOIN vn.component c ON c.code = 'margin'
- WHERE e.id = vSelf;
+ WHERE e.id = vSelf;
END IF;
DROP TEMPORARY TABLE tmp.buyRecalc;
END$$
diff --git a/db/routines/edi/triggers/item_feature_bi.sql b/db/routines/edi/triggers/item_feature_beforeInsert.sql
similarity index 90%
rename from db/routines/edi/triggers/item_feature_bi.sql
rename to db/routines/edi/triggers/item_feature_beforeInsert.sql
index 81d16d0c8..4e3e9cc0e 100644
--- a/db/routines/edi/triggers/item_feature_bi.sql
+++ b/db/routines/edi/triggers/item_feature_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`item_feature_bi`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`item_feature_beforeInsert`
BEFORE INSERT ON `item_feature`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/putOrder_AFTER_UPDATE.sql b/db/routines/edi/triggers/putOrder_afterUpdate.sql
similarity index 99%
rename from db/routines/edi/triggers/putOrder_AFTER_UPDATE.sql
rename to db/routines/edi/triggers/putOrder_afterUpdate.sql
index fa34425c9..b56ae4c66 100644
--- a/db/routines/edi/triggers/putOrder_AFTER_UPDATE.sql
+++ b/db/routines/edi/triggers/putOrder_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_afterUpdate`
AFTER UPDATE ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/putOrder_BEFORE_INSERT.sql b/db/routines/edi/triggers/putOrder_beforeInsert.sql
similarity index 93%
rename from db/routines/edi/triggers/putOrder_BEFORE_INSERT.sql
rename to db/routines/edi/triggers/putOrder_beforeInsert.sql
index c1ac76df5..beddd191c 100644
--- a/db/routines/edi/triggers/putOrder_BEFORE_INSERT.sql
+++ b/db/routines/edi/triggers/putOrder_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_beforeInsert`
BEFORE INSERT ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/BEFORE UPDATE.sql b/db/routines/edi/triggers/putOrder_beforeUpdate.sql
similarity index 91%
rename from db/routines/edi/triggers/BEFORE UPDATE.sql
rename to db/routines/edi/triggers/putOrder_beforeUpdate.sql
index 1ba9b4b0f..f18b77a0c 100644
--- a/db/routines/edi/triggers/BEFORE UPDATE.sql
+++ b/db/routines/edi/triggers/putOrder_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`BEFORE UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_beforeUpdate`
BEFORE UPDATE ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/supplyResponse_AFTER_UPDATE.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
similarity index 96%
rename from db/routines/edi/triggers/supplyResponse_AFTER_UPDATE.sql
rename to db/routines/edi/triggers/supplyResponse_afterUpdate.sql
index f4115cbb3..389ef9f1c 100644
--- a/db/routines/edi/triggers/supplyResponse_AFTER_UPDATE.sql
+++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`supplyResponse_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`supplyResponse_afterUpdate`
AFTER UPDATE ON `supplyResponse`
FOR EACH ROW
BEGIN
diff --git a/db/routines/sage/procedures/accountingMovements_add.sql b/db/routines/sage/procedures/accountingMovements_add.sql
index ab0477823..bd86e132d 100644
--- a/db/routines/sage/procedures/accountingMovements_add.sql
+++ b/db/routines/sage/procedures/accountingMovements_add.sql
@@ -22,7 +22,6 @@ BEGIN
DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ;
- DECLARE vBookEntries TEXT;
SELECT SiglaNacion INTO vCountryCanariasCode
FROM Naciones
@@ -412,40 +411,5 @@ BEGIN
AND importeDivisa > 0
AND ImporteAsiento < 0;
- -- Comprobación que los importes e ivas sean correctos, avisa vía CAU
- SELECT GROUP_CONCAT(Asiento ORDER BY Asiento ASC SEPARATOR ',') INTO vBookEntries
- FROM(SELECT sub.Asiento
- FROM (SELECT mc.Asiento, SUM(mc.ImporteAsiento) amount
- FROM movConta mc
- WHERE mc.enlazadoSage = FALSE
- GROUP BY mc.Asiento)sub
- JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount
- FROM vn.XDiario x
- WHERE x.enlazadoSage = FALSE
- GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento
- WHERE sub.amount <> sub2.amount
- UNION ALL
- SELECT sub.Asiento
- FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase
- FROM movConta
- WHERE TipoFactura <> 'I'
- AND enlazadoSage = FALSE
- GROUP BY Asiento) sub
- JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase
- FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO
- FROM vn.XDiario
- WHERE FACTURA
- AND auxiliar <> '*'
- AND enlazadoSage = FALSE
- GROUP BY FACTURA, ASIEN)sub3
- GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento
- WHERE sub.amountTaxableBase<>sub2.amountTaxableBase
- AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase) sub;
-
- IF vBookEntries IS NOT NULL THEN
- SELECT util.notification_send ("book-entries-imported-incorrectly",
- CONCAT('{"bookEntries":"', vBookEntries,'"}'),
- null);
- END IF;
END$$
DELIMITER ;
diff --git a/db/routines/sage/procedures/clean.sql b/db/routines/sage/procedures/clean.sql
new file mode 100644
index 000000000..f1175c4dc
--- /dev/null
+++ b/db/routines/sage/procedures/clean.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clean`()
+BEGIN
+/**
+ * Maintains tables over time by removing unnecessary data
+ */
+ DECLARE vTwoYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
+
+ DELETE FROM movConta WHERE FechaAsiento < vTwoYearAgo;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/sage/procedures/importErrorNotification.sql b/db/routines/sage/procedures/importErrorNotification.sql
new file mode 100644
index 000000000..b070097f4
--- /dev/null
+++ b/db/routines/sage/procedures/importErrorNotification.sql
@@ -0,0 +1,62 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`importErrorNotification`()
+BEGIN
+/**
+ * Inserta notificaciones con los errores detectados durante la importación
+ *
+ */
+ DECLARE vBookEntries TEXT;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SELECT GROUP_CONCAT(error SEPARATOR ' ') INTO vBookEntries
+ FROM(
+ SELECT CONCAT('- Importes: ', sub.Asiento) error
+ FROM (SELECT mc.Asiento, SUM(mc.ImporteAsiento) amount
+ FROM movConta mc
+ WHERE mc.enlazadoSage = FALSE
+ GROUP BY mc.Asiento)sub
+ JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount
+ FROM vn.XDiario x
+ WHERE x.enlazadoSage = FALSE
+ GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amount <> sub2.amount
+ UNION ALL
+ SELECT CONCAT('- Base imponible: ', sub.Asiento)
+ FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase
+ FROM movConta
+ WHERE TipoFactura <> 'I'
+ AND enlazadoSage = FALSE
+ GROUP BY Asiento) sub
+ JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase
+ FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO
+ FROM vn.XDiario
+ WHERE FACTURA
+ AND auxiliar <> '*'
+ AND enlazadoSage = FALSE
+ GROUP BY FACTURA, ASIEN)sub3
+ GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amountTaxableBase<>sub2.amountTaxableBase
+ AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase
+ UNION ALL
+ SELECT CONCAT('- Factura Duplicada: ', mc.Asiento)
+ FROM accountingEntryError
+ )sub;
+
+ IF vBookEntries IS NOT NULL THEN
+ START TRANSACTION;
+
+ SELECT util.notification_send ("book-entries-imported-incorrectly",
+ CONCAT('{"bookEntries":"', vBookEntries,'"}'),
+ null);
+
+ TRUNCATE accountingEntryError;
+
+ COMMIT;
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/sage/triggers/movConta_BEFORE_UPDATE.sql b/db/routines/sage/triggers/movConta_beforeUpdate.sql
similarity index 92%
rename from db/routines/sage/triggers/movConta_BEFORE_UPDATE.sql
rename to db/routines/sage/triggers/movConta_beforeUpdate.sql
index 0b7a30fe1..316b28b7f 100644
--- a/db/routines/sage/triggers/movConta_BEFORE_UPDATE.sql
+++ b/db/routines/sage/triggers/movConta_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `sage`.`movConta_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `sage`.`movConta_beforeUpdate`
BEFORE UPDATE ON `movConta`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/expedition_BU.sql b/db/routines/srt/triggers/expedition_beforeUpdate.sql
similarity index 89%
rename from db/routines/srt/triggers/expedition_BU.sql
rename to db/routines/srt/triggers/expedition_beforeUpdate.sql
index fb557d151..b8933aaf5 100644
--- a/db/routines/srt/triggers/expedition_BU.sql
+++ b/db/routines/srt/triggers/expedition_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`expedition_BU`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`expedition_beforeUpdate`
BEFORE UPDATE ON `expedition`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/moving_AI.sql b/db/routines/srt/triggers/moving_afterInsert.sql
similarity index 97%
rename from db/routines/srt/triggers/moving_AI.sql
rename to db/routines/srt/triggers/moving_afterInsert.sql
index 6c2dcf961..aaa09c99c 100644
--- a/db/routines/srt/triggers/moving_AI.sql
+++ b/db/routines/srt/triggers/moving_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`moving_AI`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`moving_afterInsert`
AFTER INSERT ON `moving`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/events/client_unassignSalesPerson.sql b/db/routines/vn/events/client_unassignSalesPerson.sql
index 4ca8b7de9..46ad414b1 100644
--- a/db/routines/vn/events/client_unassignSalesPerson.sql
+++ b/db/routines/vn/events/client_unassignSalesPerson.sql
@@ -1,8 +1,8 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`jgallego`@`%` EVENT `vn`.`client_unassignSalesPerson`
+CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_unassignSalesPerson`
ON SCHEDULE EVERY 1 DAY
STARTS '2023-06-01 03:30:00.000'
ON COMPLETION PRESERVE
- DISABLE
+ ENABLE
DO CALL client_unassignSalesPerson$$
DELIMITER ;
diff --git a/db/routines/vn/events/sale_checkWithoutComponents.sql b/db/routines/vn/events/sale_checkWithoutComponents.sql
index b67a6f4fa..2a1ced6ca 100644
--- a/db/routines/vn/events/sale_checkWithoutComponents.sql
+++ b/db/routines/vn/events/sale_checkWithoutComponents.sql
@@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`sale_checkWithoutCompon
ON SCHEDULE EVERY 10 MINUTE
STARTS '2020-05-04 11:56:23.000'
ON COMPLETION PRESERVE
- DISABLE
+ ENABLE
DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE))$$
DELIMITER ;
diff --git a/db/routines/vn/functions/workerTimeControl_add.sql b/db/routines/vn/functions/workerTimeControl_add.sql
deleted file mode 100644
index 63c40d7f2..000000000
--- a/db/routines/vn/functions/workerTimeControl_add.sql
+++ /dev/null
@@ -1,57 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`workerTimeControl_add`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL)
- RETURNS int(11)
- DETERMINISTIC
-BEGIN
- DECLARE vDirection VARCHAR(6);
- DECLARE vLastIn DATETIME;
- DECLARE vDayStayMax INT;
- DECLARE vHasDirectionOut INT;
- DECLARE vLastInsertedId INT;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection;
-
- IF vDirection = 'out' THEN
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed < vTimed;
-
- UPDATE workerTimeControl wtc
- SET wtc.direction = 'middle'
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vLastIn AND vTimed;
-
- ELSE IF vDirection = 'in' THEN
-
- SELECT COUNT(*) INTO vHasDirectionOut
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- UPDATE workerTimeControl wtc
- SET wtc.direction = IF (vHasDirectionOut,'middle','out')
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- END IF;
- END IF;
-
- INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual)
- VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual);
-
- SET vLastInsertedId = LAST_INSERT_ID();
-
- CALL workerTimeControlSOWP(vUserFk, vTimed);
-
- RETURN vLastInsertedId;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/functions/workerTimeControl_addDirection.sql b/db/routines/vn/functions/workerTimeControl_addDirection.sql
deleted file mode 100644
index 4d935e895..000000000
--- a/db/routines/vn/functions/workerTimeControl_addDirection.sql
+++ /dev/null
@@ -1,57 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`workerTimeControl_addDirection`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL)
- RETURNS int(11)
- DETERMINISTIC
-BEGIN
- DECLARE vDirection VARCHAR(6);
- DECLARE vLastIn DATETIME;
- DECLARE vDayStayMax INT;
- DECLARE vHasDirectionOut INT;
- DECLARE vLastInsertedId INT;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection;
-
- IF vDirection = 'out' THEN
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed < vTimed;
-
- UPDATE workerTimeControl wtc
- SET wtc.direction = 'middle'
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vLastIn AND vTimed;
-
- ELSE IF vDirection = 'in' THEN
-
- SELECT COUNT(*) INTO vHasDirectionOut
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- UPDATE workerTimeControl wtc
- SET wtc.direction = IF (vHasDirectionOut,'middle','out')
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- END IF;
- END IF;
-
- INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual)
- VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual);
-
- SET vLastInsertedId = LAST_INSERT_ID();
-
- CALL workerTimeControlSOWP(vUserFk, vTimed);
-
- RETURN vLastInsertedId;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/functions/worker_isInDepartment.sql b/db/routines/vn/functions/worker_isInDepartment.sql
new file mode 100644
index 000000000..8eee3656e
--- /dev/null
+++ b/db/routines/vn/functions/worker_isInDepartment.sql
@@ -0,0 +1,27 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_isInDepartment`(vDepartmentCode VARCHAR(255))
+ RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Devuelve booleano si el trabajador conectado pertenece
+ * al departamento vDepartmentCode o a sus departamentos subordinados
+ *
+ * @param vDepartmentCode code del departamento que se desea comprobar.
+ * @return Devuelve verdadero si es jefe del empleado por escala jerárquica.
+ */
+ DECLARE vIsInDepartment BOOLEAN;
+ WITH RECURSIVE department AS (
+ SELECT d.id FROM vn.department d WHERE code = vDepartmentCode
+ UNION
+ SELECT d.id
+ FROM department ds
+ JOIN vn.department d ON ds.id = d.parentFk
+ )
+ SELECT COUNT(*) INTO vIsInDepartment FROM department ds
+ JOIN vn.workerDepartment wd ON wd.departmentFk = ds.id
+ WHERE wd.workerFk = account.myUser_getId();
+
+ RETURN vIsInDepartment;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql
index 404a8fdab..4346ef640 100644
--- a/db/routines/vn/procedures/buyUltimate.sql
+++ b/db/routines/vn/procedures/buyUltimate.sql
@@ -25,12 +25,15 @@ BEGIN
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
- AND landed <= vDated;
+ AND landed <= vDated
+ AND NOT isIgnored;
INSERT IGNORE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
- AND landed > vDated;
+ AND landed > vDated
+ ORDER BY isIgnored = FALSE DESC;
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql
index e9d30f4c9..92434a47b 100644
--- a/db/routines/vn/procedures/buyUltimateFromInterval.sql
+++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql
@@ -26,11 +26,13 @@ BEGIN
SELECT itemFk,
warehouseFk,
buyFk,
- MAX(landed) landed
+ MAX(landed) landed,
+ isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
- t.landed
+ t.landed,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
@@ -42,12 +44,13 @@ BEGIN
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
- INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed)
+ INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
- t.landed
+ t.landed,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
@@ -57,12 +60,13 @@ BEGIN
AND NOT b.isIgnored
GROUP BY itemFk, warehouseInFk;
- INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed)
+ INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
- t.landed
+ t.landed,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
@@ -71,17 +75,19 @@ BEGIN
AND b.quantity = 0
GROUP BY itemFk, warehouseInFk;
- -- ItemOriginal
- INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed)
+ -- ItemOriginal
+ INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
- MAX(landed) landed
+ MAX(landed) landed,
+ isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
- itemOriginalFk
+ itemOriginalFk,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
@@ -95,12 +101,13 @@ BEGIN
LIMIT 10000000000000000000) sub
GROUP BY itemOriginalFk, warehouseFk;
- INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed)
+ INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
- t.landed
+ t.landed,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
@@ -111,12 +118,13 @@ BEGIN
AND itemOriginalFk
GROUP BY itemOriginalFk, warehouseInFk;
- INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed)
+ INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
- t.landed
+ t.landed,
+ b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
diff --git a/db/routines/vn/procedures/buy_recalcPricesByAwb.sql b/db/routines/vn/procedures/buy_recalcPricesByAwb.sql
index bc0c9bcb3..6f6baf305 100644
--- a/db/routines/vn/procedures/buy_recalcPricesByAwb.sql
+++ b/db/routines/vn/procedures/buy_recalcPricesByAwb.sql
@@ -12,9 +12,8 @@ BEGIN
SELECT b.id
FROM buy b
JOIN entry e ON e.id = b.entryFk
- JOIN duaEntry de ON de.entryFk = e.id
- JOIN dua d ON d.id = de.duaFk
- JOIN awb a ON a.id = d.awbFk
+ JOIN travel t ON t.id = e.travelFk
+ JOIN awb a ON a.id = t.awbFk
WHERE a.code = awbFk;
CALL buy_recalcPrices();
diff --git a/db/routines/vn/procedures/client_unassignSalesPerson.sql b/db/routines/vn/procedures/client_unassignSalesPerson.sql
index 8c624204e..f939ae68b 100644
--- a/db/routines/vn/procedures/client_unassignSalesPerson.sql
+++ b/db/routines/vn/procedures/client_unassignSalesPerson.sql
@@ -18,9 +18,9 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
CREATE OR REPLACE TEMPORARY TABLE tClientList
- SELECT c.clientFk
+ SELECT c.id clientFk
FROM bs.clientDied cd
- JOIN client c ON c.id = cd.id
+ JOIN client c ON c.id = cd.clientFk
LEFT JOIN clientProtected cp ON cp.clientFk = c.id
LEFT JOIN salesPersonProtected sp ON sp.salesPersonFk = c.salesPersonFk
JOIN province p ON p.id = c.provinceFk
diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql
index 038f8f9a3..0918bf1da 100644
--- a/db/routines/vn/procedures/collection_assign.sql
+++ b/db/routines/vn/procedures/collection_assign.sql
@@ -1,72 +1,88 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_assign`(vUserFk INT, OUT vCollectionFk INT)
-proc:BEGIN
-/* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
- * y le asigna la más antigua.
- * Añade un registro al semillero de colecciones
- */
- DECLARE vHasTooMuchCollections BOOL;
- DECLARE vLockTime INT DEFAULT 15;
-
- -- Si hay colecciones sin terminar, sale del proceso
- CALL vn.collection_get(vUserFk);
-
- SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
- INTO vHasTooMuchCollections
- FROM tCollection
- JOIN vn.productionConfig pc ;
-
- DROP TEMPORARY TABLE tCollection;
-
- IF vHasTooMuchCollections THEN
- CALL util.throw('Hay colecciones pendientes');
- LEAVE proc;
- END IF;
-
- IF NOT GET_LOCK('collection_assign',vLockTime) THEN
- LEAVE proc;
- END IF;
-
- -- Se eliminan las colecciones sin asignar que estan obsoletas
- INSERT INTO ticketTracking(stateFk, ticketFk)
- SELECT s.id, tc.ticketFk
- FROM vn.collection c
- JOIN vn.ticketCollection tc ON tc.collectionFk = c.id
- JOIN vn.state s ON s.code = 'PRINTED_AUTO'
- JOIN vn.productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
-
- DELETE c.*
- FROM vn.collection c
- JOIN vn.productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
-
- -- Se a�ade registro al semillero
- INSERT INTO vn.collectionHotbed(userFk)
- VALUES(vUserFk);
-
- -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
- SELECT MIN(c.id)
- INTO vCollectionFk
- FROM vn.collection c
- JOIN vn.operator o
- ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL)
- AND o.numberOfWagons = c.wagons
- AND o.trainFk = c.trainFk
- AND o.warehouseFk = c.warehouseFk
- AND c.workerFk IS NULL
- WHERE o.workerFk = vUserFk;
-
- IF vCollectionFk IS NULL THEN
- CALL vn.collection_new(vUserFk, vCollectionFk);
- END IF;
-
- UPDATE vn.collection
- SET workerFk = vUserFk
- WHERE id = vCollectionFk;
-
- DO RELEASE_LOCK('collection_assign');
-END$$
-DELIMITER ;
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_assign`(
+ vUserFk INT,
+ OUT vCollectionFk INT
+)
+proc:BEGIN
+/**
+ * Comprueba si existen colecciones libres que se ajustan
+ * al perfil del usuario y le asigna la más antigua.
+ * Añade un registro al semillero de colecciones.
+ *
+ * @param vUserFk Id de usuario
+ * @param vCollectionFk Id de colección
+ */
+ DECLARE vHasTooMuchCollections BOOL;
+ DECLARE vLockTime INT DEFAULT 15;
+
+ -- Si hay colecciones sin terminar, sale del proceso
+ CALL collection_get(vUserFk);
+
+ SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
+ INTO vHasTooMuchCollections
+ FROM tCollection
+ JOIN productionConfig pc ;
+
+ DROP TEMPORARY TABLE tCollection;
+
+ IF vHasTooMuchCollections THEN
+ CALL util.throw('Hay colecciones pendientes');
+ LEAVE proc;
+ END IF;
+
+ IF NOT GET_LOCK('collection_assign',vLockTime) THEN
+ LEAVE proc;
+ END IF;
+
+ -- Se eliminan las colecciones sin asignar que estan obsoletas
+ INSERT INTO ticketTracking(stateFk, ticketFk)
+ SELECT s.id, tc.ticketFk
+ FROM `collection` c
+ JOIN ticketCollection tc ON tc.collectionFk = c.id
+ JOIN `state` s ON s.code = 'PRINTED_AUTO'
+ JOIN productionConfig pc
+ WHERE c.workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
+
+ DELETE c.*
+ FROM `collection` c
+ JOIN productionConfig pc
+ WHERE c.workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
+
+ -- Se añade registro al semillero
+ INSERT INTO collectionHotbed(userFk)
+ VALUES(vUserFk);
+
+ -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
+ SELECT MIN(c.id)
+ INTO vCollectionFk
+ FROM `collection` c
+ JOIN operator o
+ ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL)
+ AND o.numberOfWagons = c.wagons
+ AND o.trainFk = c.trainFk
+ AND o.warehouseFk = c.warehouseFk
+ AND c.workerFk IS NULL
+ AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL)
+ JOIN (
+ SELECT tc.collectionFk, SUM(sv.volume) volume
+ FROM ticketCollection tc
+ JOIN saleVolume sv ON sv.ticketFk = tc.ticketFk
+ WHERE sv.shipped >= util.VN_CURDATE()
+ GROUP BY tc.collectionFk
+ ) sub ON sub.collectionFk = c.id
+ AND (volume <= o.volumeLimit OR o.volumeLimit IS NULL)
+ WHERE o.workerFk = vUserFk;
+
+ IF vCollectionFk IS NULL THEN
+ CALL collection_new(vUserFk, vCollectionFk);
+ END IF;
+
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+
+ DO RELEASE_LOCK('collection_assign');
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql
index 8bb382db1..d91c63c24 100644
--- a/db/routines/vn/procedures/collection_new.sql
+++ b/db/routines/vn/procedures/collection_new.sql
@@ -9,6 +9,10 @@ proc:BEGIN
DECLARE vWarehouseFk INT;
DECLARE vWagons INT;
DECLARE vTrainFk INT;
+ DECLARE vLinesLimit INT DEFAULT NULL;
+ DECLARE vTicketLines INT;
+ DECLARE vVolumeLimit DECIMAL DEFAULT NULL;
+ DECLARE vTicketVolume DECIMAL;
DECLARE vMaxTickets INT;
DECLARE vStateFk VARCHAR(45);
DECLARE vFirstTicketFk INT;
@@ -24,12 +28,11 @@ proc:BEGIN
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 15;
DECLARE vFreeWagonFk INT;
- DECLARE cur1 CURSOR FOR
- SELECT ticketFk
+ DECLARE c1 CURSOR FOR
+ SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer
WHERE ticketFk <> vFirstTicketFk
- ORDER BY
- HH,
+ ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
@@ -41,32 +44,34 @@ proc:BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- SELECT
- pc.ticketTrolleyMax * o.numberOfWagons,
- pc.hasUniqueCollectionTime,
- w.code,
- o.warehouseFk,
- o.itemPackingTypeFk,
- st.code,
- CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk),
- o.numberOfWagons,
- o.trainFk
- INTO
- vMaxTickets,
- vHasUniqueCollectionTime,
- vWorkerCode,
- vWarehouseFk,
- vItemPackingTypeFk,
- vStateFk,
- vLockName,
- vWagons,
- vTrainFk
+ SELECT pc.ticketTrolleyMax * o.numberOfWagons,
+ pc.hasUniqueCollectionTime,
+ w.code,
+ o.warehouseFk,
+ o.itemPackingTypeFk,
+ st.code,
+ CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk),
+ o.numberOfWagons,
+ o.trainFk,
+ o.linesLimit,
+ o.volumeLimit
+ INTO vMaxTickets,
+ vHasUniqueCollectionTime,
+ vWorkerCode,
+ vWarehouseFk,
+ vItemPackingTypeFk,
+ vStateFk,
+ vLockName,
+ vWagons,
+ vTrainFk,
+ vLinesLimit,
+ vVolumeLimit
FROM productionConfig pc
JOIN worker w ON w.id = vUserFk
JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN operator o ON o.workerFk = vUserFk;
- IF NOT GET_LOCK(vLockName,vLockTime) THEN
+ IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc;
END IF;
@@ -122,16 +127,16 @@ proc:BEGIN
SELECT COUNT(*) INTO vHasAssignedTickets
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
- WHERE s.code = 'PICKER_DESIGNED'
- AND pb.workerCode = vWorkerCode;
+ WHERE s.code = 'PICKER_DESIGNED'
+ AND pb.workerCode = vWorkerCode;
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
IF vHasAssignedTickets THEN
DELETE pb.*
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
- WHERE s.code <> 'PICKER_DESIGNED'
- OR pb.workerCode <> vWorkerCode;
+ WHERE s.code <> 'PICKER_DESIGNED'
+ OR pb.workerCode <> vWorkerCode;
ELSE
DELETE pb.*
FROM tmp.productionBuffer pb
@@ -140,23 +145,32 @@ proc:BEGIN
JOIN agency a ON a.id = am.agencyFk
JOIN productionConfig pc
WHERE pb.shipped <> util.VN_CURDATE()
- OR (pb.ubicacion IS NULL AND a.isOwn = TRUE)
- OR (s.isPreparable = FALSE AND s.isPrintable = FALSE)
+ OR (pb.ubicacion IS NULL AND a.isOwn)
+ OR (NOT s.isPreparable AND NOT s.isPrintable)
OR pb.collectionH IS NOT NULL
OR pb.collectionV IS NOT NULL
OR pb.collectionN IS NOT NULL
- OR (pb.H = 0 AND pb.V > 0 AND vItemPackingTypeFk = 'H')
- OR (pb.V = 0 AND vItemPackingTypeFk = 'V')
+ OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
+ OR (NOT pb.V AND vItemPackingTypeFk = 'V')
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
- OR LENGTH(pb.problem) > 0;
+ OR LENGTH(pb.problem) > 0
+ OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL)
+ OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL);
END IF;
-- Es importante que el primer ticket se coja en todos los casos
- SELECT ticketFk, HH, mm
- INTO vFirstTicketFk, vHour, vMinute
- FROM tmp.productionBuffer
- ORDER BY
+ SELECT ticketFk,
HH,
+ mm,
+ `lines`,
+ m3
+ INTO vFirstTicketFk,
+ vHour,
+ vMinute,
+ vTicketLines,
+ vTicketVolume
+ FROM tmp.productionBuffer
+ ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
@@ -168,90 +182,103 @@ proc:BEGIN
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
IF vHasUniqueCollectionTime THEN
- DELETE
- FROM tmp.productionBuffer
+ DELETE FROM tmp.productionBuffer
WHERE HH <> vHour
OR mm <> vMinute;
END IF;
SET vTicketFk = vFirstTicketFk;
+ SET @lines = 0;
+ SET @volume = 0;
- OPEN cur1;
-
+ OPEN c1;
read_loop: LOOP
SET vDone = FALSE;
- CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
+ -- Buscamos un ticket que cumpla con los requisitos en el listado
+ IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL)
+ AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN
- DROP TEMPORARY TABLE tmp.ticketIPT;
+ CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
+ DROP TEMPORARY TABLE tmp.ticketIPT;
- UPDATE tmp.productionBuffer pb
- JOIN (SELECT @litros:= SUM(litros) liters, COUNT(*) `lines`, MAX(i.`size`) height
- FROM saleVolume sv
- JOIN sale s ON s.id = sv.saleFk
- JOIN item i ON i.id = s.itemFk
- WHERE sv.ticketFk = vTicketFk ) sub
- SET pb.liters = sub.liters, pb.`lines` = sub.`lines`, pb.height = sub.height
- WHERE pb.ticketFk = vTicketFk;
+ UPDATE tmp.productionBuffer pb
+ JOIN (
+ SELECT SUM(litros) liters,
+ @lines:= COUNT(*) + @lines `lines`,
+ MAX(i.`size`) height,
+ @volume := SUM(sv.volume) + @volume volume
+ FROM saleVolume sv
+ JOIN sale s ON s.id = sv.saleFk
+ JOIN item i ON i.id = s.itemFk
+ WHERE sv.ticketFk = vTicketFk
+ ) sub
+ SET pb.liters = sub.liters,
+ pb.`lines` = sub.`lines`,
+ pb.height = sub.height
+ WHERE pb.ticketFk = vTicketFk;
- UPDATE tTrain tt
- JOIN tmp.productionBuffer pb ON pb.ticketFk = vTicketFk
- SET tt.ticketFk = pb.ticketFk
- WHERE tt.liters >= pb.liters
- AND tt.`lines` >= pb.`lines`
- AND (tt.height >= pb.height OR vItemPackingTypeFk <> 'V')
- AND tt.ticketFk IS NULL
- ORDER BY
- wagon,
- shelve,
- tt.liters,
- tt.`lines`,
- tt.height
- LIMIT 1;
-
- -- Si no le encuentra una balda adecuada, intentamos darle un carro entero
- -- si queda alguno libre
-
- IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
- SELECT tt.wagon
- INTO vFreeWagonFk
- FROM tTrain tt
- LEFT JOIN (SELECT DISTINCT wagon
- FROM tTrain
- WHERE ticketFk IS NOT NULL
- ) nn ON nn.wagon = tt.wagon
- WHERE nn.wagon IS NULL
- ORDER BY wagon
+ UPDATE tTrain tt
+ JOIN tmp.productionBuffer pb ON pb.ticketFk = vTicketFk
+ SET tt.ticketFk = pb.ticketFk
+ WHERE tt.liters >= pb.liters
+ AND tt.`lines` >= pb.`lines`
+ AND (tt.height >= pb.height OR vItemPackingTypeFk <> 'V')
+ AND tt.ticketFk IS NULL
+ ORDER BY wagon,
+ shelve,
+ tt.liters,
+ tt.`lines`,
+ tt.height
LIMIT 1;
- IF vFreeWagonFk THEN
- UPDATE tTrain
- SET ticketFk = vFirstTicketFk
- WHERE wagon = vFreeWagonFk;
-
- -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
- DELETE tt.*
+ -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre
+ IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
+ SELECT tt.wagon
+ INTO vFreeWagonFk
FROM tTrain tt
- LEFT JOIN (SELECT DISTINCT wagon
+ LEFT JOIN (
+ SELECT DISTINCT wagon
+ FROM tTrain
+ WHERE ticketFk IS NOT NULL
+ ) nn ON nn.wagon = tt.wagon
+ WHERE nn.wagon IS NULL
+ ORDER BY wagon
+ LIMIT 1;
+
+ IF vFreeWagonFk THEN
+ UPDATE tTrain
+ SET ticketFk = vFirstTicketFk
+ WHERE wagon = vFreeWagonFk;
+
+ -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
+ DELETE tt.*
+ FROM tTrain tt
+ LEFT JOIN (
+ SELECT DISTINCT wagon
FROM tTrain
WHERE ticketFk IS NOT NULL
- ) nn ON nn.wagon = tt.wagon
- WHERE nn.wagon IS NULL;
+ ) nn ON nn.wagon = tt.wagon
+ WHERE nn.wagon IS NULL;
+ END IF;
END IF;
- END IF;
- FETCH cur1 INTO vTicketFk;
-
- IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
- LEAVE read_loop;
+ FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
+ IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
+ LEAVE read_loop;
+ END IF;
+ ELSE
+ FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
END IF;
END LOOP;
-
- CLOSE cur1;
+ CLOSE c1;
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
UPDATE collection c
- JOIN state st ON st.code = 'ON_PREPARATION'
+ JOIN state st ON st.code = 'ON_PREPARATION'
SET c.stateFk = st.id
WHERE c.id = vCollectionFk;
@@ -263,7 +290,6 @@ proc:BEGIN
ORDER BY tt.wagon, tt.shelve;
-- Actualiza el estado de los tickets
-
CALL collection_setState(vCollectionFk, vStateFk);
-- Aviso para la preparacion previa
@@ -274,24 +300,23 @@ proc:BEGIN
CALL sales_mergeByCollection(vCollectionFk);
- UPDATE collection c
- JOIN (SELECT count(*) saleTotalCount ,
- sum(s.isPicked != 0) salePickedCount
- FROM ticketCollection tc
- JOIN sale s ON s.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND s.quantity > 0
+ UPDATE `collection` c
+ JOIN (
+ SELECT COUNT(*) saleTotalCount,
+ SUM(s.isPicked <> 0) salePickedCount
+ FROM ticketCollection tc
+ JOIN sale s ON s.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND s.quantity > 0
) sub
SET c.saleTotalCount = sub.saleTotalCount,
c.salePickedCount = sub.salePickedCount
WHERE c.id = vCollectionFk;
ELSE
-
- -- CALL util.throw('No ha sido posible obtener colección');
- DELETE FROM collection WHERE id = vCollectionFk;
- SET vCollectionFk = NULL;
-
+ DELETE FROM `collection`
+ WHERE id = vCollectionFk;
+ SET vCollectionFk = NULL;
END IF;
DO RELEASE_LOCK(vLockName);
diff --git a/db/routines/vn/procedures/comparative_add.sql b/db/routines/vn/procedures/comparative_add.sql
index 349d26db5..756096e54 100644
--- a/db/routines/vn/procedures/comparative_add.sql
+++ b/db/routines/vn/procedures/comparative_add.sql
@@ -23,9 +23,10 @@ BEGIN
FROM `time`
WHERE dated = util.VN_CURDATE();
- IF vMaxPeriod < vPeriod
- AND vWeek > vConfigWeek THEN
- REPLACE comparative(
+ IF vMaxPeriod < vPeriod AND vWeek > vConfigWeek THEN
+ DELETE FROM comparative WHERE timePeriod BETWEEN vMaxPeriod AND vPeriod;
+
+ INSERT INTO comparative(
timePeriod,
itemFk,
warehouseFk,
diff --git a/db/routines/vn/procedures/duaParcialMake.sql b/db/routines/vn/procedures/duaParcialMake.sql
index 9504cd38a..cbb56e16d 100644
--- a/db/routines/vn/procedures/duaParcialMake.sql
+++ b/db/routines/vn/procedures/duaParcialMake.sql
@@ -4,8 +4,8 @@ BEGIN
DECLARE vNewDuaFk INT;
- INSERT INTO dua(awbFk,companyFk)
- SELECT awbFk,companyFk
+ INSERT INTO dua(companyFk)
+ SELECT companyFk
FROM dua
WHERE id = vDuaFk;
@@ -15,7 +15,7 @@ BEGIN
SELECT vNewDuaFk, entryFk, value, value - customsValue
FROM duaEntry
WHERE duaFk = vDuaFk
- AND value != customsValue;
+ AND value != customsValue;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/ektEntryAssign_setEntry.sql b/db/routines/vn/procedures/ektEntryAssign_setEntry.sql
index 441555ad5..d80215e37 100644
--- a/db/routines/vn/procedures/ektEntryAssign_setEntry.sql
+++ b/db/routines/vn/procedures/ektEntryAssign_setEntry.sql
@@ -80,7 +80,7 @@ OPEN cur1;
FROM vn.travel tr
JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk
AND ea.warehouseInFk = tr.warehouseInFk
- AND ea.agencyModeFk = tr.agencyFk
+ AND ea.agencyModeFk = tr.agencyModeFk
WHERE ea.id = vId
AND tr.landed = vLanded;
diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
index e9461369a..77e989630 100644
--- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
+++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
@@ -13,7 +13,8 @@ BEGIN
SELECT COUNT(*) INTO vLines
FROM invoiceInTax
- WHERE invoiceInFk = vInvoiceInFk;
+ WHERE invoiceInFk = vInvoiceInFk
+ AND (taxTypeSageFk OR transactionTypeSageFk);
IF vLines >= vTaxRowLimit THEN
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
diff --git a/db/routines/vn/procedures/itemProposal_Add.sql b/db/routines/vn/procedures/itemProposal_Add.sql
index 537cecb1c..5a01cb67a 100644
--- a/db/routines/vn/procedures/itemProposal_Add.sql
+++ b/db/routines/vn/procedures/itemProposal_Add.sql
@@ -8,52 +8,63 @@ BEGIN
* @param vMateFk articulo sustituto
* @ param vQuantity cantidad que se va a sustituir
*/
- DECLARE vTicketFk INT;
- DECLARE vItemFk INT;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vDate DATE;
- DECLARE vGrouping INT;
+ DECLARE vTicketFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vWarehouseFk SMALLINT;
+ DECLARE vDate DATE;
+ DECLARE vGrouping INT;
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;
+ DECLARE vRoundQuantity INT DEFAULT 1;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk
+ INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ WHERE s.id = vSaleFk;
+
+ CALL 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;
+
+ START TRANSACTION;
+
+ UPDATE sale
+ SET quantity = quantity - vQuantity
+ WHERE id = vSaleFk;
+
+ INSERT INTO sale(ticketFk, itemFk, quantity, concept)
+ SELECT vTicketFk,
+ vMateFk,
+ CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
+ CONCAT('+ ',i.longName)
+ FROM item i
+ WHERE id = vMateFk;
+
+ SELECT LAST_INSERT_ID() INTO vSaleFk;
+
+ CALL sale_calculateComponent(vSaleFk, NULL);
+
+ INSERT INTO itemProposal(itemFk, mateFk, counter)
+ VALUES(vItemFk, vMateFk, 1)
+ ON DUPLICATE KEY UPDATE counter = counter + 1;
+
+ COMMIT;
END$$
-DELIMITER ;
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql
index 4ddaf3d12..a232139d3 100644
--- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql
+++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql
@@ -9,7 +9,7 @@ proc:BEGIN
* @return Lista de articulos
*/
DECLARE vCalcVisibleFk INT;
-
+
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
SELECT * FROM
@@ -23,7 +23,7 @@ proc:BEGIN
CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho,
sub.name itemColour
FROM (SELECT iss.itemFk,
- CONCAT(i.longName, ' ', i.size,' ', IFNULL(i.subName,'') ) longName,
+ CONCAT(i.longName, ' ', IFNULL(i.size, ''),' ', IFNULL(i.subName, '') ) longName,
'' size,
CONCAT(iss.parkingCode, ' ', iss.shelvingFk) producer,
0 upstairs,
@@ -38,7 +38,7 @@ proc:BEGIN
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
@@ -49,9 +49,9 @@ proc:BEGIN
AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
- ) sub2 ON sub2.itemFk = sub.itemFk
- UNION ALL
- SELECT v.item_id ,
+ ) 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`,
CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer,
diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql
index 51af98e0b..3f3663865 100644
--- a/db/routines/vn/procedures/productionControl.sql
+++ b/db/routines/vn/procedures/productionControl.sql
@@ -81,8 +81,8 @@ proc: BEGIN
rm.bufferFk
FROM tmp.productionTicket tt
JOIN ticket t ON tt.ticketFk = t.id
- LEFT JOIN ticketStateToday tst ON tst.ticket = t.id
- LEFT JOIN state st ON st.id = tst.state
+ LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id
+ LEFT JOIN `state` st ON st.id = tst.state
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
JOIN address a ON a.id = t.addressFk
diff --git a/db/routines/vn/procedures/recipe_Plaster.sql b/db/routines/vn/procedures/recipe_Plaster.sql
index 65e2ab473..18fdf55c8 100644
--- a/db/routines/vn/procedures/recipe_Plaster.sql
+++ b/db/routines/vn/procedures/recipe_Plaster.sql
@@ -3,33 +3,33 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`recipe_Plaster`(vIt
BEGIN
DECLARE vLastCost DECIMAL(10,2);
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vEntryFk INT;
- DECLARE vTravelFk INT;
-
- CALL cache.last_buy_refresh(FALSE);
-
- SELECT warehouseFk, shipped
+ DECLARE vWarehouseFk INT;
+ DECLARE vShipped DATE;
+ DECLARE vEntryFk INT;
+ DECLARE vTravelFk INT;
+
+ CALL cache.last_buy_refresh(FALSE);
+
+ SELECT warehouseFk, shipped
INTO vWarehouseFk, vShipped
FROM vn.ticket
- WHERE id = vTicketFk;
+ WHERE id = vTicketFk;
UPDATE vn.ticket t
JOIN vn.item i ON i.id = vItemFk
- SET t.nickname = CONCAT(vQuantity,' ',i.longName)
+ 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;
-
+ 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;
+ WHERE i.id = vItemFk;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/saleGroup_add.sql b/db/routines/vn/procedures/saleGroup_add.sql
index 679b84025..63e3bdedd 100644
--- a/db/routines/vn/procedures/saleGroup_add.sql
+++ b/db/routines/vn/procedures/saleGroup_add.sql
@@ -1,13 +1,15 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleGroup_add`(vSectorFk INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleGroup_add`(vSectorFk INT,vTicketFk INT)
BEGIN
/**
* Añade un nuevo registro a la tabla y devuelve su id.
*
* @param vSectorFk Identificador de vn.sector
*/
- INSERT INTO vn.saleGroup(userFk, sectorFk)
- VALUES (account.myUser_getId(), vSectorFk);
+ INSERT INTO vn.saleGroup
+ SET `userFk` = account.myUser_getId(),
+ `sectorFk` = vSectorFk,
+ `ticketFk` = vTicketFk;
SELECT LAST_INSERT_ID();
END$$
diff --git a/db/routines/vn/procedures/sale_calculateComponent.sql b/db/routines/vn/procedures/sale_calculateComponent.sql
index d720c5b06..63786c75c 100644
--- a/db/routines/vn/procedures/sale_calculateComponent.sql
+++ b/db/routines/vn/procedures/sale_calculateComponent.sql
@@ -1,19 +1,19 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption VARCHAR(25))
proc: BEGIN
/**
* Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes
*
* @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;
+ */
+ 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 ;
diff --git a/db/routines/vn/procedures/sale_checkNoComponents.sql b/db/routines/vn/procedures/sale_checkNoComponents.sql
index 136c13409..79abbbf92 100644
--- a/db/routines/vn/procedures/sale_checkNoComponents.sql
+++ b/db/routines/vn/procedures/sale_checkNoComponents.sql
@@ -61,7 +61,7 @@ BEGIN
FROM sale
WHERE id = vSaleFk;
- CALL sale_calculateComponent(vSaleFk, 1);
+ CALL sale_calculateComponent(vSaleFk, 'renewPrices');
END LOOP;
CLOSE vCur;
diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql
index 407c15854..0f2b2bc71 100644
--- a/db/routines/vn/procedures/sale_getBoxPickingList.sql
+++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql
@@ -1,13 +1,13 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getBoxPickingList`(vSectorFk INT, vDated DATE)
BEGIN
-/**
+/**
* Returns a suitable boxPicking sales list
*
* @param vSectorFk Identifier for vn.sector table
* @param vDated Date for vn.tickets.shipping
*
-* @return tmp.sale
+* @return tmp.sale
*/
DECLARE vWarehouseFk INT;
@@ -17,6 +17,55 @@ BEGIN
CALL productionControl(vWarehouseFk, 0);
+ -- Products with vn.item.isBoxPickingMode = TRUE, pay atention to vn.itemShelving.packing
+ CREATE OR REPLACE TEMPORARY TABLE tmp.sale
+ (saleFk INT PRIMARY KEY)
+ SELECT
+ s.ticketFk,
+ s.id saleFk,
+ s.itemFk,
+ s.concept,
+ s.quantity,
+ MAKETIME(pb.HH,pb.mm,0) etd,
+ pb.routeFk,
+ FLOOR(s.quantity / ish.packing) stickers,
+ ish.packing,
+ b.packagingFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemShelving ish ON ish.itemFk = s.itemFk
+ LEFT JOIN ( SELECT iss.itemShelvingFk,
+ s.itemFk,
+ SUM(iss.quantity) reserve
+ FROM itemShelvingSale iss
+ JOIN sale s ON s.id = iss.saleFk
+ WHERE iss.isPicked = FALSE
+ AND iss.created >= vDated
+ GROUP BY iss.itemShelvingFk, s.itemFk) tISS
+ ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
+ JOIN agencyMode am ON am.id = pb.agencyModeFk
+ LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
+ LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
+ LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
+ LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
+ LEFT JOIN buy b ON b.id = lb.buy_id
+ WHERE s.quantity BETWEEN ish.packing AND (ish.visible - IFNULL(tISS.reserve,0))
+ AND i.isBoxPickingMode
+ AND NOT pb.problem
+ AND sgd.saleFk IS NULL
+ AND p.sectorFk = vSectorFk
+ AND ts.isPreviousPreparable
+ AND ((rm.bufferFk AND rm.isPickingAllowed)
+ OR am.code = 'REC_ALG')
+ AND pb.shipped = vDated
+ GROUP BY s.id
+ ORDER BY etd;
+
+ -- Remaining products, vn.item.packingOut
+ INSERT IGNORE INTO tmp.sale
SELECT
s.ticketFk,
s.id saleFk,
@@ -26,7 +75,8 @@ BEGIN
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
s.quantity / i.packingOut stickers,
- i.packingOut
+ i.packingOut,
+ pc.defaultBigPackageFk
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemShelving ish ON ish.itemFk = s.itemFk
@@ -34,25 +84,27 @@ BEGIN
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk
+ JOIN packagingConfig pc
LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
LEFT JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = p.sectorFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
- WHERE s.quantity MOD i.packingOut = 0
- AND pb.problem = ""
+ WHERE s.quantity >= i.packingOut
+ AND NOT pb.problem
AND s.quantity > 0
AND sgd.saleFk IS NULL
AND p.sectorFk = vSectorFk
AND ts.isPreviousPreparable
AND iss.visible >= s.quantity
AND ((rm.bufferFk AND rm.isPickingAllowed)
- OR am.name = 'REC_ALGEMESI')
+ OR am.code = 'REC_ALG')
AND pb.shipped = vDated
GROUP BY s.id
ORDER BY etd;
+ SELECT * FROM tmp.sale;
+
DROP TEMPORARY TABLE tmp.productionBuffer;
+ DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;
-
-
diff --git a/db/routines/vn/procedures/sale_recalcComponent.sql b/db/routines/vn/procedures/sale_recalcComponent.sql
index 4e407ca6b..54297571a 100644
--- a/db/routines/vn/procedures/sale_recalcComponent.sql
+++ b/db/routines/vn/procedures/sale_recalcComponent.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption VARCHAR(25))
proc: BEGIN
/**
* Este procedimiento recalcula los componentes de un conjunto de sales,
@@ -10,21 +10,21 @@ proc: BEGIN
*/
DECLARE vShipped DATE;
DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicketFk INT;
- DECLARE vLanded DATE;
- DECLARE vIsEditable BOOLEAN;
- DECLARE vZoneFk INTEGER;
- DECLARE vDone BOOL DEFAULT FALSE;
-
+ DECLARE vAgencyModeFk INT;
+ DECLARE vAddressFk INT;
+ DECLARE vTicketFk INT;
+ 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;
-
+
OPEN vCur;
l: LOOP
@@ -59,13 +59,13 @@ proc: BEGIN
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)
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
@@ -76,10 +76,10 @@ proc: BEGIN
END IF;
DROP TEMPORARY TABLE tmp.zoneGetLanded;
-
+
-- rellena la tabla buyUltimate con la ultima compra
- CALL buyUltimate (vWarehouseFk, vShipped);
-
+ CALL buyUltimate (vWarehouseFk, vShipped);
+
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouseFk warehouseFk
@@ -87,7 +87,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
@@ -99,15 +99,15 @@ proc: BEGIN
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
IF vOption IS NULL THEN
- SET vOption = IF(vIsEditable, 1, 6);
- END IF;
-
- CALL ticketComponentUpdateSale(vOption);
- CALL catalog_componentPurge();
-
+ SET vOption = IF(vIsEditable, 'renewPrices', 'imbalance');
+ END IF;
+
+ CALL ticketComponentUpdateSale(vOption);
+ CALL catalog_componentPurge();
+
DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE tmp.sale;
-
+ DROP TEMPORARY TABLE tmp.sale;
+
END LOOP;
CLOSE vCur;
diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql
new file mode 100644
index 000000000..1edad1983
--- /dev/null
+++ b/db/routines/vn/procedures/sale_replaceItem.sql
@@ -0,0 +1,136 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT)
+BEGIN
+/**
+ * Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones.
+ *
+ * @param vSaleFk id de la tabla sale
+ * @param vNewItemFk articulo sustituto
+ * @param vQuantity cantidad que se va a sustituir
+ */
+ DECLARE vTicketFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vWarehouseFk SMALLINT;
+ DECLARE vDate DATE;
+ DECLARE vGrouping INT;
+ DECLARE vGroupingModeFk INT;
+ DECLARE vPacking INT;
+ DECLARE vRoundQuantity INT DEFAULT 1;
+ DECLARE vLanded DATE;
+ DECLARE vAddressFk INT;
+ DECLARE vAgencyModeFk INT;
+ DECLARE vNewPrice DECIMAL(10,2);
+ DECLARE vOldPrice DECIMAL(10,2);
+ DECLARE vOption INT DEFAULT NULL;
+ DECLARE vNewSaleFk INT;
+ DECLARE vChangePrice INT DEFAULT 1;
+ DECLARE vBuyerDiscount INT DEFAULT 4;
+ DECLARE vManaDiscount INT DEFAULT 3;
+ DECLARE vForceToGrouping INT DEFAULT 1;
+ DECLARE vForceToPacking INT DEFAULT 2;
+ DECLARE vFinalPrice DECIMAL(10,2);
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SELECT s.ticketFk,
+ LEAST(s.quantity, vQuantity),
+ s.itemFk,
+ t.shipped,
+ t.warehouseFk,
+ t.landed,
+ t.addressFk,
+ t.agencyModeFk,
+ s.price
+ INTO vTicketFk,
+ vQuantity,
+ vItemFk,
+ vDate,
+ vWarehouseFk,
+ vLanded,
+ vAddressFk,
+ vAgencyModeFk,
+ vOldPrice
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ WHERE s.id = vSaleFk;
+
+ CALL buyUltimate(vWarehouseFk, vDate);
+
+ SELECT `grouping`, groupingMode, packing
+ INTO vGrouping,vGroupingModeFk,vPacking
+ FROM buy b
+ JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
+ WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
+
+ IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN
+ SET vRoundQuantity = vPacking;
+ END IF;
+ IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN
+ SET vRoundQuantity = vGrouping;
+ END IF;
+
+ CALL catalog_calcFromItem(
+ vLanded,
+ vAddressFk,
+ vAgencyModeFk,
+ vNewItemFk);
+
+ SELECT price INTO vNewPrice
+ FROM tmp.ticketCalculateItem;
+
+ IF vNewPrice IS NULL THEN
+ CALL util.throw('price retrieval failed');
+ END IF;
+ IF vNewPrice > vOldPrice THEN
+ SET vFinalPrice = vOldPrice;
+ IF worker_isInDepartment('vt') THEN
+ SET vOption = vManaDiscount;
+ ELSE
+ SET vOption = vBuyerDiscount;
+ END IF;
+ ELSE
+ SET vFinalPrice = vNewPrice;
+ SET vOption = vChangePrice;
+ END IF;
+
+ START TRANSACTION;
+
+ UPDATE sale
+ SET quantity = quantity - vQuantity
+ WHERE id = vSaleFk;
+
+ INSERT INTO vn.sale(ticketFk,
+ itemFk,
+ quantity,
+ concept,
+ price)
+ SELECT vTicketFk,
+ vNewItemFk,
+ CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName),
+ vFinalPrice
+ FROM vn.item i
+ WHERE id = vNewItemFk;
+
+ SELECT LAST_INSERT_ID() INTO vNewSaleFk;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale;
+ CREATE TEMPORARY TABLE tmp.sale
+ (PRIMARY KEY (saleFk))
+ ENGINE = MEMORY
+ SELECT id saleFk, vWarehouseFk warehouseFk
+ FROM sale s WHERE id = vNewSaleFk;
+
+ CALL ticketComponentUpdateSale(vOption);
+ CALL catalog_componentPurge();
+
+ INSERT INTO itemProposal(itemFk, mateFk, counter)
+ VALUES(vItemFk, vNewItemFk, 1)
+ ON DUPLICATE KEY UPDATE counter = counter + 1;
+
+ COMMIT;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/ticketCalculateClon.sql b/db/routines/vn/procedures/ticketCalculateClon.sql
index 0be51c2ce..7ded84f45 100644
--- a/db/routines/vn/procedures/ticketCalculateClon.sql
+++ b/db/routines/vn/procedures/ticketCalculateClon.sql
@@ -11,16 +11,16 @@ BEGIN
REPLACE INTO orderTicket(orderFk,ticketFk)
SELECT orderFk, vTicketNew
FROM orderTicket
- WHERE ticketFk = vTicketOld;
-
+ 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);
+
+ CALL sale_recalcComponent('renewPrices');
-- Bionizamos lineas con Preu > 0
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
@@ -28,10 +28,10 @@ BEGIN
SELECT id
FROM sale
WHERE ticketFk = vTicketNew AND price > 0;
-
- CALL sale_recalcComponent(6);
+
+ CALL sale_recalcComponent('imbalance');
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
-
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/ticketComponentUpdate.sql b/db/routines/vn/procedures/ticketComponentUpdate.sql
index 28af8b87f..bdb3bf6cb 100644
--- a/db/routines/vn/procedures/ticketComponentUpdate.sql
+++ b/db/routines/vn/procedures/ticketComponentUpdate.sql
@@ -1,65 +1,62 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`(
vTicketFk INT,
- vClientFk INT,
- vAgencyModeFk INT,
- vAddressFk INT,
- vWarehouseFk TINYINT,
- vCompanyFk SMALLINT,
- vShipped DATETIME,
- vLanded DATE,
- vIsDeleted BOOLEAN,
- vHasToBeUnrouted BOOLEAN,
- vOption INT)
+ vClientFk INT,
+ vAgencyModeFk INT,
+ vAddressFk INT,
+ vWarehouseFk TINYINT,
+ vCompanyFk SMALLINT,
+ vShipped DATETIME,
+ vLanded DATE,
+ vIsDeleted BOOLEAN,
+ vHasToBeUnrouted BOOLEAN,
+ vOption VARCHAR(25))
BEGIN
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
ROLLBACK;
- RESIGNAL;
+ RESIGNAL;
END;
START TRANSACTION;
-
- IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
-
+
+ IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
+
UPDATE ticket t
JOIN address a ON a.id = vAddressFk
SET t.nickname = a.nickname
WHERE t.id = vTicketFk;
-
- END IF;
-
+ END IF;
+
UPDATE ticket t
SET
t.clientFk = vClientFk,
t.agencyModeFk = vAgencyModeFk,
t.addressFk = vAddressFk,
t.warehouseFk = vWarehouseFk,
- t.companyFk = vCompanyFk,
+ t.companyFk = vCompanyFk,
t.landed = vLanded,
t.shipped = vShipped,
- t.isDeleted = vIsDeleted
+ 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
- (PRIMARY KEY (saleFk))
- ENGINE = MEMORY
- SELECT id AS saleFk, vWarehouseFk warehouseFk
- FROM sale s WHERE s.ticketFk = vTicketFk;
-
- CALL ticketComponentUpdateSale (vOption);
-
- DROP TEMPORARY TABLE tmp.sale;
END IF;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale;
+ CREATE TEMPORARY TABLE tmp.sale
+ (PRIMARY KEY (saleFk))
+ ENGINE = MEMORY
+ SELECT id AS saleFk, vWarehouseFk warehouseFk
+ FROM sale s WHERE s.ticketFk = vTicketFk;
+
+ CALL ticketComponentUpdateSale (vOption);
+
+ DROP TEMPORARY TABLE tmp.sale;
COMMIT;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/ticketComponentUpdateSale.sql b/db/routines/vn/procedures/ticketComponentUpdateSale.sql
index fe11d1e83..d002655d1 100644
--- a/db/routines/vn/procedures/ticketComponentUpdateSale.sql
+++ b/db/routines/vn/procedures/ticketComponentUpdateSale.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vOption INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25))
BEGIN
/**
* A partir de la tabla tmp.sale, crea los Movimientos_componentes
@@ -9,153 +9,80 @@ BEGIN
* @param table tmp.sale tabla memory con el campo saleFk, warehouseFk
**/
DECLARE vComponentFk INT;
- DECLARE vRenewComponents BOOLEAN;
- DECLARE vKeepPrices BOOLEAN;
-
- CASE vOption
- WHEN 1 THEN
- SET vRenewComponents = TRUE;
- SET vKeepPrices = FALSE;
- WHEN 2 THEN
- 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';
- 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
- SET vComponentFk = 35;
- SET vRenewComponents = TRUE;
- SET vKeepPrices = TRUE;*/
- 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)
- FROM sale s
- JOIN tmp.sale tmps ON tmps.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)
- FROM sale s
- JOIN tmp.sale tmps ON tmps.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.*
- 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)
- FROM sale s
- JOIN tmp.sale tmps ON tmps.saleFk = s.id;
-
- SET vRenewComponents = FALSE;
- SET vKeepPrices = FALSE;
- WHEN 9 THEN
- SET vRenewComponents = TRUE;
- SET vKeepPrices = TRUE;
- END CASE;
- IF vRenewComponents THEN
- 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
- 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
- WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE);
-
- -- Añadir componente venta por paquete
- DROP TEMPORARY TABLE IF EXISTS tmp.sale2;
- CREATE TEMPORARY TABLE tmp.sale2
- (PRIMARY KEY (saleFk))
- 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 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 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'
- LEFT JOIN (
- SELECT s.id
- FROM vn.sale s
- JOIN tmp.sale2 tmps ON tmps.saleFk = s.id
- JOIN tmp.ticketComponent2 tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
- JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = tc.componentFk
- JOIN `component` c ON c.id = sc.componentFk AND c.code = 'lastUnitsDiscount'
- ) tp ON tp.id = s.id
- WHERE tp.id IS NULL
- HAVING resto <> 0) t;
-
- DROP TEMPORARY TABLE IF EXISTS
- tmp.sale2,
- tmp.ticketComponent2;
- END IF;
+ IF vCode <> 'renewPrices' THEN
+ SELECT id INTO vComponentFk FROM component WHERE `code` = vCode;
+ END IF;
- IF vKeepPrices THEN
+ 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
+ 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
+ WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE);
+
+ -- Añadir componente venta por paquete
+ 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 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'
+ LEFT JOIN (
+ SELECT s.id
+ FROM vn.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
+ JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = tc.componentFk
+ JOIN `component` c ON c.id = sc.componentFk AND c.code = 'lastUnitsDiscount'
+ ) tp ON tp.id = s.id
+ WHERE tp.id IS NULL
+ HAVING resto <> 0) t;
+
+ IF vCode <> 'renewPrices' THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
- SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
- FROM sale s
- JOIN tmp.sale tmps ON tmps.saleFk = s.id
- LEFT JOIN saleComponent sc ON sc.saleFk = s.id
- WHERE sc.saleFk <> vComponentFk
- GROUP BY s.id
- HAVING dif <> 0;
- ELSE
+ SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
+ FROM sale s
+ JOIN tmp.sale tmps ON tmps.saleFk = s.id
+ LEFT JOIN saleComponent sc ON sc.saleFk = s.id
+ WHERE sc.saleFk <> vComponentFk
+ GROUP BY s.id
+ HAVING dif <> 0;
+ ELSE
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
+ END IF;
+
+ UPDATE sale s
JOIN (
SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
@@ -165,16 +92,16 @@ BEGIN
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.priceFixed = sumValue, s.isPriceFixed = 1;
- DELETE sc.*
+ DELETE sc.*
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
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
diff --git a/db/routines/vn/procedures/ticketMissed_List.sql b/db/routines/vn/procedures/ticketMissed_List.sql
index c35852b15..6b0f66e6a 100644
--- a/db/routines/vn/procedures/ticketMissed_List.sql
+++ b/db/routines/vn/procedures/ticketMissed_List.sql
@@ -23,7 +23,7 @@ BEGIN
JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
- JOIN vn.ticketStateToday tst ON tst.ticket = tp.ticketFk
+ JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
diff --git a/db/routines/vn/procedures/ticketParking_findSkipped.sql b/db/routines/vn/procedures/ticketParking_findSkipped.sql
index 1da3e2a7f..b00006ffe 100644
--- a/db/routines/vn/procedures/ticketParking_findSkipped.sql
+++ b/db/routines/vn/procedures/ticketParking_findSkipped.sql
@@ -37,7 +37,7 @@ BEGIN
JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
- JOIN vn.ticketStateToday tst ON tst.ticket = tp.ticketFk
+ JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
diff --git a/db/routines/vn/procedures/ticketStateToday_setState.sql b/db/routines/vn/procedures/ticketStateToday_setState.sql
index 98e5ee480..73a92bbb5 100644
--- a/db/routines/vn/procedures/ticketStateToday_setState.sql
+++ b/db/routines/vn/procedures/ticketStateToday_setState.sql
@@ -14,7 +14,7 @@ BEGIN
SELECT s.alertLevel INTO vAlertLevel
FROM state s
JOIN ticketStateToday tst ON tst.state = s.id
- WHERE tst.ticket = vTicketFk
+ WHERE tst.ticketFk = vTicketFk
LIMIT 1;
IF vAlertLevel < 2 THEN
diff --git a/db/routines/vn/procedures/ticket_canbePostponed.sql b/db/routines/vn/procedures/ticket_canbePostponed.sql
index a88099fed..442059b99 100644
--- a/db/routines/vn/procedures/ticket_canbePostponed.sql
+++ b/db/routines/vn/procedures/ticket_canbePostponed.sql
@@ -22,6 +22,7 @@ BEGIN
t.warehouseFk,
ts.alertLevel,
t.shipped,
+ t.totalWithVat,
sub2.shipped futureShipped,
t.workerFk,
st.code stateCode,
diff --git a/db/routines/vn/procedures/ticket_checkNoComponents.sql b/db/routines/vn/procedures/ticket_checkNoComponents.sql
index 6b3e75e85..28fe333f0 100644
--- a/db/routines/vn/procedures/ticket_checkNoComponents.sql
+++ b/db/routines/vn/procedures/ticket_checkNoComponents.sql
@@ -24,9 +24,9 @@ BEGIN
WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
AND ic.merchandise;
- CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
+ CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
(primary key (id)) ENGINE = MEMORY
- SELECT DISTINCT s.id
+ SELECT DISTINCT s.id
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
@@ -37,9 +37,9 @@ BEGIN
AND c.id IS NULL
AND ic.merchandise;
- CALL vn.sale_recalcComponent(1);
-
- DROP TEMPORARY TABLE tmp.recalculateSales;
+ CALL sale_recalcComponent('renewPrices');
+
+ DROP TEMPORARY TABLE tmp.recalculateSales;
DROP TEMPORARY TABLE tmp.coste;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/ticket_componentMakeUpdate.sql b/db/routines/vn/procedures/ticket_componentMakeUpdate.sql
index 001e7ebaa..4b0a5bdbc 100644
--- a/db/routines/vn/procedures/ticket_componentMakeUpdate.sql
+++ b/db/routines/vn/procedures/ticket_componentMakeUpdate.sql
@@ -1,18 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`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,
- vOption INT)
+ vHasToBeUnrouted BOOLEAN,
+ vOption VARCHAR(25))
BEGIN
/**
@@ -53,7 +53,7 @@ BEGIN
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
t.clientFk = vClientFk,
@@ -70,29 +70,27 @@ 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
- (PRIMARY KEY (saleFk))
- ENGINE = MEMORY
- SELECT id AS saleFk, vWarehouseFk warehouseFk
- FROM sale s WHERE s.ticketFk = vTicketFk;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
- CREATE TEMPORARY TABLE tmp.ticketComponent
- SELECT * FROM tmp.ticketComponentPreview;
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale;
+ CREATE TEMPORARY TABLE tmp.sale
+ (PRIMARY KEY (saleFk))
+ ENGINE = MEMORY
+ SELECT id AS saleFk, vWarehouseFk warehouseFk
+ FROM sale s WHERE s.ticketFk = vTicketFk;
- CALL ticketComponentUpdateSale (vOption);
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
+ CREATE TEMPORARY TABLE tmp.ticketComponent
+ SELECT * FROM tmp.ticketComponentPreview;
- DROP TEMPORARY TABLE tmp.sale;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
- END IF;
+ CALL ticketComponentUpdateSale (vOption);
+
+ DROP TEMPORARY TABLE tmp.sale;
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview;
END$$
diff --git a/db/routines/vn/procedures/ticket_recalcComponents.sql b/db/routines/vn/procedures/ticket_recalcComponents.sql
index f48d70ee2..0282c0e42 100644
--- a/db/routines/vn/procedures/ticket_recalcComponents.sql
+++ b/db/routines/vn/procedures/ticket_recalcComponents.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25))
proc: BEGIN
/**
diff --git a/db/routines/vn/procedures/ticket_split.sql b/db/routines/vn/procedures/ticket_split.sql
index e8a94c610..172f6829a 100644
--- a/db/routines/vn/procedures/ticket_split.sql
+++ b/db/routines/vn/procedures/ticket_split.sql
@@ -32,7 +32,7 @@ proc:BEGIN
nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname )
WHERE id = vTicketFk;
- SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated);
+ SELECT "moved" message, NULL ticketFuture;
LEAVE proc;
END IF;
@@ -46,8 +46,7 @@ proc:BEGIN
s.concept = CONCAT('(s) ', s.concept)
WHERE ss.ticketFk = vTicketFk;
- SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
- " al ticket existente ", vTicketFutureFk,"(", vDated,")");
+ SELECT "future" message, NULL ticketFuture;
LEAVE proc;
END IF;
@@ -72,7 +71,6 @@ proc:BEGIN
CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING');
- SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
- " al nuevo ticket ", vTicketFutureFk,"(", vDated,")");
+ SELECT "new" message,vTicketFutureFk ticketFuture;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/timeWorkerControl_check.sql b/db/routines/vn/procedures/timeWorkerControl_check.sql
deleted file mode 100644
index 877bc9b69..000000000
--- a/db/routines/vn/procedures/timeWorkerControl_check.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
-proc: BEGIN
-/**
- * deprecated call workerTimeControl_check
- */
-CALL vn.workerTimeControl_check(vUserFk,vDated,vTabletFk);
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControlAdd.sql b/db/routines/vn/procedures/workerTimeControlAdd.sql
deleted file mode 100644
index 1f5f0db2d..000000000
--- a/db/routines/vn/procedures/workerTimeControlAdd.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`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 ;
diff --git a/db/routines/vn/procedures/workerTimeControlPinGenerate.sql b/db/routines/vn/procedures/workerTimeControlPinGenerate.sql
deleted file mode 100644
index afbb47c31..000000000
--- a/db/routines/vn/procedures/workerTimeControlPinGenerate.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControlPinGenerate`(
- vWorkerFk INT)
-BEGIN
-/**
- * Create new pin for workerFk or new pin for all workers if vWorkerFk is null
- *
- */
-
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControlSetOrder.sql b/db/routines/vn/procedures/workerTimeControlSetOrder.sql
deleted file mode 100644
index 953fa25f5..000000000
--- a/db/routines/vn/procedures/workerTimeControlSetOrder.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControlSetOrder`()
-BEGIN
-
- SET @order := 1;
- SET @userFk := 0;
- SET @day := 0;
-
- UPDATE tmp.workerTimeControl
- SET `order` = IF(userFk = @userFk AND day(timed) = @day, @order := @order + 1, @order := 1),
- userFk = @userFk := userFk,
- manual = manual + (0 * @day := day(timed))
- ORDER BY userFk, timed;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControl_add.sql b/db/routines/vn/procedures/workerTimeControl_add.sql
deleted file mode 100644
index 7769d71aa..000000000
--- a/db/routines/vn/procedures/workerTimeControl_add.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL)
-BEGIN
-
-
- SELECT workerTimeControl_add(vUserFk,vWarehouseFk,vTimed,vIsManual);
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControl_repair.sql b/db/routines/vn/procedures/workerTimeControl_repair.sql
deleted file mode 100644
index f4f0fd0a5..000000000
--- a/db/routines/vn/procedures/workerTimeControl_repair.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_repair`()
-proc: BEGIN
-/**
- * Corrige las fichadas
- *
- */
-
-/*1- poner todos a middle*/
-UPDATE vn.workerTimeControl SET direction = 'middle';
-
-/*2- poner los out*/
-UPDATE vn.workerTimeControl wtc
- JOIN
- (SELECT userFk,MAX(timed) maxTimed FROM
- (SELECT id, userFk, timed, date(timed) dated
- FROM vn.workerTimeControl
- ) sub
- GROUP BY userFk,dated
- )sub
- SET direction = "out"
- WHERE wtc.userFk = sub.userFk
- AND wtc.timed = sub.maxTimed;
-
- /*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
- GROUP BY userFk,dated
- )sub
- SET direction = "in"
- WHERE wtc.userFk = sub.userFk
- AND wtc.timed = sub.maxTimed ;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControl_setOrder.sql b/db/routines/vn/procedures/workerTimeControl_setOrder.sql
deleted file mode 100644
index c3d3753ae..000000000
--- a/db/routines/vn/procedures/workerTimeControl_setOrder.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE)
-BEGIN
-
- SET @order := 0;
- SET @day := '2000-01-01';
-
- UPDATE vn.workerTimeControl w
- SET w.`order` = @order := IF(@day = @day := date(timed), @order, 0) + 1
- WHERE w.userFk = vUserFk
- AND w.timed BETWEEN vStarted AND util.dayend(vFinished)
- ORDER BY w.timed;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/zone_upcomingDeliveries.sql b/db/routines/vn/procedures/zone_upcomingDeliveries.sql
index 3d83b51cf..96c4136ae 100644
--- a/db/routines/vn/procedures/zone_upcomingDeliveries.sql
+++ b/db/routines/vn/procedures/zone_upcomingDeliveries.sql
@@ -5,7 +5,7 @@ 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));
+ CALL util.time_generate(util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL vForwardDays DAY));
DROP TEMPORARY TABLE IF EXISTS tLandings;
CREATE TEMPORARY TABLE tLandings
diff --git a/db/routines/vn/triggers/autonomy_AD.sql b/db/routines/vn/triggers/autonomy_afterDelete.sql
similarity index 91%
rename from db/routines/vn/triggers/autonomy_AD.sql
rename to db/routines/vn/triggers/autonomy_afterDelete.sql
index f9e1ccf36..f278ccdea 100644
--- a/db/routines/vn/triggers/autonomy_AD.sql
+++ b/db/routines/vn/triggers/autonomy_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_AD`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_afterDelete`
AFTER DELETE ON `autonomy`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/autonomy_BI.sql b/db/routines/vn/triggers/autonomy_beforeInsert.sql
similarity index 93%
rename from db/routines/vn/triggers/autonomy_BI.sql
rename to db/routines/vn/triggers/autonomy_beforeInsert.sql
index e5f9ca9ca..3a6448b81 100644
--- a/db/routines/vn/triggers/autonomy_BI.sql
+++ b/db/routines/vn/triggers/autonomy_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_BI`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_beforeInsert`
BEFORE INSERT ON `autonomy`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/autonomy_BU.sql b/db/routines/vn/triggers/autonomy_beforeUpdate.sql
similarity index 95%
rename from db/routines/vn/triggers/autonomy_BU.sql
rename to db/routines/vn/triggers/autonomy_beforeUpdate.sql
index fd68cef58..a2c9a2a11 100644
--- a/db/routines/vn/triggers/autonomy_BU.sql
+++ b/db/routines/vn/triggers/autonomy_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_BU`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_beforeUpdate`
BEFORE UPDATE ON `autonomy`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/awb_bi.sql b/db/routines/vn/triggers/awb_beforeInsert.sql
similarity index 93%
rename from db/routines/vn/triggers/awb_bi.sql
rename to db/routines/vn/triggers/awb_beforeInsert.sql
index 1cc0fc2f7..8dc216024 100644
--- a/db/routines/vn/triggers/awb_bi.sql
+++ b/db/routines/vn/triggers/awb_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awb_bi`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awb_beforeInsert`
BEFORE INSERT ON `awb`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/calendar_afterDelete.sql b/db/routines/vn/triggers/calendar_afterDelete.sql
new file mode 100644
index 000000000..acd2c55b7
--- /dev/null
+++ b/db/routines/vn/triggers/calendar_afterDelete.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_afterDelete`
+ AFTER DELETE ON `calendar`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO workerLog
+ SET `action` = 'delete',
+ `changedModel` = 'Calendar',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/calendar_beforeInsert.sql b/db/routines/vn/triggers/calendar_beforeInsert.sql
new file mode 100644
index 000000000..9e51e6d18
--- /dev/null
+++ b/db/routines/vn/triggers/calendar_beforeInsert.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_beforeInsert`
+ BEFORE INSERT ON `calendar`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/calendar_beforeUpdate.sql b/db/routines/vn/triggers/calendar_beforeUpdate.sql
new file mode 100644
index 000000000..bb1ba53c3
--- /dev/null
+++ b/db/routines/vn/triggers/calendar_beforeUpdate.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_beforeUpdate`
+ BEFORE UPDATE ON `calendar`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/clientCredit_AfterInsert.sql b/db/routines/vn/triggers/clientCredit_AfterInsert.sql
index a0f1c65ce..440f24865 100644
--- a/db/routines/vn/triggers/clientCredit_AfterInsert.sql
+++ b/db/routines/vn/triggers/clientCredit_AfterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientCredit_AfterInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientCredit_afterInsert`
AFTER INSERT ON `clientCredit`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/client_AfterInsert.sql b/db/routines/vn/triggers/client_AfterInsert.sql
index 401d8951f..764d8f067 100644
--- a/db/routines/vn/triggers/client_AfterInsert.sql
+++ b/db/routines/vn/triggers/client_AfterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_AfterInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterInsert`
AFTER INSERT ON `client`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/collection_BEFORE_UPDATE.sql b/db/routines/vn/triggers/collection_beforeUpdate.sql
similarity index 93%
rename from db/routines/vn/triggers/collection_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/collection_beforeUpdate.sql
index a4a5ff91c..40a0b7bed 100644
--- a/db/routines/vn/triggers/collection_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/collection_beforeUpdate.sql
@@ -1,36 +1,36 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collection_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collection_beforeUpdate`
BEFORE UPDATE ON `collection`
FOR EACH ROW
-BEGIN
-
- DECLARE vStateFk INT;
- DECLARE vTotalLines INT;
- DECLARE vPickedLines INT;
-
- IF NEW.saleTotalCount <= NEW.salePickedCount
- AND (NEW.saleTotalCount != OLD.saleTotalCount
- OR NEW.salePickedCount != OLD.salePickedCount)
- THEN
-
- SELECT id INTO vStateFk
- FROM vn.state
- WHERE code = 'PREPARED';
-
- SET NEW.stateFk = vStateFk;
-
- END IF;
-
- IF NEW.saleTotalCount > NEW.salePickedCount
- AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN
-
- SELECT id INTO vStateFk
- FROM vn.state
- WHERE code = 'ON_PREPARATION';
-
- SET NEW.stateFk = vStateFk;
-
- END IF;
-
+BEGIN
+
+ DECLARE vStateFk INT;
+ DECLARE vTotalLines INT;
+ DECLARE vPickedLines INT;
+
+ IF NEW.saleTotalCount <= NEW.salePickedCount
+ AND (NEW.saleTotalCount != OLD.saleTotalCount
+ OR NEW.salePickedCount != OLD.salePickedCount)
+ THEN
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE code = 'PREPARED';
+
+ SET NEW.stateFk = vStateFk;
+
+ END IF;
+
+ IF NEW.saleTotalCount > NEW.salePickedCount
+ AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE code = 'ON_PREPARATION';
+
+ SET NEW.stateFk = vStateFk;
+
+ END IF;
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/country_AFTER_INSERT.sql b/db/routines/vn/triggers/country_afterInsert.sql
similarity index 97%
rename from db/routines/vn/triggers/country_AFTER_INSERT.sql
rename to db/routines/vn/triggers/country_afterInsert.sql
index baf17b18b..0a7e5dc00 100644
--- a/db/routines/vn/triggers/country_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/country_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_afterInsert`
AFTER INSERT ON `country`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/delivery_beforeInsert.sql b/db/routines/vn/triggers/delivery_beforeInsert.sql
new file mode 100644
index 000000000..89431c30f
--- /dev/null
+++ b/db/routines/vn/triggers/delivery_beforeInsert.sql
@@ -0,0 +1,20 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert`
+ BEFORE INSERT ON `delivery`
+ FOR EACH ROW
+BEGIN
+
+ IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
+ THEN
+ UPDATE address
+ SET longitude = NEW.longitude,
+ latitude = NEW.latitude
+ WHERE id IN (
+ SELECT addressFK
+ FROM ticket
+ WHERE id = NEW.ticketFk
+ );
+ END IF;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/delivery_beforeUpdate.sql b/db/routines/vn/triggers/delivery_beforeUpdate.sql
new file mode 100644
index 000000000..7e6aa7d4c
--- /dev/null
+++ b/db/routines/vn/triggers/delivery_beforeUpdate.sql
@@ -0,0 +1,20 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate`
+ BEFORE UPDATE ON `delivery`
+ FOR EACH ROW
+BEGIN
+
+IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
+ THEN
+ UPDATE address
+ SET longitude = NEW.longitude,
+ latitude = NEW.latitude
+ WHERE id IN (
+ SELECT addressFK
+ FROM ticket
+ WHERE id = NEW.ticketFk
+ );
+ END IF;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/duaTax_BEFORE_INSERT.sql b/db/routines/vn/triggers/duaTax_beforeInsert.sql
similarity index 93%
rename from db/routines/vn/triggers/duaTax_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/duaTax_beforeInsert.sql
index 5a937cc79..9ca1d970d 100644
--- a/db/routines/vn/triggers/duaTax_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/duaTax_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_beforeInsert`
BEFORE INSERT ON `duaTax`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/duaTax_BEFORE_UPDATE.sql b/db/routines/vn/triggers/duaTax_beforeUpdate.sql
similarity index 93%
rename from db/routines/vn/triggers/duaTax_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/duaTax_beforeUpdate.sql
index 13c7f91c7..dca8958a9 100644
--- a/db/routines/vn/triggers/duaTax_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/duaTax_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_beforeUpdate`
BEFORE UPDATE ON `duaTax`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionPallet_BEFORE_INSERT.sql b/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql
similarity index 92%
rename from db/routines/vn/triggers/expeditionPallet_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/expeditionPallet_beforeInsert.sql
index 2ed69502b..419cc2553 100644
--- a/db/routines/vn/triggers/expeditionPallet_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionPallet_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionPallet_beforeInsert`
BEFORE INSERT ON `expeditionPallet`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionScan_BEFORE_INSERT.sql b/db/routines/vn/triggers/expeditionScan_beforeInsert.sql
similarity index 88%
rename from db/routines/vn/triggers/expeditionScan_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/expeditionScan_beforeInsert.sql
index dfc25f8bc..1dce8fe9b 100644
--- a/db/routines/vn/triggers/expeditionScan_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/expeditionScan_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionScan_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionScan_beforeInsert`
BEFORE INSERT ON `expeditionScan`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionState_AfterInsert.sql b/db/routines/vn/triggers/expeditionState_AfterInsert.sql
index 618c2cfee..3d8f4130c 100644
--- a/db/routines/vn/triggers/expeditionState_AfterInsert.sql
+++ b/db/routines/vn/triggers/expeditionState_AfterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_AfterInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_afterInsert`
AFTER INSERT ON `expeditionState`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionState_BeforeInsert.sql b/db/routines/vn/triggers/expeditionState_BeforeInsert.sql
index b210889ec..350240aab 100644
--- a/db/routines/vn/triggers/expeditionState_BeforeInsert.sql
+++ b/db/routines/vn/triggers/expeditionState_BeforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_BeforeInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_beforeInsert`
BEFORE INSERT ON `expeditionState`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionTruck_BEFORE_INSERT.sql b/db/routines/vn/triggers/expeditionTruck_beforeInsert.sql
similarity index 88%
rename from db/routines/vn/triggers/expeditionTruck_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/expeditionTruck_beforeInsert.sql
index d7bf827f0..23cba7b3a 100644
--- a/db/routines/vn/triggers/expeditionTruck_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/expeditionTruck_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_beforeInsert`
BEFORE INSERT ON `expeditionTruck`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/expeditionTruck_BEFORE_UPDATE.sql b/db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql
similarity index 88%
rename from db/routines/vn/triggers/expeditionTruck_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql
index f08e02ddf..1b3b97238 100644
--- a/db/routines/vn/triggers/expeditionTruck_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_beforeUpdate`
BEFORE UPDATE ON `expeditionTruck`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/floramondoConfig_AFTER_INSERT.sql b/db/routines/vn/triggers/floramondoConfig_afterInsert.sql
similarity index 89%
rename from db/routines/vn/triggers/floramondoConfig_AFTER_INSERT.sql
rename to db/routines/vn/triggers/floramondoConfig_afterInsert.sql
index f4d9a5317..f64cb7878 100644
--- a/db/routines/vn/triggers/floramondoConfig_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/floramondoConfig_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`floramondoConfig_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`floramondoConfig_afterInsert`
AFTER INSERT ON `floramondoConfig`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/invoiceIn_au.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql
similarity index 97%
rename from db/routines/vn/triggers/invoiceIn_au.sql
rename to db/routines/vn/triggers/invoiceIn_afterUpdate.sql
index b8e385c4b..b1308393c 100644
--- a/db/routines/vn/triggers/invoiceIn_au.sql
+++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_au`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate`
AFTER UPDATE ON `invoiceIn`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/invoiceIn_bi.sql b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql
similarity index 98%
rename from db/routines/vn/triggers/invoiceIn_bi.sql
rename to db/routines/vn/triggers/invoiceIn_beforeInsert.sql
index 5baf75897..c09e71ba1 100644
--- a/db/routines/vn/triggers/invoiceIn_bi.sql
+++ b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_bi`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeInsert`
BEFORE INSERT ON `invoiceIn`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/invoiceIn_bu.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
similarity index 97%
rename from db/routines/vn/triggers/invoiceIn_bu.sql
rename to db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
index 5fe54a518..ae69ad379 100644
--- a/db/routines/vn/triggers/invoiceIn_bu.sql
+++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_bu`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate`
BEFORE UPDATE ON `invoiceIn`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql
index 159c98370..0081c8803 100644
--- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql
+++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql
@@ -3,30 +3,57 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInse
BEFORE INSERT ON `invoiceOut`
FOR EACH ROW
BEGIN
- DECLARE vRef CHAR(10) ;
+/**
+ * Generates the next reference for the invoice serial. There cannot be gaps
+ * between identifiers of the same serial!
+ *
+ * Reference format:
+ * {0} Invoice serial
+ * {1} The company code
+ * {2-3} Last two digits of issue year
+ * {4-$} Autoincrement identifier
+ */
+ DECLARE vRef INT DEFAULT 0;
+ DECLARE vRefLen INT;
+ DECLARE vRefPrefix VARCHAR(255);
+ DECLARE vLastRef VARCHAR(255);
+ DECLARE vCompanyCode INT;
+ DECLARE vYearLen INT DEFAULT 2;
+ DECLARE vPrefixLen INT;
- IF YEAR(NEW.issued) <= 2021 THEN
+ SELECT companyCode INTO vCompanyCode
+ FROM company
+ WHERE id = NEW.companyFk;
- SELECT CONCAT(NEW.serial,
- IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) ,
- RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 7,'0')) + 1) INTO vRef
- FROM invoiceOut i
- LEFT JOIN company c ON c.id = i.companyFk
- WHERE i.serial = NEW.serial
- AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued))
- AND c.id = NEW.companyFk;
- ELSE
-
- SELECT CONCAT(NEW.serial,
- IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) ,
- RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 8,'0')) + 1) INTO vRef
- FROM invoiceOut i
- LEFT JOIN company c ON c.id = i.companyFk
- WHERE i.serial = NEW.serial
- AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued))
- AND c.id = NEW.companyFk;
+ IF vCompanyCode IS NULL THEN
+ CALL util.throw('companyCodeNotDefined');
END IF;
- SET NEW.ref = vRef;
+ SELECT MAX(i.ref) INTO vLastRef
+ FROM invoiceOut i
+ WHERE i.serial = NEW.serial
+ AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.lastDayOfYear(NEW.issued)
+ AND i.companyFk = NEW.companyFk;
+
+ IF vLastRef IS NOT NULL THEN
+ SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
+ SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
+ SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
+ SET vRef = RIGHT(vLastRef, vRefLen);
+ ELSE
+ SELECT refLen INTO vRefLen FROM invoiceOutConfig;
+ SET vRefPrefix = CONCAT(
+ NEW.serial,
+ vCompanyCode,
+ RIGHT(YEAR(NEW.issued), vYearLen)
+ );
+ END IF;
+
+ SET vRef = vRef + 1;
+ IF LENGTH(vRef) > vRefLen THEN
+ CALL util.throw('refIdLenExceeded');
+ END IF;
+
+ SET NEW.ref = CONCAT(vRefPrefix, LPAD(vRef, vRefLen, '0'));
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/itemCategory_AFTER_INSERT.sql b/db/routines/vn/triggers/itemCategory_afterInsert.sql
similarity index 93%
rename from db/routines/vn/triggers/itemCategory_AFTER_INSERT.sql
rename to db/routines/vn/triggers/itemCategory_afterInsert.sql
index 82272126d..9449737d1 100644
--- a/db/routines/vn/triggers/itemCategory_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/itemCategory_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemCategory_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemCategory_afterInsert`
AFTER INSERT ON `itemCategory`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/itemShelving _afterDelete.sql b/db/routines/vn/triggers/itemShelving _afterDelete.sql
new file mode 100644
index 000000000..7c0d54358
--- /dev/null
+++ b/db/routines/vn/triggers/itemShelving _afterDelete.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving _afterDelete`
+ AFTER DELETE ON `itemShelving`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO shelvingLog
+ SET `action` = 'delete',
+ `changedModel` = 'itemShelving',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/itemShelvingSale_AFTER_INSERT.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql
similarity index 89%
rename from db/routines/vn/triggers/itemShelvingSale_AFTER_INSERT.sql
rename to db/routines/vn/triggers/itemShelvingSale_afterInsert.sql
index aca98dbef..63ca893bd 100644
--- a/db/routines/vn/triggers/itemShelvingSale_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert`
AFTER INSERT ON `itemShelvingSale`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql
similarity index 95%
rename from db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql
rename to db/routines/vn/triggers/itemShelving_afterInsert.sql
index e9b4397ca..5c0cb3853 100644
--- a/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/itemShelving_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
AFTER INSERT ON `itemShelving`
FOR EACH ROW
INSERT INTO vn.itemShelvingLog( itemShelvingFk,
diff --git a/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql b/db/routines/vn/triggers/itemShelving_afterUpdate.sql
similarity index 94%
rename from db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql
rename to db/routines/vn/triggers/itemShelving_afterUpdate.sql
index 50a9c7d01..107e8ecdc 100644
--- a/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql
+++ b/db/routines/vn/triggers/itemShelving_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate`
AFTER UPDATE ON `itemShelving`
FOR EACH ROW
INSERT INTO itemShelvingLog
diff --git a/db/routines/vn/triggers/itemShelving_BEFORE_DELETE.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql
similarity index 94%
rename from db/routines/vn/triggers/itemShelving_BEFORE_DELETE.sql
rename to db/routines/vn/triggers/itemShelving_beforeDelete.sql
index 2018066c4..a9f59e011 100644
--- a/db/routines/vn/triggers/itemShelving_BEFORE_DELETE.sql
+++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_DELETE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete`
BEFORE DELETE ON `itemShelving`
FOR EACH ROW
INSERT INTO vn.itemShelvingLog(itemShelvingFk,
diff --git a/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql b/db/routines/vn/triggers/itemShelving_beforeInsert.sql
similarity index 74%
rename from db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/itemShelving_beforeInsert.sql
index 3a3f5c41a..011cf3701 100644
--- a/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/itemShelving_beforeInsert.sql
@@ -1,11 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeInsert`
BEFORE INSERT ON `itemShelving`
FOR EACH ROW
BEGIN
-
+ SET NEW.editorFk = account.myUser_getId();
SET NEW.userFk = account.myUser_getId();
-
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/itemShelving_BEFORE_UPDATE.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql
similarity index 77%
rename from db/routines/vn/triggers/itemShelving_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/itemShelving_beforeUpdate.sql
index 6937eb1fd..6fd919d2e 100644
--- a/db/routines/vn/triggers/itemShelving_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql
@@ -1,8 +1,9 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeUpdate`
BEFORE UPDATE ON `itemShelving`
FOR EACH ROW
BEGIN
+ SET NEW.editorFk = account.myUser_getId();
IF NEW.userFk IS NULL THEN
SET NEW.userFk = account.myUser_getId();
END IF;
diff --git a/db/routines/vn/triggers/machine_BI.sql b/db/routines/vn/triggers/machine_beforeInsert.sql
similarity index 91%
rename from db/routines/vn/triggers/machine_BI.sql
rename to db/routines/vn/triggers/machine_beforeInsert.sql
index 4b9210e65..269879b22 100644
--- a/db/routines/vn/triggers/machine_BI.sql
+++ b/db/routines/vn/triggers/machine_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`machine_BI`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`machine_beforeInsert`
BEFORE INSERT ON `machine`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/parking_BEFORE_INSERT.sql b/db/routines/vn/triggers/parking_beforeInsert.sql
similarity index 91%
rename from db/routines/vn/triggers/parking_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/parking_beforeInsert.sql
index 9ae2464cb..9cf0bd42a 100644
--- a/db/routines/vn/triggers/parking_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/parking_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeInsert`
BEFORE INSERT ON `parking`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/parking_BEFORE_UPDATE.sql b/db/routines/vn/triggers/parking_beforeUpdate.sql
similarity index 92%
rename from db/routines/vn/triggers/parking_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/parking_beforeUpdate.sql
index bc2187c64..38238daa1 100644
--- a/db/routines/vn/triggers/parking_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/parking_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeUpdate`
BEFORE UPDATE ON `parking`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/projectNotes_BeforeInsert.sql b/db/routines/vn/triggers/projectNotes_BeforeInsert.sql
index 8b6424ef0..58d75bec7 100644
--- a/db/routines/vn/triggers/projectNotes_BeforeInsert.sql
+++ b/db/routines/vn/triggers/projectNotes_BeforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`projectNotes_BeforeInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`projectNotes_beforeInsert`
BEFORE INSERT ON `projectNotes`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/saleBuy_AI.sql b/db/routines/vn/triggers/saleBuy_AI.sql
deleted file mode 100644
index 3186a0ec7..000000000
--- a/db/routines/vn/triggers/saleBuy_AI.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleBuy_AI`
- AFTER INSERT ON `saleBuy`
- FOR EACH ROW
-BEGIN
-/* Activar de nuevo cuando volvamos a vender fruta y verdura
- *
- UPDATE vn.sale s
- SET s.concept = CONCAT(s.concept, ' Lote: ', NEW.buyFk)
- WHERE s.id = NEW.saleFk;
-*/
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/BEFORE_INSERT.sql b/db/routines/vn/triggers/saleBuy_beforeInsert.sql
similarity index 59%
rename from db/routines/vn/triggers/BEFORE_INSERT.sql
rename to db/routines/vn/triggers/saleBuy_beforeInsert.sql
index c0fcf4e3e..1c36671d5 100644
--- a/db/routines/vn/triggers/BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/saleBuy_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleBuy_beforeInsert`
BEFORE INSERT ON `saleBuy`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/saleGroup_afterDelete.sql b/db/routines/vn/triggers/saleGroup_afterDelete.sql
new file mode 100644
index 000000000..1e0163187
--- /dev/null
+++ b/db/routines/vn/triggers/saleGroup_afterDelete.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_afterDelete`
+ AFTER DELETE ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO ticketLog
+ SET `action` = 'delete',
+ `changedModel` = 'SaleGroup',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/saleGroup_beforeInser.sql b/db/routines/vn/triggers/saleGroup_beforeInser.sql
new file mode 100644
index 000000000..18be92ed6
--- /dev/null
+++ b/db/routines/vn/triggers/saleGroup_beforeInser.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_beforeInsert`
+ BEFORE INSERT ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/saleGroup_beforeUpdate.sql b/db/routines/vn/triggers/saleGroup_beforeUpdate.sql
new file mode 100644
index 000000000..1f6aa6def
--- /dev/null
+++ b/db/routines/vn/triggers/saleGroup_beforeUpdate.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_beforeUpdate`
+ BEFORE UPDATE ON `saleGroup`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/saleTracking_After_Insert.sql b/db/routines/vn/triggers/saleTracking_afterInsert.sql
similarity index 92%
rename from db/routines/vn/triggers/saleTracking_After_Insert.sql
rename to db/routines/vn/triggers/saleTracking_afterInsert.sql
index 861428f19..00bef8486 100644
--- a/db/routines/vn/triggers/saleTracking_After_Insert.sql
+++ b/db/routines/vn/triggers/saleTracking_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleTracking_After_Insert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleTracking_afterInsert`
AFTER INSERT ON `saleTracking`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/sale_BEFORE_DELETE.sql b/db/routines/vn/triggers/sale_beforeDelete.sql
similarity index 96%
rename from db/routines/vn/triggers/sale_BEFORE_DELETE.sql
rename to db/routines/vn/triggers/sale_beforeDelete.sql
index 724f65262..a91e7f010 100644
--- a/db/routines/vn/triggers/sale_BEFORE_DELETE.sql
+++ b/db/routines/vn/triggers/sale_beforeDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_BEFORE_DELETE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_beforeDelete`
BEFORE DELETE ON `sale`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/shelving_BEFORE_UPDATE.sql b/db/routines/vn/triggers/shelving_beforeUpdate.sql
similarity index 94%
rename from db/routines/vn/triggers/shelving_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/shelving_beforeUpdate.sql
index 770e2a495..89e7cb7e9 100644
--- a/db/routines/vn/triggers/shelving_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/shelving_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`shelving_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`shelving_beforeUpdate`
BEFORE UPDATE ON `shelving`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/solunionCAP_AFTER_INSERT.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql
similarity index 94%
rename from db/routines/vn/triggers/solunionCAP_AFTER_INSERT.sql
rename to db/routines/vn/triggers/solunionCAP_afterInsert.sql
index a35635e43..8524689a7 100644
--- a/db/routines/vn/triggers/solunionCAP_AFTER_INSERT.sql
+++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_AFTER_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert`
AFTER INSERT ON `solunionCAP`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/solunionCAP_AFTER_UPDATE.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql
similarity index 96%
rename from db/routines/vn/triggers/solunionCAP_AFTER_UPDATE.sql
rename to db/routines/vn/triggers/solunionCAP_afterUpdate.sql
index 91ea1b4ba..688241515 100644
--- a/db/routines/vn/triggers/solunionCAP_AFTER_UPDATE.sql
+++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpdate`
AFTER UPDATE ON `solunionCAP`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/solunionCAP_BEFORE_DELETE.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql
similarity index 94%
rename from db/routines/vn/triggers/solunionCAP_BEFORE_DELETE.sql
rename to db/routines/vn/triggers/solunionCAP_beforeDelete.sql
index 590a38734..85d65a949 100644
--- a/db/routines/vn/triggers/solunionCAP_BEFORE_DELETE.sql
+++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_BEFORE_DELETE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelete`
BEFORE DELETE ON `solunionCAP`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/specie_BEFORE_INSERT.sql b/db/routines/vn/triggers/specie_beforeInsert.sql
similarity index 91%
rename from db/routines/vn/triggers/specie_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/specie_beforeInsert.sql
index 2b5fd85d6..68abf0d30 100644
--- a/db/routines/vn/triggers/specie_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/specie_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_beforeInsert`
BEFORE INSERT ON `specie`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/specie_BEFORE_UPDATE.sql b/db/routines/vn/triggers/specie_beforeUpdate.sql
similarity index 91%
rename from db/routines/vn/triggers/specie_BEFORE_UPDATE.sql
rename to db/routines/vn/triggers/specie_beforeUpdate.sql
index d451c5a8f..364b1d52f 100644
--- a/db/routines/vn/triggers/specie_BEFORE_UPDATE.sql
+++ b/db/routines/vn/triggers/specie_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_BEFORE_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_beforeUpdate`
BEFORE UPDATE ON `specie`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/tag_BEFORE_INSERT.sql b/db/routines/vn/triggers/tag_beforeInsert.sql
similarity index 73%
rename from db/routines/vn/triggers/tag_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/tag_beforeInsert.sql
index 69536a711..27057754d 100644
--- a/db/routines/vn/triggers/tag_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/tag_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`tag_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`tag_beforeInsert`
BEFORE INSERT ON `tag`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/ticketPackaging_BEFORE_INSERT.sql b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql
similarity index 90%
rename from db/routines/vn/triggers/ticketPackaging_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/ticketPackaging_beforeInsert.sql
index 36d64ca3e..a58955e0d 100644
--- a/db/routines/vn/triggers/ticketPackaging_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_beforeInsert`
BEFORE INSERT ON `ticketPackaging`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/ticketParking_BEFORE_INSERT.sql b/db/routines/vn/triggers/ticketParking_beforeInsert.sql
similarity index 88%
rename from db/routines/vn/triggers/ticketParking_BEFORE_INSERT.sql
rename to db/routines/vn/triggers/ticketParking_beforeInsert.sql
index ec403b307..2add4f3ea 100644
--- a/db/routines/vn/triggers/ticketParking_BEFORE_INSERT.sql
+++ b/db/routines/vn/triggers/ticketParking_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketParking_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketParking_beforeInsert`
BEFORE INSERT ON `ticketParking`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/ticketService_ad.sql b/db/routines/vn/triggers/ticketService_afterDelete.sql
similarity index 94%
rename from db/routines/vn/triggers/ticketService_ad.sql
rename to db/routines/vn/triggers/ticketService_afterDelete.sql
index 94c771c65..11d5aaf24 100644
--- a/db/routines/vn/triggers/ticketService_ad.sql
+++ b/db/routines/vn/triggers/ticketService_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_ad`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterDelete`
AFTER DELETE ON `ticketService`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/ticketService_ai.sql b/db/routines/vn/triggers/ticketService_afterInsert.sql
similarity index 89%
rename from db/routines/vn/triggers/ticketService_ai.sql
rename to db/routines/vn/triggers/ticketService_afterInsert.sql
index c98ebccd5..b9142ff72 100644
--- a/db/routines/vn/triggers/ticketService_ai.sql
+++ b/db/routines/vn/triggers/ticketService_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_ai`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterInsert`
AFTER INSERT ON `ticketService`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/ticketService_au.sql b/db/routines/vn/triggers/ticketService_afterUpdate.sql
similarity index 94%
rename from db/routines/vn/triggers/ticketService_au.sql
rename to db/routines/vn/triggers/ticketService_afterUpdate.sql
index 989cb3b08..ecc9e9a5a 100644
--- a/db/routines/vn/triggers/ticketService_au.sql
+++ b/db/routines/vn/triggers/ticketService_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_au`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterUpdate`
AFTER UPDATE ON `ticketService`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/time_AFTER_UPDATE.sql b/db/routines/vn/triggers/time_afterUpdate.sql
similarity index 96%
rename from db/routines/vn/triggers/time_AFTER_UPDATE.sql
rename to db/routines/vn/triggers/time_afterUpdate.sql
index 14fdf96dc..1eb735923 100644
--- a/db/routines/vn/triggers/time_AFTER_UPDATE.sql
+++ b/db/routines/vn/triggers/time_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`time_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`time_afterUpdate`
AFTER UPDATE ON `time`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql
index 38e28b7e9..4e1dae3ef 100644
--- a/db/routines/vn/triggers/travel_beforeInsert.sql
+++ b/db/routines/vn/triggers/travel_beforeInsert.sql
@@ -7,15 +7,6 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
- -- Actualizar agencyFk y agencyModeFk
- IF NEW.agencyFk THEN
- SET NEW.agencyModeFk = NEW.agencyFk;
- END IF;
-
- IF NEW.agencyModeFk THEN
- SET NEW.agencyFk = NEW.agencyModeFk;
- END IF;
-
- CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
+ CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 46fa2edb8..440b21c04 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -18,15 +18,6 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
END IF;
- -- Actualizar agencyFk y agencyModeFk
- IF NOT (NEW.agencyFk <=> OLD.agencyFk)THEN
- SET NEW.agencyModeFk = NEW.agencyFk;
- END IF;
-
- IF NOT (NEW.agencyModeFk <=> OLD.agencyModeFk) THEN
- SET NEW.agencyFk = NEW.agencyModeFk;
- END IF;
-
IF NOT (NEW.isReceived <=> OLD.isReceived) THEN
CALL travel_checkPackaging(NEW.id);
END IF;
diff --git a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql
new file mode 100644
index 000000000..6f0f00dbf
--- /dev/null
+++ b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_afterDelete`
+ AFTER DELETE ON `workerTimeControl`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO workerLog
+ SET `action` = 'delete',
+ `changedModel` = 'WorkerTimeControl',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/workerTimeControl_AI.sql b/db/routines/vn/triggers/workerTimeControl_afterInsert.sql
similarity index 65%
rename from db/routines/vn/triggers/workerTimeControl_AI.sql
rename to db/routines/vn/triggers/workerTimeControl_afterInsert.sql
index 8e55004eb..b8b9c3b01 100644
--- a/db/routines/vn/triggers/workerTimeControl_AI.sql
+++ b/db/routines/vn/triggers/workerTimeControl_afterInsert.sql
@@ -1,10 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_AI`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_afterInsert`
AFTER INSERT ON `workerTimeControl`
FOR EACH ROW
BEGIN
- IF NEW.timed > DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY) THEN
+ IF NEW.timed > (util.VN_NOW() + INTERVAL 1 DAY) THEN
CALL util.throw('date in the future');
- END IF;
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql b/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql
new file mode 100644
index 000000000..a899b879a
--- /dev/null
+++ b/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeInsert`
+ BEFORE INSERT ON `workerTimeControl`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql b/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql
new file mode 100644
index 000000000..969e08711
--- /dev/null
+++ b/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeUpdate`
+ BEFORE UPDATE ON `workerTimeControl`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/workingHoursBeforeInsert.sql b/db/routines/vn/triggers/workingHours_beforeInsert.sql
similarity index 93%
rename from db/routines/vn/triggers/workingHoursBeforeInsert.sql
rename to db/routines/vn/triggers/workingHours_beforeInsert.sql
index 763061be8..dce726f10 100644
--- a/db/routines/vn/triggers/workingHoursBeforeInsert.sql
+++ b/db/routines/vn/triggers/workingHours_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workingHoursBeforeInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workingHours_beforeInsert`
BEFORE INSERT ON `workingHours`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/zoneExclusion_BI.sql b/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql
similarity index 91%
rename from db/routines/vn/triggers/zoneExclusion_BI.sql
rename to db/routines/vn/triggers/zoneExclusion_beforeInsert.sql
index 117a482ab..6b2d2f5c7 100644
--- a/db/routines/vn/triggers/zoneExclusion_BI.sql
+++ b/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_BI`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeInsert`
BEFORE INSERT ON `zoneExclusion`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/triggers/zoneExclusion_BU.sql b/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql
similarity index 91%
rename from db/routines/vn/triggers/zoneExclusion_BU.sql
rename to db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql
index cab6ae3c4..1daa6d2f0 100644
--- a/db/routines/vn/triggers/zoneExclusion_BU.sql
+++ b/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_BU`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeUpdate`
BEFORE UPDATE ON `zoneExclusion`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn/views/awbVolume.sql b/db/routines/vn/views/awbVolume.sql
index 0f4778864..2c77973ca 100644
--- a/db/routines/vn/views/awbVolume.sql
+++ b/db/routines/vn/views/awbVolume.sql
@@ -1,7 +1,7 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`awbVolume`
-AS SELECT `d`.`awbFk` AS `awbFk`,
+AS SELECT `t`.`awbFk` AS `awbFk`,
`b`.`stickers` * `i`.`density` * IF(
`p`.`volume` > 0,
`p`.`volume`,
@@ -14,23 +14,18 @@ FROM (
(
(
(
- (
- (
- `vn`.`buy` `b`
- JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
- )
- JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
- )
- JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
+ `vn`.`buy` `b`
+ JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
)
- JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
+ JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
)
- JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
+ JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
)
- JOIN `vn`.`duaEntry` `de` ON(`de`.`entryFk` = `e`.`id`)
+ JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
)
- JOIN `vn`.`dua` `d` ON(`d`.`id` = `de`.`duaFk`)
+ JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
)
JOIN `vn`.`volumeConfig` `vc`
)
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
+ AND t.awbFk
\ No newline at end of file
diff --git a/db/routines/vn/views/expeditionRoute_freeTickets.sql b/db/routines/vn/views/expeditionRoute_freeTickets.sql
index 2c25ac94f..85e6297c9 100644
--- a/db/routines/vn/views/expeditionRoute_freeTickets.sql
+++ b/db/routines/vn/views/expeditionRoute_freeTickets.sql
@@ -1,17 +1,26 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
- VIEW `vn`.`expeditionRoute_freeTickets` AS
-SELECT
- `t`.`routeFk` AS `routeFk`,
- `tss`.`ticketFk` AS `ticket`,
- `s`.`name` AS `code`,
- `w`.`name` AS `almacen`,
- `tss`.`updated` AS `updated`,
- `p`.`code` AS `parkingCode`
- FROM `vn`.`ticketState` `tss`
- JOIN `vn`.`ticket` `t` ON `t`.`id` = `tss`.`ticketFk`
- JOIN `vn`.`warehouse` `w` ON `w`.`id` = `t`.`warehouseFk`
- JOIN `vn`.`state` `s` ON `s`.`id` = `tss`.`state`
- LEFT JOIN `vn`.`ticketParking` `tp` ON `tp`.`ticketFk` = `t`.`id`
- LEFT JOIN `vn`.`parking` `p` ON `p`.`id` = `tp`.`parkingFk`
- WHERE IFNULL(`t`.`packages`, 0) = 0;
\ No newline at end of file
+ VIEW `vn`.`expeditionRoute_freeTickets`
+AS SELECT `t`.`routeFk` AS `routeFk`,
+ `tss`.`ticketFk` AS `ticket`,
+ `s`.`name` AS `code`,
+ `w`.`name` AS `almacen`,
+ `tss`.`updated` AS `updated`,
+ `p`.`code` AS `parkingCode`
+FROM (
+ (
+ (
+ (
+ (
+ `vn`.`ticketState` `tss`
+ JOIN `vn`.`ticket` `t` ON(`t`.`id` = `tss`.`ticketFk`)
+ )
+ JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `t`.`warehouseFk`)
+ )
+ JOIN `vn`.`state` `s` ON(`s`.`id` = `tss`.`state`)
+ )
+ LEFT JOIN `vn`.`ticketParking` `tp` ON(`tp`.`ticketFk` = `t`.`id`)
+ )
+ LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `tp`.`parkingFk`)
+ )
+WHERE IFNULL(`t`.`packages`, 0) = 0
diff --git a/db/routines/vn/views/itemShelvingAvailable.sql b/db/routines/vn/views/itemShelvingAvailable.sql
index e9599a1db..868d6a963 100644
--- a/db/routines/vn/views/itemShelvingAvailable.sql
+++ b/db/routines/vn/views/itemShelvingAvailable.sql
@@ -38,7 +38,7 @@ FROM (
)
JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`)
)
- JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticket` = `t`.`id`)
+ JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
)
JOIN `vn`.`state` `st` ON(`st`.`id` = `tst`.`state`)
)
diff --git a/db/routines/vn/views/itemShelvingStock.sql b/db/routines/vn/views/itemShelvingStock.sql
index c4057d7f0..15afe72a2 100644
--- a/db/routines/vn/views/itemShelvingStock.sql
+++ b/db/routines/vn/views/itemShelvingStock.sql
@@ -1,27 +1,35 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`itemShelvingStock` AS
-SELECT ish.itemFk,
- SUM(ish.visible) visible,
- MIN(ish.packing) packing,
- MIN(ish.`grouping`) `grouping`,
- s.description sector,
- SUM(ish.visible) visibleOriginal,
- 0 removed,
- p.sectorFk,
- s.warehouseFk,
- ish.shelvingFk,
- p.code,
- sh.parkingFk,
- ish.id itemShelvingFk,
- ish.created,
- st.description = 'previousPrepared' isPreviousPrepared
- FROM itemShelving ish
- LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
- LEFT JOIN parking p ON p.id = sh.parkingFk
- LEFT JOIN sector s ON s.id = p.sectorFk
- LEFT JOIN sectorType st ON st.id = s.typeFk
- WHERE ish.visible <> 0
- AND p.sectorFk <> 0
- GROUP BY ish.itemFk,
- p.sectorFk
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn`.`itemShelvingStock`
+AS SELECT `ish`.`itemFk` AS `itemFk`,
+ sum(`ish`.`visible`) AS `visible`,
+ min(`ish`.`packing`) AS `packing`,
+ min(`ish`.`grouping`) AS `grouping`,
+ `s`.`description` AS `sector`,
+ sum(`ish`.`visible`) AS `visibleOriginal`,
+ 0 AS `removed`,
+ `p`.`sectorFk` AS `sectorFk`,
+ `s`.`warehouseFk` AS `warehouseFk`,
+ `ish`.`shelvingFk` AS `shelvingFk`,
+ `p`.`code` AS `parkingCode`,
+ `sh`.`parkingFk` AS `parkingFk`,
+ `ish`.`id` AS `itemShelvingFk`,
+ `ish`.`created` AS `created`,
+ `st`.`description` = 'previousPrepared' AS `isPreviousPrepared`
+FROM (
+ (
+ (
+ (
+ `vn`.`itemShelving` `ish`
+ LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ )
+ LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
+ )
+ LEFT JOIN `vn`.`sector` `s` ON(`s`.`id` = `p`.`sectorFk`)
+ )
+ LEFT JOIN `vn`.`sectorType` `st` ON(`st`.`id` = `s`.`typeFk`)
+ )
+WHERE `ish`.`visible` <> 0
+ AND `p`.`sectorFk` <> 0
+GROUP BY `ish`.`itemFk`,
+ `p`.`sectorFk`
diff --git a/db/routines/vn/views/ticketDownBuffer.sql b/db/routines/vn/views/ticketDownBuffer.sql
index 84e053fd4..4d157f20c 100644
--- a/db/routines/vn/views/ticketDownBuffer.sql
+++ b/db/routines/vn/views/ticketDownBuffer.sql
@@ -15,8 +15,8 @@ FROM (
)
JOIN `vn`.`parking` `pk` ON(`pk`.`id` = `tp`.`parkingFk`)
)
- JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticket` = `td`.`ticketFk`)
+ JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `td`.`ticketFk`)
)
- JOIN `vn`.`worker` `w` ON(`w`.`id` = `tst`.`worker`)
+ JOIN `vn`.`worker` `w` ON(`w`.`id` = `tst`.`userFk`)
)
WHERE `td`.`selected` = 2
diff --git a/db/routines/vn/views/ticketState.sql b/db/routines/vn/views/ticketState.sql
index f8273d7a9..118a58b34 100644
--- a/db/routines/vn/views/ticketState.sql
+++ b/db/routines/vn/views/ticketState.sql
@@ -3,14 +3,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
VIEW `vn`.`ticketState`
AS SELECT `tt`.`created` AS `updated`,
`tt`.`stateFk` AS `stateFk`,
- `tt`.`userFk` AS `workerFk`,
+ `tt`.`userFk` AS `userFk`,
`tls`.`ticketFk` AS `ticketFk`,
`s`.`id` AS `state`,
`s`.`order` AS `productionOrder`,
`s`.`alertLevel` AS `alertLevel`,
`s`.`code` AS `code`,
- `tls`.`ticketFk` AS `ticket`,
- `tt`.`userFk` AS `worker`,
`s`.`isPreviousPreparable` AS `isPreviousPreparable`,
`s`.`isPicked` AS `isPicked`
FROM (
diff --git a/db/routines/vn/views/ticketStateToday.sql b/db/routines/vn/views/ticketStateToday.sql
index f4a0ebc02..cf1f24539 100644
--- a/db/routines/vn/views/ticketStateToday.sql
+++ b/db/routines/vn/views/ticketStateToday.sql
@@ -5,7 +5,7 @@ AS SELECT `ts`.`ticketFk` AS `ticket`,
`ts`.`state` AS `state`,
`ts`.`productionOrder` AS `productionOrder`,
`ts`.`alertLevel` AS `alertLevel`,
- `ts`.`worker` AS `worker`,
+ `ts`.`userFk` AS `worker`,
`ts`.`code` AS `code`,
`ts`.`updated` AS `updated`,
`ts`.`isPicked` AS `isPicked`
diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql
index cfd837add..081ccb0bd 100644
--- a/db/routines/vn/views/zoneEstimatedDelivery.sql
+++ b/db/routines/vn/views/zoneEstimatedDelivery.sql
@@ -19,7 +19,7 @@ FROM (
(
(
`vn`.`ticket` `t`
- JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticket` = `t`.`id`)
+ JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
)
JOIN `vn`.`state` `s` ON(`s`.`id` = `tst`.`state`)
)
diff --git a/db/routines/vn2008/procedures/Cajas_Saldo_Detalle.sql b/db/routines/vn2008/procedures/Cajas_Saldo_Detalle.sql
deleted file mode 100644
index 3dd9e9dc4..000000000
--- a/db/routines/vn2008/procedures/Cajas_Saldo_Detalle.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`Cajas_Saldo_Detalle`()
-BEGIN
-
- Select Proveedores.Id_Proveedor, Proveedor, Fecha, round(Importe) as Importe
- from Proveedores
- join
- (
- select Fecha, sub.Id_Proveedor, sum(Importe) as Importe
- from
-
- (
-
- select round(sum(Importe),2) as Importe, TIMESTAMPADD(DAY,-1,util.VN_CURDATE()) as Fecha, Id_Proveedor
- from pago
- join Proveedores using(Id_Proveedor)
- where Fecha >= '2011-01-01'
- and Id_Proveedor NOT IN (select id from empresa)
- group by Id_Proveedor
-
- union all
-
- select IFNULL(-1 * round(sum(rv.Cantidad / if(Id_Moneda = 2,rate,1)),2),0) AS Vto, TIMESTAMPADD(DAY,-1,util.VN_CURDATE()), proveedor_id
- from recibida_vencimiento rv
- join recibida r on r.id = rv.recibida_id
- join reference_rate rr on rr.`date` = rv.fecha
- join Proveedores P on P.Id_Proveedor = r.proveedor_id
- join Paises PS on PS.Id = P.pais_id
- where rv.fecha between '2011-01-01' and util.VN_CURDATE()-1
- and Id_Proveedor NOT IN (select id from empresa)
- group by proveedor_id
-
- union all
-
- select -1 * round(rv.Cantidad / if(Id_Moneda = 2,(SELECT value FROM vn.referenceRate ORDER BY dated DESC LIMIT 1),1),2) AS Vto, rv.fecha, proveedor_id
- from recibida_vencimiento rv
- join recibida r on r.id = rv.recibida_id
- join Proveedores P on P.Id_Proveedor = r.proveedor_id
- join Paises PS on PS.Id = P.pais_id
- where rv.fecha >= util.VN_CURDATE()
- and Id_Proveedor NOT IN (select id from empresa)
-
- union all
-
- select @remesas:= @pago:= @saldo:= 0.0000, util.VN_CURDATE(), @prov:= 0) sub
- group by Fecha,Id_Proveedor
- ) sub2 using(Id_Proveedor)
- having Importe < -100
- ;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/CompresTriggerBeforeDelete.sql b/db/routines/vn2008/procedures/CompresTriggerBeforeDelete.sql
deleted file mode 100644
index 3c8e40702..000000000
--- a/db/routines/vn2008/procedures/CompresTriggerBeforeDelete.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`CompresTriggerBeforeDelete`(oldId INT, oldEntrada INT)
-BEGIN
-
- DECLARE hasToRecalculate BOOLEAN;
- DECLARE newWarehouse INT;
-
- SELECT Id_Compra INTO hasToRecalculate FROM vn.lastBuy lb
- WHERE lb.id = oldId LIMIT 1;
-
- IF hasToRecalculate THEN
- SELECT warehouse_id INTO newWarehouse FROM travel t
- JOIN Entradas e ON t.id = e.travel_id
- WHERE e.Id_Entrada = oldEntrada;
-
- CALL vn.lastBuyRefresh(newWarehouse);
- END IF;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/EntradasTriggerBeforeDelete.sql b/db/routines/vn2008/procedures/EntradasTriggerBeforeDelete.sql
deleted file mode 100644
index e48359f55..000000000
--- a/db/routines/vn2008/procedures/EntradasTriggerBeforeDelete.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`EntradasTriggerBeforeDelete`(oldTravel INT, oldId INT)
-BEGIN
-
- DECLARE hasToRecalculate BOOLEAN;
- DECLARE newWarehouse INT;
-
- SELECT Id_Compra INTO hasToRecalculate FROM Compres c
- JOIN vn.lastBuy lb ON lb.id = c.Id_Compra
- WHERE c.Id_Entrada = newId LIMIT 1;
- IF hasToRecalculate THEN
- SELECT warehouse_id INTO newWarehouse FROM travel WHERE id = oldTravel;
- CALL vn.lastBuyRefresh(newWarehouse);
- END IF;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/EntradasTriggerBeforeUpdate.sql b/db/routines/vn2008/procedures/EntradasTriggerBeforeUpdate.sql
deleted file mode 100644
index 8e387ce1f..000000000
--- a/db/routines/vn2008/procedures/EntradasTriggerBeforeUpdate.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`EntradasTriggerBeforeUpdate`(oldTravel INT, newTravel INT, oldRedada BOOLEAN,
- newRedada BOOLEAN, newId INT)
-BEGIN
- DECLARE newWarehouse INTEGER;
- DECLARE hasToRecalculate BOOLEAN;
-
- IF oldRedada <> newRedada OR newTravel IS NULL THEN
-
- SELECT Id_Compra INTO hasToRecalculate FROM Compres c
- JOIN vn.lastBuy lb ON lb.id = c.Id_Compra
- WHERE c.Id_Entrada = newId LIMIT 1;
- IF hasToRecalculate THEN
- SELECT warehouse_id INTO newWarehouse FROM travel WHERE id = newtravel;
- CALL vn.lastBuyRefresh(newWarehouse);
- END IF;
- END IF;
-
- IF newTravel <> oldTravel AND newTravel IS NOT NULL THEN
- UPDATE travel t
- JOIN Compres c ON c.Id_Entrada = newId
- JOIN vn.lastBuy lb ON c.Id_Article = lb.item AND t.warehouse_id = lb.warehouse
- SET lb.id = c.Id_Compra
- WHERE t.id = newTravel AND t.landing BETWEEN vn.getInventoryDate() AND util.yesterday()
- AND t.landing > lb.landing;
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/Facturas_Saltos.sql b/db/routines/vn2008/procedures/Facturas_Saltos.sql
deleted file mode 100644
index 22c7ab516..000000000
--- a/db/routines/vn2008/procedures/Facturas_Saltos.sql
+++ /dev/null
@@ -1,65 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`Facturas_Saltos`(IN datSTART DATE , IN datEND DATE)
-BEGIN
-
-
-DECLARE strSER1 VARCHAR(2);
-DECLARE strSER2 VARCHAR(2);
-DECLARE intEMP1 INT;
-DECLARE intEMP2 INT;
-DECLARE v_done BOOLEAN DEFAULT FALSE;
-DECLARE strFAC1 VARCHAR(11);
-DECLARE strFAC2 VARCHAR(11);
-
-
-DECLARE rs CURSOR FOR
- SELECT Id_Factura, empresa_id, Serie
- FROM Facturas
- WHERE Fecha BETWEEN datSTART AND datEND
- ORDER BY empresa_id, Serie, Id_Factura;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;
-
-OPEN rs;
-
-DROP TEMPORARY TABLE IF EXISTS Facturas_Saltarinas;
-
-CREATE TEMPORARY TABLE Facturas_Saltarinas
-(Factura_Inicial VARCHAR(11),
- Factura_Final VARCHAR(11),
- Empresa VARCHAR(3),
- Serie VARCHAR(1));
-
-FETCH rs INTO strFAC1, intEMP1, strSER1;
-
-IF NOT v_done THEN
-
- FETCH rs INTO strFAC2, intEMP2, strSER2;
-
-END IF;
-
-WHILE NOT v_done DO
-
- IF strSER1 = strSER2 AND intEMP1 = intEMP2 AND right(strFAC2,5) - right(strFAC1,5) > 1 then
-
- INSERT INTO Facturas_Saltarinas(Factura_Inicial, Factura_Final, Empresa, Serie)
- SELECT strFAC1, strFAC2, abbreviation, strSER1
- FROM empresa
- WHERE id = intEMP1;
-
- END IF;
-
- SET strFAC1 = strFAC2;
- SET intEMP1 = intEMP2;
- SET STRSER1 = strSER2;
-
- FETCH rs INTO strFAC2, intEMP2, strSER2;
-
-END WHILE;
-
-SELECT * FROM Facturas_Saltarinas;
-
-CLOSE rs;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/InsertarEspionaje.sql b/db/routines/vn2008/procedures/InsertarEspionaje.sql
deleted file mode 100644
index 5ddc1c820..000000000
--- a/db/routines/vn2008/procedures/InsertarEspionaje.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`InsertarEspionaje`(intIdTrabajador INT(11),intIdEquipo int)
-BEGIN
-
-DECLARE intNReg TINYINT DEFAULT 0;
-
-SELECT Count(*) AS NReg
-INTO intNReg
-FROM Espionajes
-WHERE Fecha=Current_date
-AND Id_Trabajador=intIdTrabajador;
-
-IF (intNReg=0) THEN
- INSERT INTO Espionajes (Id_Trabajador,Fecha,HoraEntrada,Id_Equipo)
- VALUES (intIdTrabajador,CURRENT_DATE,CURRENT_TIME,intIdEquipo);
-ELSE
- UPDATE Espionajes
- SET HoraSalida=CURRENT_TIME
- WHERE Id_Trabajador=intIdTrabajador
- AND Fecha=util.VN_CURDATE();
-END IF;
-
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/Rutas_Graph.sql b/db/routines/vn2008/procedures/Rutas_Graph.sql
deleted file mode 100644
index b1a7471d0..000000000
--- a/db/routines/vn2008/procedures/Rutas_Graph.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`Rutas_Graph`()
-BEGIN
-
- DECLARE datSTART DATE DEFAULT TIMESTAMPADD(DAY,-3,util.VN_CURDATE());
- DECLARE datEND DATE;
-
- SET datEND = util.dayEnd(timestampadd(DAY,3,util.VN_CURDATE()));
-
- CALL vn.buyUltimate(NULL, datSTART);
-
- SELECT CAST(SUM(Cantidad * vn.buy_getUnitVolume(buy_id)) / 1000000 AS DECIMAL(5,1)) AS m3, Agencia, w.name AS Almacen, DATE(R.Fecha) AS Fecha_Ruta
- FROM vn2008.Rutas R
- JOIN vn2008.Agencias a ON a.Id_Agencia = R.Id_Agencia
- JOIN vn2008.Tickets t USING(Id_Ruta)
- JOIN vn2008.warehouse w ON w.id = t.warehouse_id
- JOIN vn2008.Movimientos m USING(Id_Ticket)
- JOIN cache.last_buy b ON m.Id_Article = b.item_id AND t.warehouse_id = b.warehouse_id
- WHERE R.Fecha BETWEEN datSTART AND datEND
- GROUP BY Agencia, Almacen, Fecha_Ruta
- UNION ALL
- SELECT CAST(SUM(Cantidad * vn.buy_getUnitVolume(buy_id)) / 1000000 AS decimal(5,1)) AS m3 ,Agencia, w.name AS Almacen, timestampadd(DAY,1,t.Fecha) AS Fecha
- FROM vn2008.Tickets t
- JOIN warehouse w ON w.id = warehouse_id
- JOIN Agencias a USING(Id_Agencia)
- JOIN vn2008.Movimientos m USING(Id_Ticket)
- JOIN cache.last_buy b ON m.Id_Article = b.item_id AND t.warehouse_id = b.warehouse_id
- LEFT JOIN warehouse_pickup wp ON wp.agency_id = t.Id_Agencia and wp.warehouse_id = t.warehouse_id
- JOIN warehouse_pickup is_rec ON is_rec.agency_id = t.Id_Agencia
- WHERE t.Fecha BETWEEN TIMESTAMPADD(DAY,-1,datSTART) AND TIMESTAMPADD(DAY,-1,datEND)
- AND wp.agency_id IS NULL
- GROUP BY Agencia, Almacen, timestampadd(DAY,1,t.Fecha)
- -- JGF 2016-05-05
- UNION ALL
- SELECT CAST(SUM(Cantidad * vn.buy_getUnitVolume(Id_Compra)) / 1000000 AS decimal(5,1)) AS m3 ,a.Agencia, w.name AS Almacen, timestampadd(DAY,1,t.shipment) AS Fecha
- FROM Compres c
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- JOIN Agencias a ON a.Id_Agencia = t.agency_id
- JOIN warehouse w ON w.id = t.warehouse_id_out
- JOIN warehouse_pickup wp ON wp.warehouse_id = t.warehouse_id_out
- WHERE t.shipment BETWEEN TIMESTAMPADD(DAY,-1,datSTART) AND TIMESTAMPADD(DAY,-1,datEND)
- GROUP BY a.Agencia, Almacen, Fecha;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/Trabuque.sql b/db/routines/vn2008/procedures/Trabuque.sql
deleted file mode 100644
index 9efbc86c9..000000000
--- a/db/routines/vn2008/procedures/Trabuque.sql
+++ /dev/null
@@ -1,72 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`Trabuque`(IN intIDTICKET BIGINT, IN dblINCREMENTO DOUBLE )
-BEGIN
-
-
-
-#Vamos a calcular el porcentaje a incrementar las cantidades de las lineas de movimiento para inflar / desinflar la base final
-
-DECLARE dblBASE_INICIAL DOUBLE DEFAULT 0;
-DECLARE dblBASE_FINAL DOUBLE DEFAULT 0;
-DECLARE dblAUMENTO DOUBLE DEFAULT 1;
-
-
-SELECT SUM(Cantidad * Preu * (100 - Descuento) / 100)
-INTO dblBASE_INICIAL
-FROM Movimientos
-WHERE Id_Ticket = intIDTICKET;
-
-SET dblBASE_FINAL = dblBASE_INICIAL;
-
-
-#Eliminamos lineas a 0
-
-DELETE FROM Movimientos WHERE Cantidad = 0 AND Id_Ticket = intIDTICKET;
-
-# Vamos a ir probando incrementos paulatinos hasta que encontremos el que supera lo pedido, teniendo en cuenta el sentido del incremento
-
-IF dblINCREMENTO < 0 THEN
-
-
-
- WHILE (dblBASE_FINAL > dblBASE_INICIAL + dblINCREMENTO) or (dblAUMENTO < 0 ) DO
-
- SET dblAUMENTO = dblAUMENTO - 0.01;
-
- SELECT SUM(IF(@cantidad:= ROUND(dblAUMENTO * Cantidad),@cantidad,1) * Preu * (100 - Descuento) / 100)
- INTO dblBASE_FINAL
- FROM Movimientos
- WHERE Id_Ticket = intIDTICKET;
-
- END WHILE;
-
-ELSE
-
- WHILE dblBASE_FINAL < dblBASE_INICIAL + dblINCREMENTO DO
-
- SET dblAUMENTO = dblAUMENTO + 0.01;
-
- SELECT SUM(IF(@cantidad:= ROUND(dblAUMENTO * Cantidad),@cantidad,1) * Preu * (100 - Descuento) / 100)
- INTO dblBASE_FINAL
- FROM Movimientos
- WHERE Id_Ticket = intIDTICKET;
-
- END WHILE;
-
-END IF;
-
-UPDATE Movimientos
-SET Cantidad = IF(@cantidad:= ROUND(dblAUMENTO * Cantidad),@cantidad,1)
-WHERE Id_Ticket = intIDTICKET;
-
-SELECT tipoiva
- , ROUND(SUM(Cantidad * Preu * (100 - Descuento) / 100),2) as Base
- , ROUND(ROUND(SUM(Cantidad * Preu * (100 - Descuento) / 100),2) * iva / 100,2) as Cuota
-FROM Movimientos M
-INNER JOIN Articles A USING(Id_Article)
-INNER JOIN tblIVA USING(tipoiva)
-WHERE Id_Ticket = intIDTICKET
-GROUP BY tipoiva;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/Vehiculos_consumo_calculateLiters100km.sql b/db/routines/vn2008/procedures/Vehiculos_consumo_calculateLiters100km.sql
deleted file mode 100644
index 5c8f174be..000000000
--- a/db/routines/vn2008/procedures/Vehiculos_consumo_calculateLiters100km.sql
+++ /dev/null
@@ -1,42 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`Vehiculos_consumo_calculateLiters100km`()
-BEGIN
- DECLARE vConsumptionVehicleId INT;
- DECLARE vDone BOOL;
- DECLARE vOldKm INT;
- DECLARE vOldLiters INT;
- DECLARE vNewKm INT;
- DECLARE vVehicleId INT;
-
- DECLARE cur CURSOR FOR
- SELECT Vehiculos_consumo_id, Id_Vehiculo, km FROM vn2008.Vehiculos_consumo;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- OPEN cur;
-
- l: LOOP
- SET vDone = FALSE;
- FETCH cur INTO vConsumptionVehicleId, vVehicleId, vNewKm;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- SELECT km, litros INTO vOldKm, vOldLiters
- FROM Vehiculos_consumo
- WHERE Id_Vehiculo = vVehicleId
- AND Vehiculos_consumo_id < vConsumptionVehicleId
- ORDER BY Vehiculos_consumo_id DESC
- LIMIT 1;
-
- UPDATE Vehiculos_consumo
- SET liters100km = vOldLiters/((vNewKm-vOldKm)*0.01)
- WHERE Vehiculos_consumo_id = vConsumptionVehicleId;
-
- END LOOP;
-
- CLOSE cur;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/add_awb_component.sql b/db/routines/vn2008/procedures/add_awb_component.sql
index a563bd0df..e75290b4b 100644
--- a/db/routines/vn2008/procedures/add_awb_component.sql
+++ b/db/routines/vn2008/procedures/add_awb_component.sql
@@ -5,13 +5,10 @@ BEGIN
DECLARE vShipped DATE;
DECLARE vHasStems BOOLEAN;
- SELECT tr.shipped, IF(a.stems, TRUE, FALSE)
+ SELECT t.shipped, IF(a.stems, TRUE, FALSE)
INTO vShipped, vHasStems
- FROM vn.travel tr
- JOIN vn.entry e ON e.travelFk = tr.id
- JOIN vn.duaEntry de ON de.entryFk = e.id
- JOIN vn.dua d ON d.id = de.duaFk
- JOIN vn.awb a ON a.id = d.awbFk
+ FROM vn.travel t
+ JOIN vn.awb a ON a.id = t.awbFk
WHERE awbFk = vAwbFk
LIMIT 1;
diff --git a/db/routines/vn2008/procedures/agencia_descuadre.sql b/db/routines/vn2008/procedures/agencia_descuadre.sql
deleted file mode 100644
index 59bf2476d..000000000
--- a/db/routines/vn2008/procedures/agencia_descuadre.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencia_descuadre`(vFrom DATE, vTo DATE, vAgencyModeFk INT, vWarehouseAlias INT)
-BEGIN
- DECLARE vToDayEnd DATETIME;
-
- SET vToDayEnd = util.dayEnd(vTo);
-
- SELECT t.id ticketFk,t.addressFk,
- v.amount AS VN, v.amount - shipping_charge AS Difer,
- e.shipping_charge AS teorico, t.packages, t.clientFk, t.zoneFk, a.provinceFk
-
- FROM vn.ticket t
- LEFT JOIN
- (SELECT ticketFk, SUM(amount) amount,shipped
- FROM vn.sale_freightComponent
- WHERE shipped BETWEEN vFrom AND vToDayEnd
- GROUP BY ticketFk) v ON t.id = v.ticketFk
- LEFT JOIN (SELECT t.id, SUM(t.zonePrice * ebv.ratio) shipping_charge
- FROM vn.ticket t
- LEFT JOIN vn.expedition e ON e.ticketFk = t.id
- JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
- WHERE t.shipped BETWEEN vFrom AND vToDayEnd
- GROUP BY t.id
- ) e ON t.id = e.id
- JOIN vn.address a ON a.id = t.addressFk
- JOIN warehouse_group wg ON wg.warehouse_id = t.warehouseFk
- WHERE DATE(t.shipped) BETWEEN vFrom AND vToDayEnd
- AND t.agencyModeFk = vAgencyModeFk
- AND wg.warehouse_alias_id = vWarehouseAlias;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/article_available_single.sql b/db/routines/vn2008/procedures/article_available_single.sql
deleted file mode 100644
index efc0df3b7..000000000
--- a/db/routines/vn2008/procedures/article_available_single.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`article_available_single`(IN v_wh TINYINT, IN v_date DATETIME, IN id_single INT)
-BEGIN
-
-/* CALL bionic_available_single (v_wh, v_date,id_single,0);*/
-
-
- SELECT available AS minimo FROM tmp.item
- WHERE item_id = id_single;
--- ixen totes les linies en lloc d'una sola
- DROP TEMPORARY TABLE IF EXISTS tmp.item;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/base_ticket.sql b/db/routines/vn2008/procedures/base_ticket.sql
deleted file mode 100644
index 2352eabaf..000000000
--- a/db/routines/vn2008/procedures/base_ticket.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`base_ticket`(IN Id_Ticket INT)
-BEGIN
- SELECT
- red(SUM(Cantidad * Preu * (100 - Descuento) / 100)) AS base
- FROm
- Movimientos m
- INNER JOIN Tickets t USING (Id_Ticket)
- WHERE t.Id_Ticket = Id_Ticket;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/bionic_available_types_filter.sql b/db/routines/vn2008/procedures/bionic_available_types_filter.sql
deleted file mode 100644
index 308c6396e..000000000
--- a/db/routines/vn2008/procedures/bionic_available_types_filter.sql
+++ /dev/null
@@ -1,38 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`bionic_available_types_filter`(
- v_date DATE,
- v_consigna INT,
- v_agencia INT)
-BEGIN
-/**
- * Este procedimiento devuelve una tabla t_bionic_available_types
- * que debe de ser borrar por quien la llame, y se conecta con la tabla articlelist
- * que tambien hay que eliminar.
- *
- * @param vDatefecha de recepcion de mercancia
- * @table t_bionic_available_types
- */
-
- CALL vn.catalog_Calculate(v_date, v_consigna, v_agencia);
-
- -- Introducimos los valores en una tabla temporal
- DROP TEMPORARY TABLE IF EXISTS t_bionic_available_types;
-
- CALL check_table_existence('articlelist');
-
- IF @table_exists THEN
- call util.throw('No usar articlelist');
- END IF;
-
- CREATE TEMPORARY TABLE t_bionic_available_types
- SELECT a.tipo_id, t.Tipo, r.reino, count(*) as item_count
- FROM tmp.ticketCalculateItem tci
- JOIN vn2008.Articles a ON tci.itemFk = a.Id_Article
- JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id
- JOIN vn2008.reinos r ON r.id = t.reino_id
- WHERE tci.available > 0
- GROUP BY a.tipo_id;
-
- DROP TEMPORARY TABLE tmp.ticketCalculateItem;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/buy_label.sql b/db/routines/vn2008/procedures/buy_label.sql
deleted file mode 100644
index 0ee1be5a4..000000000
--- a/db/routines/vn2008/procedures/buy_label.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_label`(IN entry_id_ INT, IN groupby TINYINT(1))
-BEGIN
-
- DECLARE done INT DEFAULT 0;
- DECLARE label INT;
- DECLARE id INT;
- DECLARE recordset CURSOR FOR SELECT Compres.Etiquetas, Compres.Id_Compra FROM Compres INNER JOIN
- (SELECT e.Id_entrada FROM Entradas e INNER JOIN (
- SELECT Id_Entrada,Inventario,Id_proveedor,travel_id,Id_Agencia FROM Entradas e1 INNER JOIN travel t ON e1.travel_id = t.id WHERE Id_Entrada = entry_id_) y
- ON y.Inventario = e.Inventario AND e.travel_id = y.travel_id AND e.Id_proveedor = y.Id_proveedor AND y.Id_Agencia = e.Id_Agencia
- WHERE (0 OR e.Id_Entrada = entry_id_)) entry_label
- ON Compres.Id_Entrada = entry_label.Id_entrada
- INNER JOIN Articles ON Compres.Id_Article = Articles.Id_Article WHERE Articles.Imprimir <> FALSE;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
- DROP TEMPORARY TABLE IF EXISTS `buy_label_source`;
-
- CREATE TEMPORARY TABLE `buy_label_source`
- (
- `buy_id` INT(11) NOT NULL
- )
-
- ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
- OPEN recordset;
-
- REPEAT
-
- FETCH recordset INTO label, id;
- WHILE label > 0 DO
-
- SET label = label - 1;
- INSERT INTO buy_label_source (buy_id) VALUES (id);
-
- END WHILE;
-
- UNTIL done END REPEAT;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/buy_split.sql b/db/routines/vn2008/procedures/buy_split.sql
deleted file mode 100644
index 188bd89ec..000000000
--- a/db/routines/vn2008/procedures/buy_split.sql
+++ /dev/null
@@ -1,150 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_split`(IN `v_buy` INT, IN `v_entry` INT)
-BEGIN
-
- -- DEPRECATED use vn.buySplit
-
- DECLARE v_item INT;
- DECLARE v_packing INT;
- DECLARE v_remaining INT;
- DECLARE v_labels INT;
- DECLARE v_remainder INT;
- DECLARE v_is_buy INT;
- DECLARE v_id INT;
- DECLARE v_amount INT;
- DECLARE v_done BOOL DEFAULT FALSE;
- DECLARE vNameCharMax INT DEFAULT 16;
-
- DECLARE cur CURSOR FOR
- SELECT TRUE, c.Id_Compra, c.Cantidad - IFNULL((c.Vida * c.Packing), 0)
- FROM Compres c
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- WHERE c.Id_Article = v_item
- AND DATE(t.shipment) = util.VN_CURDATE() AND t.warehouse_id_out IN (7, 40)
- AND t.warehouse_id NOT IN (60)
- AND NOT e.redada AND NOT e.Inventario
- AND IFNULL(c.Vida, 0) < c.Etiquetas
- UNION ALL
- SELECT FALSE, m.Id_Movimiento, m.Cantidad - IFNULL(l.stem, 0)
- FROM Movimientos m
- JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket
- LEFT JOIN movement_label l ON l.Id_Movimiento = m.Id_Movimiento
- WHERE m.Id_Article = v_item
- AND t.Fecha >= util.VN_CURDATE() AND t.warehouse_id IN (7, 40)
- AND NOT t.Etiquetasemitidas
- AND IFNULL(l.stem, 0) < m.Cantidad
- LOCK IN SHARE MODE;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET v_done = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- -- Obtiene los datos de la compra
-
- SELECT Id_Article, Packing, Cantidad
- INTO v_item, v_packing, v_remaining
- FROM Compres WHERE Id_Compra = v_buy;
-
- -- Crea splits de los tickets
-
- DROP TEMPORARY TABLE IF EXISTS tmp.split;
- CREATE TEMPORARY TABLE tmp.split
- (
- is_buy BOOL,
- id INT,
- labels INT,
- remainder INT
- )
- ENGINE = MEMORY;
-
- OPEN cur;
-
- l: LOOP
- SET v_done = FALSE;
- FETCH cur INTO v_is_buy, v_id, v_amount;
-
- IF v_done OR v_remaining = 0 THEN
- LEAVE l;
- END IF;
-
- SET v_amount = LEAST(v_amount, v_remaining);
- SET v_remaining = v_remaining - v_amount;
- SET v_labels = v_amount DIV v_packing;
-
- INSERT INTO tmp.split
- VALUES (v_is_buy, v_id, v_labels, v_amount % v_packing);
-
- IF v_is_buy
- THEN
- UPDATE Compres
- SET Vida = Vida + v_labels
- WHERE Id_Compra = v_id;
- ELSE
- INSERT INTO movement_label
- SET
- Id_Movimiento = v_id,
- stem = v_amount,
- label = v_labels
- ON DUPLICATE KEY UPDATE
- stem = stem + VALUES(stem),
- label = label + VALUES(label);
- END IF;
- END LOOP;
-
- CLOSE cur;
-
- -- Crea los movimientos de almacén a silla
-
- CALL buy_transfer (v_buy, v_entry);
-
- UPDATE Compres SET dispatched = Vida * Packing
- WHERE Id_Compra = v_buy;
-
- -- Devuelve los splits creados
-
- DROP TEMPORARY TABLE IF EXISTS tmp.aux;
- CREATE TEMPORARY TABLE tmp.aux
- ENGINE = MEMORY
- SELECT s.labels, s.remainder, w.`name` destination,
- a.Id_Article, a.Article, a.Medida, ' ' counter, ' ' destination2
- FROM tmp.split s
- JOIN Compres c ON c.Id_Compra = s.id
- JOIN Articles a ON a.Id_Article = c.Id_Article
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- JOIN warehouse w ON t.warehouse_id = w.id
- WHERE s.is_buy;
-
- INSERT INTO tmp.aux
- SELECT s.labels, s.remainder, IF(p.`name` IN ('BARCELONA','TARRAGONA','GIRONA','LLEIDA','LÉRIDA') AND t.Id_Cliente != 93, '<< VILASSAR >>',o.Consignatario),
- a.Id_Article, a.Article, a.Medida,
- vn.ticketSplitCounter(t.Id_Ticket), IF(p.`name` IN ('BARCELONA','TARRAGONA','GIRONA','LLEIDA','LÉRIDA') AND t.Id_Cliente != 93, o.Consignatario,CONCAT(o.id_consigna, ' ', p.`name`,' (', c.`code`,')'))
- /*UCASE(CONCAT(p.`name`,' (', c.`code`, ')'))*/
- FROM tmp.split s
- JOIN Movimientos m ON m.Id_Movimiento = s.id
- JOIN Articles a ON a.Id_Article = m.Id_Article
- JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket
- JOIN Consignatarios o ON o.Id_Consigna = t.Id_Consigna
- JOIN vn.province p ON p.id = o.province_id
- JOIN vn.country c ON c.id = p.countryFk
- WHERE NOT s.is_buy;
-
- SELECT * FROM tmp.aux;
-
- -- Limpia y confirma cambios
-
- DROP TEMPORARY TABLE
- tmp.split,
- tmp.aux;
-
- COMMIT;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/buy_tarifas_recalcular_almacen.sql b/db/routines/vn2008/procedures/buy_tarifas_recalcular_almacen.sql
deleted file mode 100644
index d2248505d..000000000
--- a/db/routines/vn2008/procedures/buy_tarifas_recalcular_almacen.sql
+++ /dev/null
@@ -1,36 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_tarifas_recalcular_almacen`(IN wh_id INT, IN datFEC DATE)
-BEGIN
-
-DECLARE done INT DEFAULT 0;
-DECLARE idE INT;
-
-DECLARE cur1 CURSOR FOR
-SELECT Id_Entrada
-FROM Entradas
-JOIN travel ON travel.id = travel_id
-WHERE landing >= datFEC AND wh_id IN (0,warehouse_id);
-
-DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
-
-OPEN cur1;
-
-REPEAT
-
- FETCH cur1 INTO idE;
-
- IF NOT done THEN
-
- Call buy_tarifas_entry(idE);
-
-
-
- END IF;
-
-
-UNTIL done END REPEAT;
-
- CLOSE cur1;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/buy_transfer.sql b/db/routines/vn2008/procedures/buy_transfer.sql
deleted file mode 100644
index 935a570bd..000000000
--- a/db/routines/vn2008/procedures/buy_transfer.sql
+++ /dev/null
@@ -1,104 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`buy_transfer`(IN `v_buy` INT, IN `entryFk` INT)
-proc: BEGIN
-/**
- * Traslada la cantidad restante de una compra de Holanda
- * al almacén de Silla.
- */
- DECLARE v_wh INT;
- DECLARE v_fv INT;
- DECLARE v_amount INT;
- DECLARE v_item INT;
- DECLARE v_holland_wh INT DEFAULT 7;
- DECLARE vIsIgnored BOOL DEFAULT FALSE;
- DECLARE vDestinationWarehouse INT;
-
- -- Comprueba que es mercancía que llega al almacén de Holanda
-
- SELECT t.warehouse_id, IF(tp.warehouseFk=1,1,0), tp.warehouseFk, c.Id_Article, c.Novincular
- INTO v_wh, v_fv, vDestinationWarehouse, v_item, vIsIgnored
- FROM Compres c
- JOIN Entradas e ON c.Id_Entrada = e.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- JOIN Articles a ON a.Id_Article = c.Id_Article
- JOIN Tipos tp ON tp.tipo_id = a.tipo_id
- WHERE c.Id_Compra = v_buy;
-
- IF v_wh != v_holland_wh THEN
- LEAVE proc;
- END IF;
-
- IF entryFk IS NULL THEN
- LEAVE proc;
- END IF;
-
- -- Calcula la cantidad a trasladar
-
- SELECT IFNULL(SUM(amount), 0) INTO v_amount
- FROM (
- SELECT SUM(c.Cantidad) amount
- FROM Compres c
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- WHERE c.Id_Article = v_item
- AND t.landing = util.VN_CURDATE()
- AND t.warehouse_id = v_holland_wh
- UNION ALL
- SELECT -SUM(c.Cantidad)
- FROM Compres c
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- WHERE c.Id_Article = v_item
- AND t.shipment = util.VN_CURDATE()
- AND t.warehouse_id_out = v_holland_wh
- UNION ALL
- SELECT -SUM(Cantidad)
- FROM Movimientos m
- JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket
- WHERE m.Id_Article = v_item
- AND t.Fecha = util.VN_CURDATE()
- AND t.warehouse_id = v_holland_wh
- ) t;
-
- IF v_amount <= 0 THEN
- LEAVE proc;
- END IF;
-
- -- Si la linea tiene no vincular hay que buscar la anterior válida
- IF vIsIgnored THEN
- CALL buyUltimate(vDestinationWarehouse, util.VN_CURDATE());
- SELECT buyFk INTO v_buy
- FROM tmp.buyUltimate
- LIMIT 1;
- DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
- END IF;
-
- -- Crea la nueva línea de compra con el translado
-
- INSERT INTO Compres (
- Id_Article, Etiquetas, Cantidad, Id_Entrada,
- Id_Cubo, Packing, `grouping`, caja, Costefijo, Portefijo,
- Embalajefijo, Comisionfija, buy_edi_id)
- SELECT c.Id_Article,
- v_amount DIV c.Packing,
- v_amount,
- entryFk,
- c.Id_Cubo,
- c.Packing,
- c.`grouping`,
- c.caja,
- @cost := IFNULL(c.Costefijo, 0) + IFNULL(c.Comisionfija, 0) + IFNULL(c.Portefijo, 0),
- @porte := ROUND((@cm3:= vn.item_getVolume(c.Id_Article, c.Id_Cubo)) * a.m3 / 1000000 / c.Packing, 3),
- c.EmbalajeFijo,
- @comision := ROUND(c.Costefijo * e.comision / 100, 3),
- c.buy_edi_id
- FROM Compres c
- JOIN Cubos cu ON cu.Id_Cubo = c.Id_Cubo
- JOIN Entradas e ON e.Id_Entrada = entryFk
- JOIN travel t ON t.id = e.travel_id
- JOIN Agencias a ON t.agency_id = a.Id_Agencia
- WHERE c.Id_Compra = v_buy;
-
- CALL buy_tarifas (LAST_INSERT_ID());
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/check_table_existence.sql b/db/routines/vn2008/procedures/check_table_existence.sql
deleted file mode 100644
index 081912d3b..000000000
--- a/db/routines/vn2008/procedures/check_table_existence.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`check_table_existence`(IN table_name CHAR(64))
-BEGIN
- DECLARE CONTINUE HANDLER FOR SQLSTATE '42S02' SET @err = 1;
- SET @err = 0;
- SET @table_name = table_name;
- SET @sqlString = CONCAT('SELECT NULL FROM ',@table_name);
- PREPARE stmt1 FROM @sqlString;
- IF (@err = 1) THEN
- SET @table_exists = 0;
- ELSE
- SET @table_exists = 1;
- DEALLOCATE PREPARE stmt1;
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql
index e2f3c9544..c2d2e34a0 100644
--- a/db/routines/vn2008/procedures/clean.sql
+++ b/db/routines/vn2008/procedures/clean.sql
@@ -77,13 +77,23 @@ proc: BEGIN
DELETE FROM scan WHERE odbc_date < vDate6 AND id <> 1;
IF v_full THEN
+ CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
+ SELECT DISTINCT tl.originFk ticketFk
+ FROM vn.ticketLog tl
+ JOIN (SELECT MAX(tl.id)ids
+ FROM vn.ticket t
+ JOIN vn.ticketLog tl ON tl.originFk = t.id
+ WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
+ AND t.isDeleted
+ GROUP BY t.id
+ )sub ON sub.ids = tl.id
+ WHERE tl.creationDate <= util.VN_CURDATE() - INTERVAL 60 DAY;
+
DELETE t
- FROM Tickets t
- LEFT JOIN Tickets_turno tt ON tt.Id_Ticket = t.Id_Ticket
- WHERE Fecha NOT IN ('2000-01-01','2000-01-02')
- AND YEAR(Fecha) = 2000
- AND ABS(DATEDIFF(Fecha,vDate2000)) > vRangeDeleteTicket
- AND tt.Id_Ticket IS NULL;
+ FROM vn.ticket t
+ JOIN tTicketDelete tmp ON tmp.ticketFk = t.id;
+
+ DROP TEMPORARY TABLE tTicketDelete;
END IF;
-- Tickets Nulos PAK 11/10/2016
diff --git a/db/routines/vn2008/procedures/comercial_caducado.sql b/db/routines/vn2008/procedures/comercial_caducado.sql
deleted file mode 100644
index 47b0d6249..000000000
--- a/db/routines/vn2008/procedures/comercial_caducado.sql
+++ /dev/null
@@ -1,57 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`comercial_caducado`()
-BEGIN
-
--- Este procedimiento le pasa los clientes al jefe de ventas cuando llevan dos meses inactivos
-
-IF day(util.VN_CURDATE()) = 5 then -- solo se ejecuta los dias 5 de cada mes
-
- Update Clientes
- join
- (
- Select c.Id_Cliente
- from Clientes c
- join jerarquia j on j.worker_id = c.Id_Trabajador -- este filtro es para que solo toque los de los comerciales
-
- join
- (
- select Id_Cliente, sum(Importe) as Saldo
- from
- (
- select Id_Cliente, Importe from Facturas
- union all
- select Id_Cliente, - Entregado from Recibos
- ) sub
- group by Id_Cliente
- ) sindeuda on sindeuda.Id_Cliente = c.Id_Cliente
-
- left join
- (
- select distinct Id_Cliente
- from Facturas
- where Fecha BETWEEN util.VN_CURDATE() - INTERVAL 12 MONTH AND util.VN_CURDATE()
- ) f on f.Id_Cliente = c.Id_Cliente
-
- left join
- (
- select distinct Id_Cliente
- from Tickets
- where Fecha between util.VN_CURDATE() - INTERVAL 2 DAY AND util.VN_CURDATE() + INTERVAL 200 DAY
-
- ) tic_vivos on tic_vivos.Id_Cliente = c.Id_Cliente
-
- where c.Created < util.VN_CURDATE() - INTERVAL 2 MONTH -- este filtro respeta a los recien nacidos....
- and j.boss_id = 87 -- sólo afecta a los comerciales de Alfredo
- and f.Id_Cliente is null -- comprueba que no tenga facturas en los dos ultimos meses
- and sindeuda.Saldo < 10 -- sólo cambia a los clientes con deuda escasa o nula
- and tic_vivos.Id_Cliente is null -- si tiene tickets vivos, lo respeta
-
-
- ) sub using(Id_Cliente)
-
- set Id_Trabajador = 87 ;-- Alfredo Giner;
-
-end if;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/compresTriggerBeforeInsert.sql b/db/routines/vn2008/procedures/compresTriggerBeforeInsert.sql
deleted file mode 100644
index 107bb59af..000000000
--- a/db/routines/vn2008/procedures/compresTriggerBeforeInsert.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`compresTriggerBeforeInsert`(newNoVincular INT, newEntrada INT, newCompra INT, newItem INT)
-BEGIN
- DECLARE newWarehouse INTEGER;
-
- IF newNoVincular = FALSE THEN
-
- UPDATE travel t
- JOIN vn.lastBuy lb ON newItem = lb.item AND t.warehouse_id = lb.warehouse
- JOIN Entradas e ON e.travel_id = t.id
- SET lb.id = newCompra
- WHERE e.Id_Entrada = newEntrada AND t.landing > lb.landing AND t.landing <= util.VN_CURDATE();
-
- END IF;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/compresTriggerBeforeUpdate.sql b/db/routines/vn2008/procedures/compresTriggerBeforeUpdate.sql
deleted file mode 100644
index e420dc0ab..000000000
--- a/db/routines/vn2008/procedures/compresTriggerBeforeUpdate.sql
+++ /dev/null
@@ -1,36 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`compresTriggerBeforeUpdate`(vOldEntrada INT, vNewEntrada INT, oldItem INT,
- newItem INT, newNoVincular BOOLEAN, newCompra INT)
-BEGIN
- DECLARE newWarehouse INTEGER;
- DECLARE hasToRecalculate BOOLEAN;
-
- IF newNoVincular = FALSE THEN
- IF oldItem <> newItem OR vOldEntrada <> vNewEntrada THEN
- SELECT Id_Compra INTO hasToRecalculate FROM travel t
- JOIN Entradas e ON e.travel_id = t.id
- JOIN vn.lastBuy lb ON lb.id = newCompra
- WHERE e.Id_Entrada = vOldEntrada LIMIT 1;
-
- IF hasToRecalculate THEN
- SELECT warehouse_id INTO newWarehouse FROM travel t
- JOIN Entradas e ON t.id = e.travel_id
- WHERE e.Id_Entrada = vOldEntrada;
- CALL vn.lastBuyRefresh(newWarehouse);
- END IF;
- END IF;
- IF vOldEntrada <> vNewEntrada THEN
-
- UPDATE Entradas oldEntrada
- JOIN travel oldTravel ON oldEntrada.travel_id = oldtravel.id
- JOIN Entradas newEntrada ON newEntrada.Id_Entrada = vNewEntrada
- JOIN travel newTravel ON newTravel.id = newEntrada.travel_id
- JOIN vn.lastBuy lb ON newItem = lb.item AND newTravel.warehouse_id = lb.warehouse
- SET lb.id = newCompra
- WHERE oldEntrada.Id_Entrada = vOldEntrada AND oldTravel.warehouse_id <> newTravel.warehouse_id
- AND newTravel.landing > lb.landing AND newTravel.landing <= util.VN_CURDATE();
- END IF;
- END IF;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/createBouquet.sql b/db/routines/vn2008/procedures/createBouquet.sql
deleted file mode 100644
index 2796ce9aa..000000000
--- a/db/routines/vn2008/procedures/createBouquet.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`createBouquet`(
- vName VARCHAR(50),
- vType int,
- vSize int,
- vColour VARCHAR(5),
- OUT vItem INT(11)
-)
-BEGIN
-
- DECLARE vTaxClass VARCHAR(1);
- DECLARE vIntrastatFk INT(11);
-
- -- COMPROBAMOS SI EXISTE UN ARTÍCULO IGUAL.
- SELECT Id_Article INTO vItem
- FROM Articles
- WHERE (Id_Article BETWEEN 161000 AND 169000)
- AND Article LIKE CONCAT('%', vName)
- AND tipo_id = vType
- AND Medida = vSize
- AND Color = vColour
- LIMIT 1;
-
- -- SI NO EXISTE CREAMOS UNO NUEVO
- IF vItem IS NULL THEN
-
- -- OBTENER EL ID ENTRE 161000 Y 169000 DEL SIGUIENTE ARTÍCULO
- SELECT (IF(MAX(Id_Article) IS NULL, 161000, (MAX(Id_Article) + 1))) INTO vItem FROM Articles WHERE Id_Article BETWEEN 161000 AND 169000;
-
- -- INSERTAR EL ARTÍCULO
- INSERT INTO vn.item (id, `name`, typeFk, size, inkFk, originFk, intrastatFk)
- VALUES (
- vItem,
- vName,
- vType,
- vSize,
- vColour,
- 1,
- 06031970
- );
-
- SELECT id INTO vTaxClass FROM vn.taxClass WHERE `code` = 'G';
- SELECT id INTO vIntrastatFk FROM vn.intrastat
- WHERE description LIKE 'Flores,follaje y frutos artificiales: otras%';
-
- UPDATE vn.itemTaxCountry SET taxClassFk = vTaxClass WHERE itemFk = LAST_INSERT_ID();
- END IF;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/credit_update.sql b/db/routines/vn2008/procedures/credit_update.sql
deleted file mode 100644
index e29fa5ada..000000000
--- a/db/routines/vn2008/procedures/credit_update.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`credit_update`()
-BEGIN
-
-DECLARE dblDiferencia DOUBLE DEFAULT 10.0;
-DECLARE dblImporteRec,auxdblImporteRec DOUBLE DEFAULT 0.0;
-DECLARE dblImporteFac,auxdblImporteFac DOUBLE DEFAULT 0.0;
-DECLARE intIdRecibo,auxintIdRecibo INT (11) DEFAULT 0;
-DECLARE intId_Cliente,auxintId_Cliente,intId_ClienteRec,auxintId_ClienteRec INT DEFAULT 0;
-DECLARE bitFin,bitFinRecord,bitFinRecord1 BIT DEFAULT 0;
-DECLARE datFechaVencimiento DATE DEFAULT util.VN_CURDATE();
-DECLARE intEmpresa_id INT DEFAULT 0;
-
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/entryFromOrder.sql b/db/routines/vn2008/procedures/entryFromOrder.sql
deleted file mode 100644
index e340177af..000000000
--- a/db/routines/vn2008/procedures/entryFromOrder.sql
+++ /dev/null
@@ -1,55 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`entryFromOrder`(IN vShipmentWarehouse INTEGER, IN vLandingWarehouse INTEGER, IN vItem INTEGER,
- IN vAmount INTEGER,IN vVolume INTEGER,vCost DECIMAL(10,2), IN vRetailedPrice DECIMAL(10,2), vInOutDate DATE)
-BEGIN
-
- DECLARE vTravel INT;
- DECLARE vEntry INT;
- DECLARE vBucket VARCHAR(10);
-
- -- seleccionamos travel
- SELECT id, Id_Entrada INTO vTravel, vEntry
- FROM travel t LEFT JOIN Entradas e ON t.id = e.travel_id
- WHERE t.landing = vInOutDate AND t.shipment = vInOutDate AND t.warehouse_id_out = vShipmentWarehouse
- AND t.warehouse_id = vLandingWarehouse AND agency_id = 15
- LIMIT 1;
-
- -- creamos el travel si es necesario
- IF NOT IFNULL(vTravel,0) THEN
- INSERT INTO travel (shipment, landing, warehouse_id, warehouse_id_out, agency_id)
- VALUES (vInOutDate, vInOutDate, vLandingWarehouse, vShipmentWarehouse, 15);
- SELECT LAST_INSERT_ID() INTO vTravel;
- END IF;
- -- creamos la Entrada si es necesario
- IF NOT IFNULL(vEntry,0) THEN
- INSERT INTO Entradas (Id_Proveedor, travel_id)
- VALUES (13, vTravel); -- proveedor 'MOVIMIENTO ALMACEN'
- SELECT LAST_INSERT_ID() INTO vEntry;
- END IF;
-
- -- creamos el cubo si es necesario
- SELECT Id_Cubo INTO vBucket FROM Cubos WHERE Volumen = vVolume LIMIT 1;
-
- IF NOT IFNULL(vBucket,'') > '' THEN
- INSERT INTO Cubos (Id_Cubo, Volumen)
- VALUES (CONCAT('dm',vVolume/1000), vVolume);
- SELECT LAST_INSERT_ID() INTO vBucket;
- END IF;
-
- INSERT INTO Compres(Id_Article,Cantidad, Id_Entrada, Id_Cubo, Packing, `grouping`, caja, Costefijo, Portefijo, Embalajefijo,
- Comisionfija, Tarifa2, Tarifa3)
- VALUES(vItem,
- vAmount,
- vEntry,
- vBucket,
- 1,
- 1,
- 0,
- vCost,
- 0,
- 0,
- 0,
- vRetailedPrice,
- vRetailedPrice);
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/entryFromTicket.sql b/db/routines/vn2008/procedures/entryFromTicket.sql
deleted file mode 100644
index f580959d7..000000000
--- a/db/routines/vn2008/procedures/entryFromTicket.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`entryFromTicket`(IN vTicket INTEGER, IN vLandingWarehouse INTEGER)
-BEGIN
-
- DECLARE vShipmentWarehouse INT;
- DECLARE vLandingDate DATE;
- DECLARE vShipmentDate DATE;
- DECLARE vTravel INT;
- DECLARE vEntry INT;
-
- SELECT warehouse_id, Fecha, Fecha INTO vShipmentWarehouse, vShipmentDate, vLandingDate
- FROM Tickets
- WHERE Id_Ticket = vTicket;
-
- -- seleccionamos travel
- SELECT id, Id_Entrada INTO vTravel, vEntry
- FROM travel t LEFT JOIN Entradas e ON t.id = e.travel_id
- WHERE t.landing = vLandingDate
- AND t.shipment = vShipmentDate
- AND t.warehouse_id_out = vShipmentWarehouse
- AND t.warehouse_id = vLandingWarehouse
- AND agency_id = 15
- LIMIT 1;
-
- -- creamos el travel si es necesario
- IF vTravel IS NULL THEN
- SELECT vLandingDate;
- INSERT INTO travel (shipment, landing, warehouse_id, warehouse_id_out, agency_id)
- VALUES (vShipmentDate, vLandingDate, vLandingWarehouse, vShipmentWarehouse, 15);
- SELECT LAST_INSERT_ID() INTO vTravel;
- END IF;
-
- -- creamos la Entrada si es necesario
- IF vEntry IS NULL THEN
- INSERT INTO Entradas (Id_Proveedor, travel_id)
- VALUES (13, vTravel); -- proveedor 'MOVIMIENTO ALMACEN'
- SELECT LAST_INSERT_ID() INTO vEntry;
- END IF;
-
- CALL vn.buyUltimate(vShipmentWarehouse,vShipmentDate);
-
- INSERT INTO Compres(Id_Article,Cantidad, Id_Entrada, Id_Cubo, Packing, `grouping`, caja, Costefijo, Portefijo, Embalajefijo, Comisionfija, Tarifa2, Tarifa3)
- SELECT m.Id_Article,
- m.Cantidad,
- vEntry,
- c.Id_Cubo,
- c.Packing,
- IF(c.`grouping`,c.`grouping`,1),
- c.caja,
- Costefijo,
- c.Portefijo,
- c.Embalajefijo,
- c.Comisionfija,
- m.Preu Tarifa2,
- m.Preu Tarifa3
- FROM Movimientos m
- JOIN Articles a ON m.Id_Article = a.Id_Article
- LEFT JOIN tmp.buyUltimate b ON m.Id_Article = b.itemFk AND b.warehouseFk = vShipmentWarehouse
- LEFT JOIN Compres c ON c.Id_Compra = b.buyFk
- WHERE m.Id_Ticket = vTicket;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/eti_to_print.sql b/db/routines/vn2008/procedures/eti_to_print.sql
deleted file mode 100644
index 4185d6a0a..000000000
--- a/db/routines/vn2008/procedures/eti_to_print.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`eti_to_print`(IN idENTRADA INT, IN idPRODUCER INT)
-BEGIN
-
-select Vida as Impresas
- ,Etiquetas as bultos
- ,Packing
- ,Id_Article
- ,CONCAT(Article,' ',Medida,' ', Categoria) as Articat
- ,p.name as marca
- ,Proveedor
- ,Id_Entrada
- ,Id_Compra
-from Compres c
-join Entradas e using(Id_Entrada)
-join Proveedores using(Id_Proveedor)
-join travel tr on tr.id = e.travel_id
-join Articles a using(Id_Article)
-left join producer p using(producer_id)
-where Id_Entrada = idENTRADA
- and idPRODUCER in (0,a.producer_id) ;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/f10_no_vincular.sql b/db/routines/vn2008/procedures/f10_no_vincular.sql
deleted file mode 100644
index 4ec93f68e..000000000
--- a/db/routines/vn2008/procedures/f10_no_vincular.sql
+++ /dev/null
@@ -1,60 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`f10_no_vincular`(lngEntrada INTEGER)
-BEGIN
- DECLARE datFecha DATE DEFAULT util.VN_CURDATE();
-
--- Modifica el NoVincular si hay dos entradas con el mismo Packing y el mismo Id_Articulo
- DROP TEMPORARY TABLE IF EXISTS f10_no_vincular_;
- CREATE TEMPORARY TABLE IF NOT EXISTS f10_no_vincular_
- SELECT c.Id_Entrada,c.Id_Compra,c.Id_Article, c.Novincular, c.Packing, be.pri
- FROM Compres c
- JOIN buy_edi be ON c.buy_edi_id = be.id AND be.fec = datFecha
- LEFT JOIN Entradas_kop ek ON ek.Id_Entrada = c.Id_Entrada
- WHERE
- ((ek.Id_Entrada IS NOT NULL AND ek.sub IS NULL)
- OR (c.Id_Entrada = 9200 AND be.ok <> FALSE)
- OR c.Id_Entrada = lngEntrada) AND Id_Article <> 90;
-
- -- Modifica el NoVincular si hay dos entradas con el mismo Packing y el mismo Id_Articulo
- DROP TEMPORARY TABLE IF EXISTS f10_mismo_Packing;
- CREATE TEMPORARY TABLE IF NOT EXISTS f10_mismo_Packing
- SELECT * FROM (
- SELECT * FROM f10_no_vincular_
- ORDER BY pri DESC
- LIMIT 10000000000000000000) t
- GROUP BY Id_Article,Packing
- HAVING count(Id_Compra) > 1 AND BIT_OR(Id_Entrada = 9200);
-
- UPDATE Compres c
- JOIN buy_edi be ON c.buy_edi_id = be.id AND be.fec = datFecha
- JOIN f10_mismo_Packing f ON f.Id_Article = c.Id_Article AND c.Packing = f.Packing
- LEFT JOIN Entradas_kop ek ON ek.Id_Entrada = f.Id_Entrada
- SET c.Novincular = IF(c.Id_Compra = f.Id_Compra,0,1)
- WHERE
- ((ek.Id_Entrada IS NOT NULL AND ek.sub IS NULL)
- OR (c.Id_Entrada = 9200 AND be.ok <> FALSE)
- OR c.Id_Entrada = lngEntrada);
-
--- Modifica el Id_Articulo si hay dos entradas con packing y el mismo Id_Articulo
- DROP TEMPORARY TABLE IF EXISTS f10_mismo_Articulo;
- CREATE TEMPORARY TABLE IF NOT EXISTS f10_mismo_Articulo
- SELECT Id_Article FROM (
- SELECT * FROM (
- SELECT * FROM f10_no_vincular_
- ORDER BY Id_Entrada = 9200 DESC
- LIMIT 10000000000000000000) t
- GROUP BY Id_Article,Packing ) t
- GROUP BY Id_Article HAVING COUNT(*) > 1 AND BIT_OR(Id_Entrada = 9200);
- SELECT 4;
- UPDATE Compres c
- JOIN buy_edi be ON c.buy_edi_id = be.id AND be.fec = datFecha
- JOIN f10_mismo_Articulo f ON f.Id_Article = c.Id_Article
- LEFT JOIN Entradas_kop ek ON ek.Id_Entrada = c.Id_Entrada
- SET c.Id_Article = 90
- WHERE c.Id_Entrada = 9200 AND be.ok <> FALSE;
-
- DROP TEMPORARY TABLE IF EXISTS f10_no_vincular_;
- DROP TEMPORARY TABLE IF EXISTS f10_mismo_Packing;
- DROP TEMPORARY TABLE IF EXISTS f10_mismo_Articulo;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/historico_joined.sql b/db/routines/vn2008/procedures/historico_joined.sql
deleted file mode 100644
index 730562de1..000000000
--- a/db/routines/vn2008/procedures/historico_joined.sql
+++ /dev/null
@@ -1,88 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_joined`(IN idART INT, IN wh_joined INT, IN v_virtual INT)
-BEGIN
- DECLARE datFEC DATETIME;
-
- SELECT Fechainventario INTO datFEC FROM tblContadores;
- SET @a = 0;
- SELECT DATE(Fecha) Fecha,
- Entrada,
- Salida,
- OK,
- Alias,
- Referencia,
- id,
- @a := @a + IFNULL(Entrada,0) - IFNULL(Salida,0) acumulado,
- F5,
- v_virtual,
- CodigoTrabajador
- FROM
- ( SELECT TR.landing Fecha,
- C.Cantidad Entrada,
- NULL Salida,
- (TR.received != FALSE) OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5,
- tra.CodigoTrabajador
- FROM Compres C
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel TR ON TR.id = E.travel_id
- JOIN Proveedores P USING (Id_Proveedor)
- LEFT JOIN Articles a ON a.Id_Article = C.Id_Article
- LEFT JOIN Tipos ti ON ti.Id_Tipo = a.tipo_id
- LEFT JOIN Trabajadores tra ON tra.Id_Trabajador = ti.Id_Trabajador
- LEFT JOIN warehouse_joined wj ON wj.warehouse_id = TR.warehouse_id
- WHERE TR.landing >= datFEC
- AND wh_joined IN (wj.warehouse_alias_id , 0)
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT TR.shipment Fecha,
- NULL Entrada,
- C.Cantidad Salida,
- TR.delivered OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5,
- tra.CodigoTrabajador
- FROM Compres C
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel TR ON TR.id = E.travel_id
- JOIN Proveedores P USING (Id_Proveedor)
- LEFT JOIN Articles a ON a.Id_Article = C.Id_Article
- LEFT JOIN Tipos ti ON ti.Id_Tipo = a.tipo_id
- LEFT JOIN Trabajadores tra ON tra.Id_Trabajador = ti.Id_Trabajador
- LEFT JOIN warehouse_joined wj ON wj.warehouse_id = TR.warehouse_id_out
- WHERE TR.shipment >= datFEC
- AND wh_joined IN (wj.warehouse_alias_id,0)
- AND Id_Proveedor <> 4
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT T.Fecha Fecha,
- NULL Entrada,
- M.Cantidad Salida,
- (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
- T.Alias Alias,
- T.Localizacion Referencia,
- T.Id_Ticket id,
- T.PedidoImpreso EtiquetasEmitidas,
- tr.CodigoTrabajador
- FROM Movimientos M
- JOIN Tickets T USING (Id_Ticket)
- JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
- LEFT JOIN Trabajadores tr ON tr.Id_Trabajador = C.Id_Trabajador
- LEFT JOIN warehouse_joined wj ON wj.warehouse_id = T.warehouse_id
- WHERE T.Fecha >= datFEC
- AND M.Id_Article = idART
- AND wh_joined IN (wj.warehouse_alias_id , 0)
- ) AS Historico
- ORDER BY Fecha, Entrada DESC, OK DESC;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/inventario_valorado.sql b/db/routines/vn2008/procedures/inventario_valorado.sql
deleted file mode 100644
index e8e5eeed0..000000000
--- a/db/routines/vn2008/procedures/inventario_valorado.sql
+++ /dev/null
@@ -1,185 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`inventario_valorado`(IN vDated DATE, IN vIsDetailed BOOLEAN)
-BEGIN
-
-/**
- * DEPRECATED usar item_ValuateInventory
- */
- DECLARE vInventoried DATE;
- DECLARE vHasNotInventory BOOLEAN DEFAULT 0;
- DECLARE vInventoried2 DATE;
- DECLARE vDateDayEnd DATETIME;
-
- SET vDateDayEnd = util.dayEnd(vDated);
- SELECT landing INTO vInventoried
- FROM travel tr
- JOIN Entradas E ON E.travel_id = tr.id
- WHERE landing <= vDateDayEnd
- AND E.Id_Proveedor = 4
- ORDER BY landing DESC
- LIMIT 1;
-
- SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE);
-
- IF vHasNotInventory THEN
-
- SELECT landing INTO vInventoried2
- FROM travel tr
- JOIN Entradas E ON E.travel_id = tr.id
- WHERE landing >= vDated
- AND E.Id_Proveedor = 4
- ORDER BY landing ASC
- LIMIT 1;
-
- SET vInventoried = TIMESTAMPADD(DAY,1,vDated);
- SET vDateDayEnd = vInventoried2;
-
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS inv;
-
- CREATE TEMPORARY TABLE inv
- (warehouseFk SMALLINT,
- Id_Article BIGINT,
- 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)
- SELECT tr.warehouse_id, C.Id_Article, SUM(C.Cantidad), w.`name`
- FROM Compres C
- JOIN Articles A USING(Id_Article)
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel tr ON tr.id = E.travel_id
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse w ON w.id = warehouse_id
- WHERE landing = vDateDayEnd
- AND E.Id_Proveedor = 4
- AND w.valuatedInventory
- AND t.inventory
- GROUP BY tr.warehouse_id, C.Id_Article;
-
- END IF;
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouse_id, C.Id_Article, C.Cantidad * IF(vHasNotInventory,-1,1), w.`name`
- FROM Compres C
- JOIN Articles A USING(Id_Article)
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel tr ON tr.id = E.travel_id
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse w ON w.id = tr.warehouse_id
- WHERE landing BETWEEN vInventoried AND vDateDayEnd
- AND IF(landing = util.VN_CURDATE(), tr.received, trUE)
- AND NOT redada
- AND w.valuatedInventory
- AND t.inventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad * IF(vHasNotInventory,-1,1));
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouse_id_out, C.Id_Article, C.Cantidad * IF(vHasNotInventory,1,-1), w.`name`
- FROM Compres C
- JOIN Articles A USING(Id_Article)
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel tr ON tr.id = E.travel_id
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse w ON w.id = warehouse_id_out
- WHERE shipment BETWEEN vInventoried AND vDateDayEnd
- AND NOT redada
- AND w.valuatedInventory
- AND t.inventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad * IF(vHasNotInventory,1,-1));
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT w.id, M.Id_Article, M.Cantidad * IF(vHasNotInventory,1,-1), w.`name`
- FROM Movimientos M
- JOIN Tickets T USING (Id_Ticket)
- JOIN Clientes C USING(Id_Cliente)
- JOIN Articles A USING(Id_Article)
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse w ON w.id = warehouse_id
- WHERE T.Fecha BETWEEN vInventoried AND vDateDayEnd
- AND w.valuatedInventory
- AND t.inventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + M.Cantidad * IF(vHasNotInventory,1,-1);
-
- IF vDated = util.VN_CURDATE() THEN -- volver a poner lo que esta aun en las estanterias
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT w.id, M.Id_Article, M.Cantidad * IF(vHasNotInventory,0,1), w.`name`
- FROM Movimientos M
- JOIN Tickets T USING (Id_Ticket)
- JOIN Clientes C USING(Id_Cliente)
- JOIN Articles A USING(Id_Article)
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse w ON w.id = warehouse_id
- WHERE T.Fecha BETWEEN vDated AND vDateDayEnd
- AND (M.OK <> 0 or T.Etiquetasemitidas <> 0 )
- AND w.valuatedInventory
- AND t.inventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + M.Cantidad * IF(vHasNotInventory,0,1);
-
- END IF;
-
- -- Mercancia en transito
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouse_id, C.Id_Article, C.Cantidad, CONCAT(wOut.`name`,' - ', wIn.`name`)
- FROM Compres C
- JOIN Articles A USING(Id_Article)
- JOIN Entradas E USING (Id_Entrada)
- JOIN travel tr ON tr.id = E.travel_id
- JOIN Tipos t USING(tipo_id)
- JOIN warehouse wIn ON wIn.id = tr.warehouse_id
- JOIN warehouse wOut ON wOut.id = tr.warehouse_id_out
- WHERE vDated >= shipment AND vDated < landing
- AND NOT redada
- AND wIn.valuatedInventory
- AND t.inventory
- AND E.Confirmada
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad);
-
- CALL vn.buyUltimate(NULL,vDateDayEnd);
-
- UPDATE inv i
- JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.Id_Article = bu.itemFk
- JOIN Compres C ON C.Id_Compra = bu.buyFk
- SET total = i.cantidad * (ifnull(C.Costefijo,0) + IFNULL(C.Embalajefijo,0) + IFNULL(C.Portefijo,0) + IFNULL(C.Comisionfija,0)),
- coste = ifnull(C.Costefijo,0) + IFNULL(C.Embalajefijo,0) + IFNULL(C.Portefijo,0) + IFNULL(C.Comisionfija,0)
- WHERE i.cantidad <> 0;
-
- DELETE FROM inv WHERE Cantidad IS NULL or Cantidad = 0;
-
- IF vIsDetailed THEN
-
- SELECT inv.warehouseFk, a.Id_Article, a.Article, a.Medida, inv.Cantidad, tp.Id_Tipo,
- tp.reino_id, inv.coste, cast(inv.total as decimal(10,2)) total, Almacen
- FROM inv
- JOIN warehouse w on w.id = warehouseFk
- JOIN Articles a ON a.Id_Article = inv.Id_Article
- JOIN Tipos tp ON tp.tipo_id = a.tipo_id
- WHERE w.valuatedInventory
- and inv.total > 0
- order by inv.total desc;
-
- ELSE
-
- SELECT i.Almacen, r.reino as Reino, cast(i.total as decimal(10,2)) as Euros, tr.Codigotrabajador as Comprador,A.Id_Article
- FROM inv i
- JOIN warehouse w on w.id = warehouseFk
- JOIN Articles A USING(Id_Article)
- JOIN Tipos t USING(tipo_id)
- LEFT JOIN Trabajadores tr ON tr.Id_trabajador = t.Id_trabajador
- JOIN reinos r ON r.id = t.reino_id
- WHERE w.valuatedInventory
- AND i.total > 0;
-
- END IF;
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE inv;
-end$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/item_buy.sql b/db/routines/vn2008/procedures/item_buy.sql
deleted file mode 100644
index 244334c80..000000000
--- a/db/routines/vn2008/procedures/item_buy.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`item_buy`(IN v_wh TINYINT, IN v_date DATETIME)
-BEGIN
- DECLARE date_inv DATE;
- ALTER TABLE item
- ADD buy_id INT UNSIGNED;
-
- IF v_date < (SELECT vn.getInventoryDate()) THEN
- SELECT MIN(landing) INTO date_inv FROM travel t INNER JOIN Entradas e ON e.travel_id = t.id
- WHERE warehouse_id_out = 13 AND landing <= v_date;
- ELSE
- SET date_inv = vn.getInventoryDate();
- END IF;
- UPDATE item i INNER JOIN (
- SELECT * FROM (
- SELECT c.Id_Article item_id, c.Id_Compra id
- FROM Compres c INNER JOIN Entradas e USING(Id_Entrada)
- INNER JOIN travel t ON t.id = e.travel_id
- WHERE t.landing BETWEEN date_inv AND v_date
- AND c.Novincular = FALSE
- AND c.Tarifa2 >= 0
- ORDER BY v_wh = t.warehouse_id DESC, t.landing DESC
- LIMIT 10000000000000000000
- ) t
- GROUP BY item_id
- ) t
- ON i.id = t.item_id
- SET i.buy_id = t.id;
-
- CREATE INDEX buy USING HASH ON item (buy_id);
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/item_express.sql b/db/routines/vn2008/procedures/item_express.sql
deleted file mode 100644
index 46275014d..000000000
--- a/db/routines/vn2008/procedures/item_express.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`item_express`(IN intWH INT, IN datFEC DATE)
-BEGIN
-
-DECLARE datINV DATE;
-
-
-
-SELECT FechaInventario INTO datINV FROM tblContadores LIMIT 1;
-
-
-SELECT sub1.Id_Article, Visible, Tarifa2
-FROM
-(SELECT Id_Article, SUM(Cantidad) as Visible
-FROM Compres C
-JOIN Entradas E USING(Id_Entrada)
-JOIN travel T ON T.id = E.travel_id
-WHERE shipment >= datINV
-AND landing <= datFEC
-AND Redada = 0
-AND warehouse_id = intWH
-GROUP BY Id_Article) sub1
-JOIN
-(
-SELECT * FROM
-(
-SELECT Id_Article, Tarifa2
-FROM Compres C
-JOIN Entradas E USING(Id_Entrada)
-JOIN travel T ON T.id = E.travel_id
-WHERE shipment >= datINV
-AND landing <= datFEC
-AND Redada = 0
-AND Novincular = 0
-AND warehouse_id = intWH
-ORDER BY landing DESC LIMIT 10000000000000000000) sub
-GROUP BY Id_Article) sub2 USING(Id_Article);
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/item_new.sql b/db/routines/vn2008/procedures/item_new.sql
deleted file mode 100644
index 701e4986a..000000000
--- a/db/routines/vn2008/procedures/item_new.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`item_new`()
-BEGIN
- CREATE TEMPORARY TABLE item
- (
- item_id INT UNSIGNED NOT NULL,
- UNIQUE KEY USING HASH (item_id)
- )
- ENGINE = MEMORY;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/malpagantes.sql b/db/routines/vn2008/procedures/malpagantes.sql
deleted file mode 100644
index 196de92d2..000000000
--- a/db/routines/vn2008/procedures/malpagantes.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`malpagantes`()
-BEGIN
-
-set @cliente := 0;
-set @saldo := 0;
-
-Select Id_Cliente, Cliente from
-Clientes
-join
-(select distinct Id_Cliente
-from Facturas
-where Fecha > '2015-01-01') cli using(Id_Cliente)
-left join
-(
-select distinct Id_Cliente
-from
-(
-select Fecha
- , @saldo := IF(@cliente = Id_Cliente, @saldo + Importe, Importe) Saldo
- , @cliente := Id_Cliente as Id_Cliente
-from
-(
-select Id_Cliente, Fecha, Importe from
-
-(
-select Id_Cliente, -1 * Importe Importe, Fecha
-from Facturas
-union all
-select Id_Cliente, Entregado, Fechacobro
-from Recibos
-) sub
-order by Id_Cliente, Fecha
-) sub2
-) sub3
-where Saldo > -1
-and Fecha > '2015-01-01'
-
-) sub4 using(Id_Cliente)
-where sub4.Id_Cliente is null;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/mensaje.sql b/db/routines/vn2008/procedures/mensaje.sql
deleted file mode 100644
index 89f9bf4f0..000000000
--- a/db/routines/vn2008/procedures/mensaje.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`mensaje`(IN idREM INT, IN idDES INT, IN strMSG LONGTEXT)
-BEGIN
-
-/*DECLARE lngLASTID BIGINT;*/
-
--- Caso sencillo
-
-INSERT INTO Mensajes(Mensaje, Fecha, Remitente, Destinatario)
-VALUES(strMSG, util.VN_NOW(), idREM, idDES);
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/msg.sql b/db/routines/vn2008/procedures/msg.sql
deleted file mode 100644
index e402efe39..000000000
--- a/db/routines/vn2008/procedures/msg.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`msg`(IN memTXT VARCHAR(255), IN idREM INTEGER, idDES INTEGER)
-BEGIN
- DECLARE last_ID INTEGER;
- DECLARE codDES CHAR(3);
-
- SELECT CodigoTrabajador INTO codDES FROM Trabajadores WHERE Id_Trabajador = idDES;
-
- INSERT INTO Mensajes(Mensaje,Fecha,Remitente,Destinatario)
- VALUES(memTXT, util.VN_NOW(),idREM, idDES);
-
- SELECT LAST_INSERT_ID() INTO last_ID;
-
-
- INSERT INTO Incidencias(Incidencia,Id_Trabajador,Destino,Fecha,Fecha_Mod)
- VALUES (CONCAT('@@ ',last_ID),idREM,codDES,util.VN_NOW(),util.VN_NOW());
-
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/newItem.sql b/db/routines/vn2008/procedures/newItem.sql
deleted file mode 100644
index 8982b6adc..000000000
--- a/db/routines/vn2008/procedures/newItem.sql
+++ /dev/null
@@ -1,34 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`newItem`(IN vTicket INTEGER, IN vVolume INTEGER, IN vQuantity INTEGER)
-BEGIN
-
- DECLARE vLandingWarehouse INT;
- DECLARE vLandingDate DATE;
- DECLARE vShipmentDate DATE;
- DECLARE vTravel INT;
- DECLARE vEntry INT;
-
- SELECT warehouse_id, Fecha, landing INTO vLandingWarehouse, vShipmentDate, vLandingDate FROM Tickets WHERE Id_Ticket = vTicket;
-
- -- seleccionamos travel
- SELECT id, Id_Entrada INTO vTravel, vEntry
- FROM travel t LEFT JOIN Entradas e ON t.id = e.travel_id
- WHERE t.landing = vLandingDate AND t.shipment = vShipmentDate AND t.warehouse_id_out = vLandingWarehouse AND t.warehouse_id = vWarehouse
- AND t.delivered = FALSE ; -- agency ??
-
- -- creamos el travel si es necesario
- IF NOT vTravel THEN
- INSERT INTO travel (shipment, landing, warehouse_id, warehouse_id_out, agency_id)
- VALUES (vShipmentDate, vLandingDate, vLandingWarehouse, vShipmentWarehouse, a);
- SELECT LAST_INSERT_ID() INTO vTravel;
- END IF;
-
- -- creamos la Entrada si es necesario
- IF NOT vEntry THEN
- INSERT INTO Entradas (Id_Proveedor, travel_id)
- VALUES (13, vTravel); -- proveedor 'MOVIMIENTO ALMACEN'
- SELECT LAST_INSERT_ID() INTO vEntry;
- END IF;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/niching.sql b/db/routines/vn2008/procedures/niching.sql
deleted file mode 100644
index eff501ed5..000000000
--- a/db/routines/vn2008/procedures/niching.sql
+++ /dev/null
@@ -1,49 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`niching`(IN i_ini INT, IN i_end INT
-, IN i_bal INT, IN i_col INT )
-BEGIN
-
-DECLARE i INT(5);
-DECLARE j INT(5);
-
-DROP TEMPORARY TABLE IF EXISTS labels;
-
-CREATE TEMPORARY TABLE `labels`
- (`label` VARCHAR(15) NULL)
-ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-WHILE i_ini <= i_end DO
-
- SET i = i_bal;
-
- WHILE i > 0 DO
-
-
-
- SET j = i_col;
- IF j = 0 THEN
- INSERT INTO labels(label)
- VALUES (CONCAT(i_ini,IF(i=0,' ',char(64 + i))));
- ELSE
-
- WHILE j > 0 DO
-
- INSERT INTO labels(label)
- VALUES (CONCAT(i_ini,char(64 + i), j));
-
- SET j = j - 1;
-
- END WHILE;
- END IF;
- SET i = i - 1;
-
- END WHILE;
-
-SET i_ini = i_ini + 1;
-
-END WHILE;
-
-SELECT CONCAT('*',label,'*') as label, label as id FROM labels;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/notify_passport.sql b/db/routines/vn2008/procedures/notify_passport.sql
deleted file mode 100644
index 5b611f063..000000000
--- a/db/routines/vn2008/procedures/notify_passport.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`notify_passport`(
- IN vItemFk INT,
- IN vStickers SMALLINT,
- IN vPacking SMALLINT,
- IN vBuyFk INT
-)
-BEGIN
- -- DPRECATED use vn.buy_notifyPassport
- CALL vn.buy_notifyPassport(vBuyFk, vItemFk, vStickers, vPacking);
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/percentil.sql b/db/routines/vn2008/procedures/percentil.sql
deleted file mode 100644
index 650be0138..000000000
--- a/db/routines/vn2008/procedures/percentil.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`percentil`()
-BEGIN
-
-DECLARE max_range INT;
-
-DROP TEMPORARY TABLE IF EXISTS previa;
-
-CREATE TEMPORARY TABLE previa
-SELECT @posicion:= @posicion +1 as Posicion, Id_Cliente, Total FROM (
-SELECT Id_Cliente, Total FROM (
-SELECT Id_Cliente, SUM(Importe) as Total
-FROM Facturas
-INNER JOIN Clientes USING(Id_Cliente)
-INNER JOIN (SELECT @posicion := 0) sub_pos
-WHERE invoice
-AND YEAR(Fecha) = YEAR(util.VN_CURDATE())
-GROUP BY Id_Cliente) sub
-ORDER BY Total
-) sub2;
-
-SELECT COUNT(*) INTO max_range FROM previa;
-
-UPDATE Clientes SET percentil = 0;
-
-UPDATE Clientes INNER JOIN previa USING(Id_Cliente)
-SET Clientes.percentil = ROUND(Posicion *100 / max_range,0);
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/prepare_client_list.sql b/db/routines/vn2008/procedures/prepare_client_list.sql
deleted file mode 100644
index 740bbff4a..000000000
--- a/db/routines/vn2008/procedures/prepare_client_list.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`prepare_client_list`()
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
- CREATE TEMPORARY TABLE tmp.client_list
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT DISTINCT Id_Cliente
- FROM tmp.ticket_list;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/proc_end.sql b/db/routines/vn2008/procedures/proc_end.sql
deleted file mode 100644
index 982ef708f..000000000
--- a/db/routines/vn2008/procedures/proc_end.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`proc_end`()
-BEGIN
-
-UPDATE stat SET `end` = util.VN_NOW()
-WHERE id = (SELECT id FROM lastid);
-
-DROP TEMPORARY TABLE IF EXISTS lastid;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/proc_start.sql b/db/routines/vn2008/procedures/proc_start.sql
deleted file mode 100644
index 57d919c12..000000000
--- a/db/routines/vn2008/procedures/proc_start.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`proc_start`(IN v_proc_id INT)
-BEGIN
-
-INSERT INTO stat(proc_id) VALUES(v_proc_id);
-
-
-DROP TEMPORARY TABLE IF EXISTS lastid;
-CREATE TEMPORARY TABLE lastid
-SELECT last_insert_id() id;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/prueba_miguel.sql b/db/routines/vn2008/procedures/prueba_miguel.sql
deleted file mode 100644
index 829f4a8cf..000000000
--- a/db/routines/vn2008/procedures/prueba_miguel.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`prueba_miguel`()
-BEGIN
-select 1;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/quadre_clientes.sql b/db/routines/vn2008/procedures/quadre_clientes.sql
deleted file mode 100644
index 3db4c073a..000000000
--- a/db/routines/vn2008/procedures/quadre_clientes.sql
+++ /dev/null
@@ -1,67 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`quadre_clientes`(IN datFEC DATETIME)
-BEGIN
-
-
- DECLARE datSTART DATE;
- SET datFEC = TIMESTAMP(datFEC,'23:59:59');
- SELECT util.firstDayOfYear(datFEC) INTO datSTART;
-
- SELECT P2.Alias, C.Id_Cliente, C.Cuenta, Gestion, Contaplus, Gestion - Contaplus as Diferencia, empresa_id, Cliente
-
- FROM Clientes C
-
- JOIN pay_met pm ON pm.id = C.pay_met_id
-
- JOIN
-
- (
-
- SELECT empresa_id, Id_Cliente, round(sum(Gestion),2) as Gestion, round(sum(Contaplus),2) as Contaplus
-
- FROM
-
- (
- SELECT empresa_id, Id_Cliente, Gestion, 0 as Contaplus
-
- FROM
-
- (
- SELECT empresa_id, Id_Cliente, -1 * Importe as Gestion
- FROM Facturas
- WHERE Fecha BETWEEN datSTART AND datFEC
- UNION ALL
- SELECT empresa_id, Id_Cliente, Entregado
- FROM Recibos
- WHERE Fechacobro BETWEEN datSTART AND datFEC
- ) G
-
- WHERE empresa_id <> 965
-
- UNION ALL
-
- SELECT empresa_id, Id_Cliente, 0, round(nz(Eurohaber) - nz(Eurodebe),2) as Contaplus
-
- FROM bi.XDiario_ALL XD
-
- JOIN Clientes C ON C.Cuenta = XD.SUBCTA
-
- WHERE Fecha BETWEEN datSTART AND datFEC
-
- ) sub1
-
- GROUP BY empresa_id, Id_Cliente
-
- ) sub2 USING(Id_Cliente)
-
- JOIN Proveedores P2 ON P2.Id_Proveedor = sub2.empresa_id
-
- WHERE pm.deudaviva -- Cliente de perdidas no vale la pena revisarlo
-
- HAVING ABS(Diferencia) > 0.05
-
- ORDER BY Cliente;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/quadre_clientes_detalle.sql b/db/routines/vn2008/procedures/quadre_clientes_detalle.sql
deleted file mode 100644
index 4ed261d4b..000000000
--- a/db/routines/vn2008/procedures/quadre_clientes_detalle.sql
+++ /dev/null
@@ -1,70 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`quadre_clientes_detalle`(IN idC INT, IN idE INT, IN datFEC DATETIME)
-BEGIN
-
-DECLARE datSTART DATE;
-
-SET datSTART = util.firstDayOfYear(datFEC);
-SET datFEC = TIMESTAMP(datFEC,'23:59:59');
-
--- Creamos una tabla para almacenar las facturas del cliente, junto con el numero de veces que se repite.
-DROP TEMPORARY TABLE IF EXISTS qFACTURAS;
-
-CREATE TEMPORARY TABLE qFACTURAS
-(Fecha DATETIME,
- TPVcount INT,
- Factura DECIMAL(10,2) SIGNED,
- Recibo DECIMAL(10,2) SIGNED,
- CPcount INT,
- Debe DECIMAL(10,2) SIGNED,
- Haber DECIMAL(10,2) SIGNED,
- Control INT DEFAULT 0,
- PRIMARY KEY(Fecha, TPVcount, Factura, Recibo, CPcount, Debe, Haber))
- ENGINE = InnoDB
-;
-
--- Insertamos las facturas y los recibos de gestion.
-INSERT INTO qFACTURAS
-
- SELECT Fecha, COUNT(*) as TPVcount, round(Importe,2) as Factura, 0 as Recibo, COUNT(*)as CPcount,round(Importe,2) as Debe, 0 as Haber, 1 as Control
- FROM Facturas
- WHERE Id_Cliente = idC AND empresa_id = idE AND Fecha BETWEEN datSTART AND datFEC
- GROUP BY Fecha, round(Importe,2)
- UNION ALL
- SELECT Fechacobro as Fecha, COUNT(*) as TPVcount, 0 as Factura, round(Entregado,2) as Recibo,COUNT(*) as CPCount, 0 as Debe, round(Entregado,2) as Haber, 3 as Control
- FROM Recibos
- WHERE Id_Cliente = idC AND empresa_id = idE AND Fechacobro BETWEEN datSTART AND datFEC
- GROUP BY Fechacobro, round(Entregado,2);
-
--- Insertamos los asientos de contabilidad, marcando con control = -1 las repetidas.
-INSERT INTO qFACTURAS
- SELECT *
- FROM (
- SELECT Fecha, COUNT(*) as TPVcount, round(Eurodebe,2) as Factura, round(Eurohaber,2) as Recibo, COUNT(*) as CPcount, round(Eurodebe,2) as Debe, round(Eurohaber,2) as Haber, 2 as Control
- FROM bi.XDiario_ALL XD
- JOIN Clientes C ON C.Cuenta = XD.SUBCTA
- WHERE Id_Cliente = idC AND empresa_id = idE AND Fecha BETWEEN datSTART AND datFEC
- AND (Eurodebe <> 0 OR Eurohaber <>0)
- GROUP BY Fecha, round(Eurodebe,2), round(Eurohaber,2)
- ) sub
-
- ON DUPLICATE KEY UPDATE Control = -1;
-
-
-
--- Eliminamos las repetidas
--- DELETE FROM qFACTURAS WHERE Control = -1;
-
--- Arreglamos las buenas
-UPDATE qFACTURAS SET TPVcount = 0, Factura = 0, Recibo = 0 WHERE Control = 2;
-UPDATE qFACTURAS SET CPcount = 0, Debe = 0, Haber = 0 WHERE Control IN (1,3);
-
--- Mostramos el resultado
-SELECT *, @saldo := @saldo + TPVcount * (Factura + Recibo) - CPCount * ( Debe + Haber ) as Saldo
-FROM qFACTURAS
-JOIN (SELECT @saldo := 0) truqui ;
-DROP TEMPORARY TABLE IF EXISTS qFACTURAS;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql
index 8c4ca5f94..ca5304b6c 100644
--- a/db/routines/vn2008/procedures/recobro_credito.sql
+++ b/db/routines/vn2008/procedures/recobro_credito.sql
@@ -8,12 +8,12 @@ BEGIN
END;
START TRANSACTION;
- INSERT INTO vn.clientCredit(clientFk, amount)
+ INSERT INTO vn.clientCredit(clientFk, amount)
SELECT c.id, 0
FROM vn.`client` c
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
WHERE c.credit <> 0 AND pm.`code` = 'card';
-
+
UPDATE vn.`client` c
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
SET credit = 0
@@ -49,7 +49,7 @@ BEGIN
SELECT Id_Cliente, newCredit, NULL
FROM clientes_credit;
- DROP TEMPORARY TABLE clientes_credit;
+ DROP TEMPORARY TABLE clientes_credit;
COMMIT;
END$$
-DELIMITER ;
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn2008/procedures/scan_rutas_view.sql b/db/routines/vn2008/procedures/scan_rutas_view.sql
deleted file mode 100644
index e61d94d71..000000000
--- a/db/routines/vn2008/procedures/scan_rutas_view.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`scan_rutas_view`()
-BEGIN
-
-
-/* muestra las rutas agrupadas de los ultimos tres dias, así como una lista de los tickets sin enrutar, agrpados por agencia y fecha*/
-
-select Fecha, Id_Ruta, Matricula, sub.m3, CodigoTrabajador, Agencia, Bultos, w.name as Almacen
-from
-(
-select r.Fecha, Id_Ruta, r.Id_Trabajador, r.Id_Agencia, Id_Vehiculo, sum(m3) m3, sum(Bultos) Bultos, warehouse_id
-from Rutas r
-join Tickets t using(Id_Ruta)
-where r.Fecha >= timestampadd(day,-3,util.VN_CURDATE())
-group by Id_Ruta, warehouse_id
-
-union all
-
-select ifnull(landing,Fecha), dayofmonth(Fecha) * 100000 + Id_Agencia ruta , count(*) as m3, Id_Agencia, null, null, sum(Bultos), warehouse_id
-from Tickets
-where Id_Ruta is null
-and Fecha between timestampadd(day,-3,util.VN_CURDATE()) and util.dayEnd(util.VN_CURDATE())
-group by ruta, warehouse_id
-) sub
-left join Vehiculos using(Id_Vehiculo)
-left join Agencias using(Id_Agencia)
-left join Trabajadores using(Id_Trabajador)
-left join warehouse w on w.id = sub.warehouse_id;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/sort_merge_passes_ernesto.sql b/db/routines/vn2008/procedures/sort_merge_passes_ernesto.sql
deleted file mode 100644
index 5c824ac9b..000000000
--- a/db/routines/vn2008/procedures/sort_merge_passes_ernesto.sql
+++ /dev/null
@@ -1,85 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`sort_merge_passes_ernesto`()
-BEGIN
-declare i INT;
-declare SMP INT;
-DECLARE SMP_RATE INT;
-DECLARE SMP_OLD INT;
-DECLARE SMP_NEW INT;
-
-SET i = 0;
-loop1: REPEAT
- SET i = i + 1;
- SET @SleepTime = 300;
-
- SELECT variable_value INTO @SMP_OLD FROM information_schema.global_status WHERE variable_name = 'Sort_merge_passes';
-
- SELECT SLEEP(@SleepTime) INTO @NiCasoAEsteSLEEP_EsNormal;
-
- SELECT variable_value INTO @SMP_NEW FROM information_schema.global_status WHERE variable_name = 'Sort_merge_passes';
- SET @SMP = @SMP_NEW - @SMP_OLD;
- SET @SMP_RATE = @SMP * 3600 / @SleepTime;
-
- Select VARIABLE_value into @connections from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'connections';
- Select VARIABLE_value into @Threads_created from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Threads_created';
- Select VARIABLE_value into @Threads_cached from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Threads_cached';
- Select VARIABLE_value into @Innodb_os_log_written from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Innodb_os_log_written';
-
- Select VARIABLE_value into @Created_tmp_disk_tables from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Created_tmp_disk_tables';
- Select VARIABLE_value into @created_tmp_tables from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'created_tmp_tables';
- Select VARIABLE_value into @Created_tmp_files from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Created_tmp_files';
- Select VARIABLE_value into @opened_tables from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'opened_tables';
- Select VARIABLE_value into @open_tables from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'open_tables';
- Select VARIABLE_value into @TABLE_OPEN_CACHE_OVERFLOWS from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'TABLE_OPEN_CACHE_OVERFLOWS';
- Select VARIABLE_value into @TABLE_OPEN_CACHE_MISSES from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'TABLE_OPEN_CACHE_MISSES';
- Select VARIABLE_value into @TABLE_OPEN_CACHE_HITS from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'TABLE_OPEN_CACHE_HITS';
- Select VARIABLE_value into @Uptime_since_flush_status from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Uptime_since_flush_status';
- Select VARIABLE_value into @Uptime from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Uptime';
- Select VARIABLE_value into @Qcache_hits from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Qcache_hits';
- Select VARIABLE_value into @Qcache_inserts from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Qcache_inserts';
- Select VARIABLE_value into @Qcache_not_cached from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Qcache_not_cached';
- Select VARIABLE_value into @Innodb_num_open_files from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Innodb_num_open_files';
- Select VARIABLE_value into @Open_table_definitions from information_schema.GLOBAL_STATUS where VARIABLE_NAME like 'Open_table_definitions';
- select count into @trx_rseg_history_len from information_schema.innodb_metrics where name = 'trx_rseg_history_len';
-
- Select @@global.table_definition_cache into @table_definition_cache;
- Select @@global.table_open_cache into @table_open_cache;
- Select @@global.table_open_cache_instances into @table_open_cache_instances;
- Select @@global.thread_cache_size into @Thread_cache_size;
- Select @@global.sort_buffer_size into @sort_buffer_size;
- select @@global.join_buffer_size into @join_buffer_size;
- select @@global.read_rnd_buffer_size into @read_rnd_buffer_size;
- select @@global.tmp_table_size into @tmp_table_size;
- select @@global.max_heap_table_size into @max_heap_table_size;
- Select @@global.open_files_limit into @open_files_limit;
- Select @@global.innodb_open_files into @innodb_open_files;
- Select @@global.query_cache_size into @query_cache_size;
- Select @@global.query_cache_type into @query_cache_type;
- select @@global.log_output into @log_output;
-
- SELECT (Open_tables * Uptime / Opened_Tables) AS OpenTablesxUptimeDivOpened INTO @OpenTablesxUptimeDivOpened FROM
- (SELECT variable_value Uptime FROM information_schema.global_status
- WHERE variable_name = 'Uptime_since_flush_status') up,
- (SELECT variable_value Open_tables FROM information_schema.global_status
- WHERE variable_name = 'Open_tables') opn,
- (SELECT IF(variable_value=0,1,variable_value) Opened_tables
- FROM information_schema.global_status
- WHERE variable_name = 'Opened_tables') opnd;
-
- INSERT INTO sort_merge_results_ernesto (hora, uptime, uptime_since_flush, smp_old, smp_new, smp, smp_hour,connections, Threads_created, Threads_cached, Thread_cache_size, sort_buffer_size, opened_tables,
- Created_tmp_disk_tables, created_tmp_tables, Innodb_os_log_written, table_definition_cache, table_open_cache, table_open_cache_instances, open_tables, TABLE_OPEN_CACHE_OVERFLOWS, TABLE_OPEN_CACHE_MISSES,
- TABLE_OPEN_CACHE_HITS, tmp_table_size, max_heap_table_size, OpenTablesxUptimeDivOpened, join_buffer_size, open_files_limit, innodb_open_files, Created_tmp_files, query_cache_size, query_cache_type, Qcache_hits,
- Qcache_inserts, Qcache_not_cached, Innodb_num_open_files, Open_table_definitions, read_rnd_buffer_size, log_output, trx_rseg_history_len)
- VALUES (util.VN_NOW(), @uptime, @uptime_since_flush, @SMP_OLD, @SMP_NEW, @SMP, @SMP_RATE, @connections, @Threads_created, @Threads_cached, @Thread_cache_size, @sort_buffer_size, @opened_tables,
- @Created_tmp_disk_tables, @created_tmp_tables, @Innodb_os_log_written, @table_definition_cache, @table_open_cache, @table_open_cache_instances, @open_tables, @TABLE_OPEN_CACHE_OVERFLOWS, @TABLE_OPEN_CACHE_MISSES,
- @TABLE_OPEN_CACHE_HITS, @tmp_table_size, @max_heap_table_size, @OpenTablesxUptimeDivOpened, @join_buffer_size, @open_files_limit, @innodb_open_files, @Created_tmp_files, @query_cache_size, @query_cache_type, @Qcache_hits,
- @Qcache_inserts, @Qcache_not_cached, @Innodb_num_open_files, @Open_table_definitions, @read_rnd_buffer_size, @log_output, @trx_rseg_history_len);
-
- if (i mod 3 = 0) then
- SELECT * FROM sort_merge_results_ernesto order by hora desc limit 20;
- End if;
-
- UNTIL i >= 12 * 24
-END REPEAT;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/splitAnthuriums2016.sql b/db/routines/vn2008/procedures/splitAnthuriums2016.sql
deleted file mode 100644
index fa7b7caf9..000000000
--- a/db/routines/vn2008/procedures/splitAnthuriums2016.sql
+++ /dev/null
@@ -1,86 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`splitAnthuriums2016`()
-BEGIN
-
-DECLARE vStartingDate DATETIME DEFAULT '2016-10-18';
-DECLARE vEndingDate DATETIME DEFAULT '2016-10-31 23:59:00';
-DECLARE vMyTicket INT;
-DECLARE vNewTicket INT;
--- DECLARE SILLA_PCA INT DEFAULT 44;
-DECLARE done INT DEFAULT 0;
-
-DECLARE rs CURSOR FOR
-SELECT DISTINCT Id_Ticket
-FROM Movimientos m
-JOIN Tickets t using(Id_Ticket)
-JOIN Articles a using(Id_Article)
-JOIN Tipos tp using(tipo_id)
-WHERE t.Fecha between vStartingDate and vEndingDate
-AND warehouse_id = 1
-AND
- (
- Id_Tipo = 'ANT'
- OR
- ( Id_Article = 100
- AND
- Concepte LIKE 'ANT%')
- );
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
-OPEN rs;
-
-FETCH rs INTO vMyTicket;
-
-
-
-WHILE NOT done DO
-
-
- INSERT INTO Tickets(Id_Cliente
- , warehouse_id
- , Fecha
- , Alias
- , Id_Consigna
- , Id_Trabajador
- , Id_Ruta
- , empresa_id
- , Id_Agencia
- , landing)
- SELECT Id_Cliente
- , SILLA_PCA as warehouse_id
- , Fecha
- , Alias
- , Id_Consigna
- , Id_Trabajador
- , Id_Ruta
- , empresa_id
- , Id_Agencia
- , landing
- FROM Tickets
- WHERE Id_Ticket = vMyTicket;
-
- SELECT LAST_INSERT_ID() INTO vNewTicket;
-
- -- SELECT vMyTicket, vNewTicket; SET done = 1;
- UPDATE Movimientos m
- JOIN Articles a using(Id_Article)
- JOIN Tipos tp using(tipo_id)
- SET Id_Ticket = vNewTicket
- WHERE Id_Ticket = vMyTicket
- AND (
- Id_Tipo = 'ANT'
- OR
- ( m.Id_Article = 100
- AND
- Concepte LIKE 'ANT%')
- );
-
- FETCH rs INTO vMyTicket;
-
-END WHILE;
-
-CLOSE rs;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/subordinate.sql b/db/routines/vn2008/procedures/subordinate.sql
deleted file mode 100644
index a30396951..000000000
--- a/db/routines/vn2008/procedures/subordinate.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`subordinate`(IN `vWorker` INT, IN `vBaseCase` BOOLEAN)
- NO SQL
-BEGIN
- -- deprecated usar vn.worker_GetHierarch
- DECLARE vAuxWorker INT;
-
- IF vBaseCase THEN
- SET @@max_sp_recursion_depth = 5 ;
- DROP TEMPORARY TABLE IF EXISTS subordinate;
- CREATE TEMPORARY TABLE subordinate
- (INDEX (Id_Trabajador))
- ENGINE = MEMORY
- SELECT vWorker Id_Trabajador, TRUE visited, 0 boss;
- END IF;
-
- INSERT INTO subordinate
- SELECT Id_Trabajador, FALSE, vWorker
- FROM Trabajadores WHERE boss = vWorker;
-
- IF (SELECT COUNT(*) FROM subordinate WHERE NOT visited AND vWorker = boss LIMIT 1) > 0 THEN
- SELECT Id_Trabajador INTO vAuxWorker
- FROM subordinate
- WHERE NOT visited AND vWorker = boss LIMIT 1;
-
- REPEAT
- CALL subordinate(vAuxWorker, FALSE);
- UPDATE subordinate SET visited = TRUE WHERE Id_Trabajador = vAuxWorker;
- SET vAuxWorker = 0;
-
- SELECT Id_Trabajador INTO vAuxWorker
- FROM subordinate
- WHERE NOT visited
- AND vWorker = boss
- LIMIT 1;
-
- UNTIL vAuxWorker = 0
- END REPEAT;
- END IF;
-
- IF vWorker = 2 THEN
- INSERT INTO subordinate
- SET Id_Trabajador = vWorker, visited = TRUE, boss = vWorker;
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/suppliersDebt.sql b/db/routines/vn2008/procedures/suppliersDebt.sql
deleted file mode 100644
index 9670badc5..000000000
--- a/db/routines/vn2008/procedures/suppliersDebt.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`suppliersDebt`()
-BEGIN
- SELECT abbreviation as Empresa, Proveedor, Euros, divisa, empresa_id, proveedor_id
- FROM
- (
- SELECT empresa_id,
- proveedor_id,
- cast(sum(Euros) AS DECIMAL(10,2)) as Euros,
- cast(sum(divisa) AS DECIMAL(10,2)) as divisa
- FROM
- (
- SELECT empresa_id,
- proveedor_id,
- -1 * cantidad as Euros,
- -1 * divisa as divisa
- FROM recibida_vencimiento rv
- INNER JOIN recibida r ON r.id = rv.recibida_id
- WHERE r.fecha > '2014-12-31'
-
- UNION ALL
-
- SELECT empresa_id,
- id_proveedor,
- importe,
- divisa
- FROM pago
- WHERE fecha > '2014-12-31'
- ) sub
- GROUP BY empresa_id, proveedor_id
- ) sub2
- JOIN Proveedores p ON p.Id_Proveedor = sub2.proveedor_id
- JOIN empresa e ON e.id = sub2.empresa_id;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/top_seller.sql b/db/routines/vn2008/procedures/top_seller.sql
deleted file mode 100644
index cb51d1425..000000000
--- a/db/routines/vn2008/procedures/top_seller.sql
+++ /dev/null
@@ -1,113 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`top_seller`()
-BEGIN
-
- drop table if exists top_sellers_min;
- create temporary table top_sellers_min ENGINE = MEMORY
- select a.Id_Article , tip.reino_id as Reino, count(m.Id_Article) as contados
- from Movimientos m
- inner join Tickets t
- on m.Id_Ticket = t.Id_Ticket
- inner join Articles a
- on a.Id_Article = m.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tip.reino_id
- where t.Fecha between timestampadd(day,-7,util.VN_CURDATE()) and util.VN_CURDATE()
- group by m.Id_Article;
-
- drop table if exists top_seller;
- create temporary table top_seller ENGINE = MEMORY
- select a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 1
- order by contados desc
- limit 5;
-
- insert into top_seller
- select
- a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 2
- order by contados desc
- limit 5;
-
- insert into top_seller
- select
- a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 3
- order by contados desc
- limit 5;
-
- insert into top_seller
- select
- a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 4
- order by contados desc
- limit 5;
-
- insert into top_seller
- select
- a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 5
- order by contados desc
- limit 5;
-
- insert into top_seller
- select
- a.Article, tmp.Id_Article , a.Foto as foto, a.tipo_id as Id_Tipo,
- tmp.Reino, r.reino as ReinoNombre, tip.Tipo as Tipo, tmp.contados
- from top_sellers_min tmp
- inner join Articles a
- on a.Id_Article = tmp.Id_Article
- inner join Tipos tip
- on a.tipo_id = tip.tipo_id
- inner join reinos r
- on r.id = tmp.Reino
- where tmp.Reino = 7
- order by contados desc
- limit 5;
-
- drop table if exists top_sellers_min;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/travel_tree_shipment.sql b/db/routines/vn2008/procedures/travel_tree_shipment.sql
deleted file mode 100644
index acbca6752..000000000
--- a/db/routines/vn2008/procedures/travel_tree_shipment.sql
+++ /dev/null
@@ -1,37 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`travel_tree_shipment`(v_date DATE, v_consigna INT, v_agency INT, v_warehouse INT)
-BEGIN
-/**
-* DEPRECATED usar vn.agencyHourGetLanded
-*
- * Devuelve una tabla temporal con el dia de recepcion para v_date.
- *
- * @param v_date Fecha de preparacion de mercancia
- * @param v_consigna Id de consignatario, %NULL para recogida
- * @param v_agency Id agencia
- * @table travel_tree_shipment Datos de recepción
- */
- DROP TEMPORARY TABLE IF EXISTS travel_tree_shipment;
- CREATE TEMPORARY TABLE travel_tree_shipment
- ENGINE = MEMORY
- SELECT v_warehouse warehouse_id, v_envio landing FROM (
- SELECT * FROM (
- SELECT v_warehouse, TIMESTAMPADD(DAY, subtract_day, v_date) v_envio, subtract_day, ah.max_hour
- FROM agency_hour ah
- LEFT JOIN Consignatarios c ON c.Id_Consigna = v_consigna
- WHERE (week_day = weekday(TIMESTAMPADD(DAY, subtract_day, v_date)) OR week_day IS NULL)
- AND (ah.agency_id = v_agency OR ah.agency_id IS NULL)
- AND ah.warehouse_id = v_warehouse
- AND (ah.province_id = c.province_id OR ah.province_id IS NULL OR v_consigna IS NULL)
- ORDER BY (
- (ah.week_day IS NOT NULL) +
- (ah.agency_id IS NOT NULL) +
- (- ah.subtract_day) +
- ((ah.province_id IS NOT NULL)*3)
- ) DESC
- ) t
- LIMIT 1
- ) t
- WHERE IF(v_date = util.VN_CURDATE(), max_hour > HOUR(util.VN_NOW()), TRUE) AND subtract_day < 225;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_delete.sql b/db/routines/vn2008/procedures/unary_delete.sql
deleted file mode 100644
index 7f60569ca..000000000
--- a/db/routines/vn2008/procedures/unary_delete.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_delete`(v_node INT, v_delete bool)
-BEGIN
-/**
- * Borra un nodo. Se puede indicar si se quieren mantener los hijos.
- * En este caso los hijos pasan al padre del nodo.
- * Si no tiene padre, los hijos pasaran a ser padres.
- *
- * @v_node: Nodo que se quiere borrar.
- * @v_delete: Se indica si se borran los nodos.
- **/
-
- DECLARE v_parent INT;
-
- SELECT parent
- INTO v_parent
- FROM unary
- WHERE id = v_node;
-
- IF(v_delete = FALSE) THEN
- UPDATE unary
- SET parent = v_parent
- WHERE parent = v_node;
- END IF;
-
- DELETE FROM unary
- WHERE id = v_node;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_insert.sql b/db/routines/vn2008/procedures/unary_insert.sql
deleted file mode 100644
index 743944f86..000000000
--- a/db/routines/vn2008/procedures/unary_insert.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_insert`(OUT v_unary INT, v_parent INT)
-BEGIN
-
- /**
- * Inserta un nuevo nodo. Se puede indicar el padre.
- *
- * @v_parent: Nodo padre.
- * @v_unary: Id del nuevo nodo.
- **/
-
- INSERT INTO unary(parent) VALUES(v_parent);
-
- SELECT last_insert_id() INTO v_unary;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_scan_ident.sql b/db/routines/vn2008/procedures/unary_scan_ident.sql
deleted file mode 100644
index 5c62e93e7..000000000
--- a/db/routines/vn2008/procedures/unary_scan_ident.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_scan_ident`(v_top INT, v_space INT)
-BEGIN
-/**
- * A partir de un nodo devuelve el id y el nombre del nodod y sus hijos.
- * El nombre viene identado segun el numero de espacios multiplicado por la profundiad del nodo.
- *
- * v_top: Id del nodo padre.
- * v_space: Spacios a dejar al identar,
- * @table tmp.tree_ident Tabla con los ids de los nodos descendientes y su nombre identado;
- **/
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tree_ident;
- CALL tree_leaves(v_top);
-
- CREATE TEMPORARY TABLE tmp.tree_ident
- ENGINE = MEMORY
- SELECT t.id,
- CONCAT( REPEAT(REPEAT(" ",v_space), t.depth), sp.name) AS name
- FROM tmp.tree t
- INNER JOIN unary_scan sp
- ON t.id = sp.id;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_scan_insert.sql b/db/routines/vn2008/procedures/unary_scan_insert.sql
deleted file mode 100644
index 0ac2c7b1e..000000000
--- a/db/routines/vn2008/procedures/unary_scan_insert.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_scan_insert`(v_name VARCHAR(45), v_parent INT, v_type VARCHAR(45))
-BEGIN
-
- /**
- * Inserta un nuevo nodo de tipo unary_scan. Se puede indicar el padre.
- *
- * @v_name: Nombre del nodo.
- * @v_parent: Nodo padre.
- * @v_type: Tipo del nodo a crear.
- **/
-
- DECLARE v_unary INT;
-
- CALL unary_insert(v_unary, v_parent);
-
- INSERT INTO unary_scan(name, unary_id, type) VALUES(v_name, v_unary, v_type);
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_update.sql b/db/routines/vn2008/procedures/unary_update.sql
deleted file mode 100644
index 8bb366810..000000000
--- a/db/routines/vn2008/procedures/unary_update.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_update`(v_node INT, v_new_parent INT, v_move bool)
-BEGIN
-/**
- * Cambia el padre de un nodo. Se puede indicar si se quieren mover los hijos.
- * En este caso los hijos pasan al padre del nodo.
- * Si no tiene padre, los hijos pasaran a ser padres.
- *
- * @v_node: Nodo que se quiere mover.
- * @v_new_parent: Padre al que se quiere mover el nodo.
- * @v_move: Se indica si se mueven los nodos.
- **/
-
- DECLARE v_parent INT;
-
- SELECT parent
- INTO v_parent
- FROM unary
- WHERE id = v_node;
-
- IF(v_move = TRUE) THEN
- UPDATE unary
- SET parent = v_parent
- WHERE parent = v_node;
- END IF;
-
- UPDATE unary
- SET parent = v_new_parent
- WHERE id = v_node;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/triggers/Conteo_ai.sql b/db/routines/vn2008/triggers/Conteo_afterInsert.sql
similarity index 96%
rename from db/routines/vn2008/triggers/Conteo_ai.sql
rename to db/routines/vn2008/triggers/Conteo_afterInsert.sql
index 5d8a0ef25..90f2a5edd 100644
--- a/db/routines/vn2008/triggers/Conteo_ai.sql
+++ b/db/routines/vn2008/triggers/Conteo_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`Conteo_ai`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`Conteo_afterInsert`
AFTER INSERT ON `Conteo`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn2008/triggers/account_conciliacion_BEFORE_INSERT.sql b/db/routines/vn2008/triggers/account_conciliacion_beforeInsert.sql
similarity index 92%
rename from db/routines/vn2008/triggers/account_conciliacion_BEFORE_INSERT.sql
rename to db/routines/vn2008/triggers/account_conciliacion_beforeInsert.sql
index 01c8af36e..fb6283e1a 100644
--- a/db/routines/vn2008/triggers/account_conciliacion_BEFORE_INSERT.sql
+++ b/db/routines/vn2008/triggers/account_conciliacion_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`account_conciliacion_BEFORE_INSERT`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`account_conciliacion_beforeInsert`
BEFORE INSERT ON `account_conciliacion`
FOR EACH ROW
set new.id_calculated = replace(
diff --git a/db/routines/vn2008/triggers/agency_hour_AFTER_UPDATE.sql b/db/routines/vn2008/triggers/agency_hour_afterUpdate.sql
similarity index 95%
rename from db/routines/vn2008/triggers/agency_hour_AFTER_UPDATE.sql
rename to db/routines/vn2008/triggers/agency_hour_afterUpdate.sql
index fb958c165..81996137b 100644
--- a/db/routines/vn2008/triggers/agency_hour_AFTER_UPDATE.sql
+++ b/db/routines/vn2008/triggers/agency_hour_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_AFTER_UPDATE`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_afterUpdate`
AFTER UPDATE ON `agency_hour`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn2008/triggers/agency_hourBeforeInsert.sql b/db/routines/vn2008/triggers/agency_hour_beforeInsert.sql
similarity index 96%
rename from db/routines/vn2008/triggers/agency_hourBeforeInsert.sql
rename to db/routines/vn2008/triggers/agency_hour_beforeInsert.sql
index f4ea375c5..a6007934e 100644
--- a/db/routines/vn2008/triggers/agency_hourBeforeInsert.sql
+++ b/db/routines/vn2008/triggers/agency_hour_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hourBeforeInsert`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_beforeInsert`
BEFORE INSERT ON `agency_hour`
FOR EACH ROW
BEGIN
diff --git a/db/routines/vn2008/triggers/awb_recibida_ad.sql b/db/routines/vn2008/triggers/awb_recibida_afterDelete.sql
similarity index 94%
rename from db/routines/vn2008/triggers/awb_recibida_ad.sql
rename to db/routines/vn2008/triggers/awb_recibida_afterDelete.sql
index e33d7fd3c..6a3380b8f 100644
--- a/db/routines/vn2008/triggers/awb_recibida_ad.sql
+++ b/db/routines/vn2008/triggers/awb_recibida_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`awb_recibida_ad`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`awb_recibida_afterDelete`
AFTER DELETE ON `awb_recibida`
FOR EACH ROW
IF (SELECT COUNT(*) FROM recibida_iva where recibida_id = OLD.recibida_id) = 0
diff --git a/db/routines/vn2008/triggers/movement_label_au.sql b/db/routines/vn2008/triggers/movement_label_afterUpdate.sql
similarity index 92%
rename from db/routines/vn2008/triggers/movement_label_au.sql
rename to db/routines/vn2008/triggers/movement_label_afterUpdate.sql
index 5f9561e15..364568fb3 100644
--- a/db/routines/vn2008/triggers/movement_label_au.sql
+++ b/db/routines/vn2008/triggers/movement_label_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`movement_label_au`
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`movement_label_afterUpdate`
AFTER UPDATE ON `movement_label`
FOR EACH ROW
IF NEW.stem >= (SELECT Cantidad FROM Movimientos WHERE Id_Movimiento = NEW.Id_Movimiento) THEN
diff --git a/db/routines/vn2008/views/client_observation.sql b/db/routines/vn2008/views/client_observation.sql
deleted file mode 100644
index 7cd357b4e..000000000
--- a/db/routines/vn2008/views/client_observation.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`client_observation`
-AS SELECT `co`.`id` AS `client_observation_id`,
- `co`.`clientFk` AS `Id_Cliente`,
- `co`.`workerFk` AS `Id_Trabajador`,
- `co`.`text` AS `text`,
- `co`.`created` AS `odbc_date`
-FROM `vn`.`clientObservation` `co`
diff --git a/db/routines/vn2008/views/clientes_gestdoc.sql b/db/routines/vn2008/views/clientes_gestdoc.sql
deleted file mode 100644
index e711fded4..000000000
--- a/db/routines/vn2008/views/clientes_gestdoc.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`clientes_gestdoc`
-AS SELECT `cd`.`clientFk` AS `Id_Cliente`,
- `cd`.`dmsFk` AS `gest_doc_id`
-FROM `vn`.`clientDms` `cd`
diff --git a/db/routines/vn2008/views/clientes_regalos_enc.sql b/db/routines/vn2008/views/clientes_regalos_enc.sql
deleted file mode 100644
index b8ed6fec2..000000000
--- a/db/routines/vn2008/views/clientes_regalos_enc.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`clientes_regalos_enc`
-AS SELECT `cpg`.`clientFk` AS `Id_Cliente`,
- `cpg`.`giftFk` AS `Id_Regalo`,
- `cpg`.`added` AS `odbc_date`
-FROM `vn`.`clientPackagingGifts` `cpg`
diff --git a/db/routines/vn2008/views/clientes_regalos_lista_enc.sql b/db/routines/vn2008/views/clientes_regalos_lista_enc.sql
deleted file mode 100644
index e129776b5..000000000
--- a/db/routines/vn2008/views/clientes_regalos_lista_enc.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`clientes_regalos_lista_enc`
-AS SELECT `pg`.`id` AS `Id_Regalo`,
- `pg`.`description` AS `Descripcion`,
- `pg`.`photo` AS `foto`,
- IF(
- `util`.`VN_CURDATE`() BETWEEN `pg`.`started` AND `pg`.`ended`,
- 1,
- 0
- ) AS `activo`,
- `pg`.`started` AS `datstart`,
- `pg`.`ended` AS `datend`,
- IFNULL(`pg`.`warehouseFk`, 0) AS `warehouse_id`,
- IFNULL(`pg`.`provinceFk`, 0) AS `province_id`,
- IFNULL(`pg`.`countryFk`, 0) AS `countryFk`
-FROM `vn`.`packagingGifts` `pg`
diff --git a/db/routines/vn2008/views/clientes_tipo.sql b/db/routines/vn2008/views/clientes_tipo.sql
deleted file mode 100644
index 130dceb65..000000000
--- a/db/routines/vn2008/views/clientes_tipo.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`clientes_tipo`
-AS SELECT `ct`.`id` AS `clientes_tipo_id`,
- `ct`.`code` AS `code`,
- `ct`.`type` AS `tipo`,
- `ct`.`isCreatedAsServed` AS `isCreatedAsServed`
-FROM `vn`.`clientType` `ct`
diff --git a/db/routines/vn2008/views/cooler_path_detail.sql b/db/routines/vn2008/views/cooler_path_detail.sql
deleted file mode 100644
index 97b234186..000000000
--- a/db/routines/vn2008/views/cooler_path_detail.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`cooler_path_detail`
-AS SELECT `cpd`.`id` AS `cooler_path_detail_id`,
- `cpd`.`coolerPathFk` AS `cooler_path_id`,
- `cpd`.`hallway` AS `pasillo`
-FROM `vn`.`coolerPathDetail` `cpd`
diff --git a/db/routines/vn2008/views/credit.sql b/db/routines/vn2008/views/credit.sql
deleted file mode 100644
index 233e9dc1a..000000000
--- a/db/routines/vn2008/views/credit.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`credit`
-AS SELECT `c`.`id` AS `id`,
- `c`.`clientFk` AS `Id_Cliente`,
- `c`.`workerFk` AS `Id_Trabajador`,
- `c`.`amount` AS `amount`,
- `c`.`created` AS `odbc_date`
-FROM `vn`.`clientCredit` `c`
diff --git a/db/routines/vn2008/views/escritos_det.sql b/db/routines/vn2008/views/escritos_det.sql
deleted file mode 100644
index 46b6db506..000000000
--- a/db/routines/vn2008/views/escritos_det.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`escritos_det`
-AS SELECT `cs`.`id` AS `id`,
- `cs`.`clientFk` AS `Id_Cliente`,
- `cs`.`typeFk` AS `escritos_id`,
- `cs`.`created` AS `fecha`,
- `cs`.`workerFk` AS `Id_Trabajador`,
- `cs`.`userFk` AS `userFk`,
- `cs`.`companyFk` AS `empresa_id`,
- `cs`.`balance` AS `saldo`
-FROM `vn`.`clientSample` `cs`
diff --git a/db/routines/vn2008/views/gesttip.sql b/db/routines/vn2008/views/gesttip.sql
index 0c3befe1a..663e70617 100644
--- a/db/routines/vn2008/views/gesttip.sql
+++ b/db/routines/vn2008/views/gesttip.sql
@@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
VIEW `vn2008`.`gesttip`
AS SELECT `g`.`id` AS `id`,
`g`.`name` AS `tipo`,
- `g`.`path` AS `path`,
`g`.`readRoleFk` AS `readRoleFk`,
`g`.`writeRoleFk` AS `writeRoleFk`,
`g`.`code` AS `code`
diff --git a/db/routines/vn2008/views/iva_codigo.sql b/db/routines/vn2008/views/iva_codigo.sql
deleted file mode 100644
index 6bd811abe..000000000
--- a/db/routines/vn2008/views/iva_codigo.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`iva_codigo`
-AS SELECT `tc`.`id` AS `id`,
- `tc`.`dated` AS `fecha`,
- `tc`.`code` AS `codigo`,
- `tc`.`taxTypeFk` AS `iva_tipo_id`,
- `tc`.`rate` AS `iva`,
- `tc`.`equalizationTax` AS `recargo`,
- `tc`.`type` AS `tipo`,
- `tc`.`link` AS `link`,
- `tc`.`isActive` AS `isActive`,
- `tc`.`updated` AS `updated`,
- `tc`.`transactionCode` AS `transactionCode`
-FROM `vn`.`taxCode` `tc`
diff --git a/db/routines/vn2008/views/iva_group.sql b/db/routines/vn2008/views/iva_group.sql
deleted file mode 100644
index f4fc1e92e..000000000
--- a/db/routines/vn2008/views/iva_group.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`iva_group`
-AS SELECT `tc`.`id` AS `iva_group_id`,
- `tc`.`description` AS `description`,
- `tc`.`code` AS `code`
-FROM `vn`.`taxClass` `tc`
diff --git a/db/routines/vn2008/views/iva_group_codigo.sql b/db/routines/vn2008/views/iva_group_codigo.sql
deleted file mode 100644
index 86e72ebe9..000000000
--- a/db/routines/vn2008/views/iva_group_codigo.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`iva_group_codigo`
-AS SELECT `tcc`.`taxClassFk` AS `iva_group_id`,
- `tcc`.`effectived` AS `date`,
- `tcc`.`taxCodeFk` AS `iva_codigo_id`
-FROM `vn`.`taxClassCode` `tcc`
diff --git a/db/routines/vn2008/views/iva_tipo.sql b/db/routines/vn2008/views/iva_tipo.sql
deleted file mode 100644
index 0c62243e2..000000000
--- a/db/routines/vn2008/views/iva_tipo.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`iva_tipo`
-AS SELECT `tt`.`id` AS `id`,
- `tt`.`nickname` AS `alias`,
- `tt`.`isAccrued` AS `isAccrued`,
- `tt`.`serial` AS `serie_id`,
- `tt`.`TIPOOPE` AS `TIPOOPE`,
- `tt`.`description` AS `descripcion`,
- `tt`.`countryFk` AS `Id_Pais`
-FROM `vn`.`taxType` `tt`
diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql
index 9c98120ef..b55dbf9b6 100644
--- a/db/routines/vn2008/views/travel.sql
+++ b/db/routines/vn2008/views/travel.sql
@@ -16,5 +16,6 @@ AS SELECT `t`.`id` AS `id`,
`t`.`kg` AS `kg`,
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
`t`.`totalEntries` AS `totalEntries`,
- `t`.`appointment` AS `appointment`
+ `t`.`appointment` AS `appointment`,
+ `t`.`awbFk` AS `awbFk`
FROM `vn`.`travel` `t`
diff --git a/db/versions/10193-navyHydrangea/00-delete.sql b/db/versions/.archive/10193-navyHydrangea/00-delete.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/00-delete.sql
rename to db/versions/.archive/10193-navyHydrangea/00-delete.sql
diff --git a/db/versions/10193-navyHydrangea/01-botanicExport.sql b/db/versions/.archive/10193-navyHydrangea/01-botanicExport.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/01-botanicExport.sql
rename to db/versions/.archive/10193-navyHydrangea/01-botanicExport.sql
diff --git a/db/versions/10193-navyHydrangea/02-item.sql b/db/versions/.archive/10193-navyHydrangea/02-item.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/02-item.sql
rename to db/versions/.archive/10193-navyHydrangea/02-item.sql
diff --git a/db/versions/10193-navyHydrangea/03-autonomy.sql b/db/versions/.archive/10193-navyHydrangea/03-autonomy.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/03-autonomy.sql
rename to db/versions/.archive/10193-navyHydrangea/03-autonomy.sql
diff --git a/db/versions/10193-navyHydrangea/03-turn.sql b/db/versions/.archive/10193-navyHydrangea/03-turn.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/03-turn.sql
rename to db/versions/.archive/10193-navyHydrangea/03-turn.sql
diff --git a/db/versions/10193-navyHydrangea/04-country.sql b/db/versions/.archive/10193-navyHydrangea/04-country.sql
similarity index 100%
rename from db/versions/10193-navyHydrangea/04-country.sql
rename to db/versions/.archive/10193-navyHydrangea/04-country.sql
diff --git a/db/versions/10379-turquoiseOrchid/00-firstScript.sql b/db/versions/.archive/10379-turquoiseOrchid/00-firstScript.sql
similarity index 100%
rename from db/versions/10379-turquoiseOrchid/00-firstScript.sql
rename to db/versions/.archive/10379-turquoiseOrchid/00-firstScript.sql
diff --git a/db/versions/10384-limeLaurel/00-business_workcenterFk.sql b/db/versions/.archive/10384-limeLaurel/00-business_workcenterFk.sql
similarity index 100%
rename from db/versions/10384-limeLaurel/00-business_workcenterFk.sql
rename to db/versions/.archive/10384-limeLaurel/00-business_workcenterFk.sql
diff --git a/db/versions/10395-blueGalax/00-firstScript.sql b/db/versions/.archive/10395-blueGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10395-blueGalax/00-firstScript.sql
rename to db/versions/.archive/10395-blueGalax/00-firstScript.sql
diff --git a/db/versions/10396-grayRoebelini/00-firstScript.sql b/db/versions/.archive/10396-grayRoebelini/00-firstScript.sql
similarity index 100%
rename from db/versions/10396-grayRoebelini/00-firstScript.sql
rename to db/versions/.archive/10396-grayRoebelini/00-firstScript.sql
diff --git a/db/versions/10397-4848TicketsFloramondo/00-firstScript.sql b/db/versions/.archive/10397-4848TicketsFloramondo/00-firstScript.sql
similarity index 100%
rename from db/versions/10397-4848TicketsFloramondo/00-firstScript.sql
rename to db/versions/.archive/10397-4848TicketsFloramondo/00-firstScript.sql
diff --git a/db/versions/10399-blueErica/00-firstScript.sql b/db/versions/.archive/10399-blueErica/00-firstScript.sql
similarity index 100%
rename from db/versions/10399-blueErica/00-firstScript.sql
rename to db/versions/.archive/10399-blueErica/00-firstScript.sql
diff --git a/db/versions/10400-brownEucalyptus/00-firstScript.sql b/db/versions/.archive/10400-brownEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10400-brownEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10400-brownEucalyptus/00-firstScript.sql
diff --git a/db/versions/10402-orangeTulip/00-firstScript.sql b/db/versions/.archive/10402-orangeTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10402-orangeTulip/00-firstScript.sql
rename to db/versions/.archive/10402-orangeTulip/00-firstScript.sql
diff --git a/db/versions/10404-grayMedeola/00-firstScript.sql b/db/versions/.archive/10404-grayMedeola/00-firstScript.sql
similarity index 100%
rename from db/versions/10404-grayMedeola/00-firstScript.sql
rename to db/versions/.archive/10404-grayMedeola/00-firstScript.sql
diff --git a/db/versions/10405-orangeGalax/00-firstScript.sql b/db/versions/.archive/10405-orangeGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10405-orangeGalax/00-firstScript.sql
rename to db/versions/.archive/10405-orangeGalax/00-firstScript.sql
diff --git a/db/versions/10407-blueOak/00-firstScript.sql b/db/versions/.archive/10407-blueOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10407-blueOak/00-firstScript.sql
rename to db/versions/.archive/10407-blueOak/00-firstScript.sql
diff --git a/db/versions/10408-purpleIvy/00-firstScript.sql b/db/versions/.archive/10408-purpleIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10408-purpleIvy/00-firstScript.sql
rename to db/versions/.archive/10408-purpleIvy/00-firstScript.sql
diff --git a/db/versions/10409-brownSalal/00-firstScript.sql b/db/versions/.archive/10409-brownSalal/00-firstScript.sql
similarity index 100%
rename from db/versions/10409-brownSalal/00-firstScript.sql
rename to db/versions/.archive/10409-brownSalal/00-firstScript.sql
diff --git a/db/versions/10412-yellowCarnation/00-firstScript.sql b/db/versions/.archive/10412-yellowCarnation/00-firstScript.sql
similarity index 100%
rename from db/versions/10412-yellowCarnation/00-firstScript.sql
rename to db/versions/.archive/10412-yellowCarnation/00-firstScript.sql
diff --git a/db/versions/10413-whiteCymbidium/00-firstScript.sql b/db/versions/.archive/10413-whiteCymbidium/00-firstScript.sql
similarity index 100%
rename from db/versions/10413-whiteCymbidium/00-firstScript.sql
rename to db/versions/.archive/10413-whiteCymbidium/00-firstScript.sql
diff --git a/db/versions/10416-blueAsparagus/00-firstScript.sql b/db/versions/.archive/10416-blueAsparagus/00-firstScript.sql
similarity index 100%
rename from db/versions/10416-blueAsparagus/00-firstScript.sql
rename to db/versions/.archive/10416-blueAsparagus/00-firstScript.sql
diff --git a/db/versions/10420-goldenCataractarum/00-firstScript.sql b/db/versions/.archive/10420-goldenCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10420-goldenCataractarum/00-firstScript.sql
rename to db/versions/.archive/10420-goldenCataractarum/00-firstScript.sql
diff --git a/db/versions/10421-navyMonstera/00-firstScript.sql b/db/versions/.archive/10421-navyMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10421-navyMonstera/00-firstScript.sql
rename to db/versions/.archive/10421-navyMonstera/00-firstScript.sql
diff --git a/db/versions/10426-silverAsparagus/00-firstScript.sql b/db/versions/.archive/10426-silverAsparagus/00-firstScript.sql
similarity index 100%
rename from db/versions/10426-silverAsparagus/00-firstScript.sql
rename to db/versions/.archive/10426-silverAsparagus/00-firstScript.sql
diff --git a/db/versions/10428-wheatRose/00-firstScript.sql b/db/versions/.archive/10428-wheatRose/00-firstScript.sql
similarity index 100%
rename from db/versions/10428-wheatRose/00-firstScript.sql
rename to db/versions/.archive/10428-wheatRose/00-firstScript.sql
diff --git a/db/versions/10431-redCordyline/00-firstScript.sql b/db/versions/.archive/10431-redCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10431-redCordyline/00-firstScript.sql
rename to db/versions/.archive/10431-redCordyline/00-firstScript.sql
diff --git a/db/versions/10433-salmonAnthurium/00-firstScript.sql b/db/versions/.archive/10433-salmonAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10433-salmonAnthurium/00-firstScript.sql
rename to db/versions/.archive/10433-salmonAnthurium/00-firstScript.sql
diff --git a/db/versions/10434-grayTulip/00-firstScript.sql b/db/versions/.archive/10434-grayTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10434-grayTulip/00-firstScript.sql
rename to db/versions/.archive/10434-grayTulip/00-firstScript.sql
diff --git a/db/versions/10435-aquaGalax/00-firstScript.sql b/db/versions/.archive/10435-aquaGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10435-aquaGalax/00-firstScript.sql
rename to db/versions/.archive/10435-aquaGalax/00-firstScript.sql
diff --git a/db/versions/10436-tealPalmetto/00-createFkWorker.sql b/db/versions/.archive/10436-tealPalmetto/00-createFkWorker.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/00-createFkWorker.sql
rename to db/versions/.archive/10436-tealPalmetto/00-createFkWorker.sql
diff --git a/db/versions/10436-tealPalmetto/01-addStateToWorkerProductivity.sql b/db/versions/.archive/10436-tealPalmetto/01-addStateToWorkerProductivity.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/01-addStateToWorkerProductivity.sql
rename to db/versions/.archive/10436-tealPalmetto/01-addStateToWorkerProductivity.sql
diff --git a/db/versions/10436-tealPalmetto/02-DeprecateVnSaleTrackingState.sql b/db/versions/.archive/10436-tealPalmetto/02-DeprecateVnSaleTrackingState.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/02-DeprecateVnSaleTrackingState.sql
rename to db/versions/.archive/10436-tealPalmetto/02-DeprecateVnSaleTrackingState.sql
diff --git a/db/versions/10436-tealPalmetto/03-DeprecateColumnVnSaleTrackingActionFk.sql b/db/versions/.archive/10436-tealPalmetto/03-DeprecateColumnVnSaleTrackingActionFk.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/03-DeprecateColumnVnSaleTrackingActionFk.sql
rename to db/versions/.archive/10436-tealPalmetto/03-DeprecateColumnVnSaleTrackingActionFk.sql
diff --git a/db/versions/10436-tealPalmetto/04-DropSchemaVnControl.sql b/db/versions/.archive/10436-tealPalmetto/04-DropSchemaVnControl.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/04-DropSchemaVnControl.sql
rename to db/versions/.archive/10436-tealPalmetto/04-DropSchemaVnControl.sql
diff --git a/db/versions/10436-tealPalmetto/05-RemoveFkWorkerProductivity.sql b/db/versions/.archive/10436-tealPalmetto/05-RemoveFkWorkerProductivity.sql
similarity index 100%
rename from db/versions/10436-tealPalmetto/05-RemoveFkWorkerProductivity.sql
rename to db/versions/.archive/10436-tealPalmetto/05-RemoveFkWorkerProductivity.sql
diff --git a/db/versions/10439-greenTulip/00-fixRole.sql b/db/versions/.archive/10439-greenTulip/00-fixRole.sql
similarity index 100%
rename from db/versions/10439-greenTulip/00-fixRole.sql
rename to db/versions/.archive/10439-greenTulip/00-fixRole.sql
diff --git a/db/versions/10440-grayDendro/00-firstScript.sql b/db/versions/.archive/10440-grayDendro/00-firstScript.sql
similarity index 100%
rename from db/versions/10440-grayDendro/00-firstScript.sql
rename to db/versions/.archive/10440-grayDendro/00-firstScript.sql
diff --git a/db/versions/10444-crimsonBamboo/00-firstScript.sql b/db/versions/.archive/10444-crimsonBamboo/00-firstScript.sql
similarity index 100%
rename from db/versions/10444-crimsonBamboo/00-firstScript.sql
rename to db/versions/.archive/10444-crimsonBamboo/00-firstScript.sql
diff --git a/db/versions/10445-orangeMoss/00-firstScript.sql b/db/versions/.archive/10445-orangeMoss/00-firstScript.sql
similarity index 100%
rename from db/versions/10445-orangeMoss/00-firstScript.sql
rename to db/versions/.archive/10445-orangeMoss/00-firstScript.sql
diff --git a/db/versions/10448-wheatChrysanthemum/00-firstScript.sql b/db/versions/.archive/10448-wheatChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10448-wheatChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10448-wheatChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10450-blackIvy/00-firstScript.sql b/db/versions/.archive/10450-blackIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10450-blackIvy/00-firstScript.sql
rename to db/versions/.archive/10450-blackIvy/00-firstScript.sql
diff --git a/db/versions/10451-salmonOak/00-firstScript.sql b/db/versions/.archive/10451-salmonOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10451-salmonOak/00-firstScript.sql
rename to db/versions/.archive/10451-salmonOak/00-firstScript.sql
diff --git a/db/versions/10452-redEucalyptus/00-firstScript.sql b/db/versions/.archive/10452-redEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10452-redEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10452-redEucalyptus/00-firstScript.sql
diff --git a/db/versions/10453-aquaMedeola/00-firstScript.sql b/db/versions/.archive/10453-aquaMedeola/00-firstScript.sql
similarity index 100%
rename from db/versions/10453-aquaMedeola/00-firstScript.sql
rename to db/versions/.archive/10453-aquaMedeola/00-firstScript.sql
diff --git a/db/versions/10454-bronzeMoss/00-firstScript.sql b/db/versions/.archive/10454-bronzeMoss/00-firstScript.sql
similarity index 100%
rename from db/versions/10454-bronzeMoss/00-firstScript.sql
rename to db/versions/.archive/10454-bronzeMoss/00-firstScript.sql
diff --git a/db/versions/10455-blackGerbera/00-firstScript.sql b/db/versions/.archive/10455-blackGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10455-blackGerbera/00-firstScript.sql
rename to db/versions/.archive/10455-blackGerbera/00-firstScript.sql
diff --git a/db/versions/10456-greenArborvitae/00-firstScript.sql b/db/versions/.archive/10456-greenArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10456-greenArborvitae/00-firstScript.sql
rename to db/versions/.archive/10456-greenArborvitae/00-firstScript.sql
diff --git a/db/versions/10457-crimsonTulip/00-firstScript.sql b/db/versions/.archive/10457-crimsonTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10457-crimsonTulip/00-firstScript.sql
rename to db/versions/.archive/10457-crimsonTulip/00-firstScript.sql
diff --git a/db/versions/10458-orangePalmetto/00-firstScript.sql b/db/versions/.archive/10458-orangePalmetto/00-firstScript.sql
similarity index 100%
rename from db/versions/10458-orangePalmetto/00-firstScript.sql
rename to db/versions/.archive/10458-orangePalmetto/00-firstScript.sql
diff --git a/db/versions/10459-chocolateMedeola/00-alterTableUtilConfig.sql b/db/versions/.archive/10459-chocolateMedeola/00-alterTableUtilConfig.sql
similarity index 100%
rename from db/versions/10459-chocolateMedeola/00-alterTableUtilConfig.sql
rename to db/versions/.archive/10459-chocolateMedeola/00-alterTableUtilConfig.sql
diff --git a/db/versions/10459-chocolateMedeola/01-createFunctionCurdate.sql b/db/versions/.archive/10459-chocolateMedeola/01-createFunctionCurdate.sql
similarity index 100%
rename from db/versions/10459-chocolateMedeola/01-createFunctionCurdate.sql
rename to db/versions/.archive/10459-chocolateMedeola/01-createFunctionCurdate.sql
diff --git a/db/versions/10459-chocolateMedeola/02-createFunctionMockTime.sql b/db/versions/.archive/10459-chocolateMedeola/02-createFunctionMockTime.sql
similarity index 100%
rename from db/versions/10459-chocolateMedeola/02-createFunctionMockTime.sql
rename to db/versions/.archive/10459-chocolateMedeola/02-createFunctionMockTime.sql
diff --git a/db/versions/10459-chocolateMedeola/03-createFunctionMockTimeBase.sql b/db/versions/.archive/10459-chocolateMedeola/03-createFunctionMockTimeBase.sql
similarity index 100%
rename from db/versions/10459-chocolateMedeola/03-createFunctionMockTimeBase.sql
rename to db/versions/.archive/10459-chocolateMedeola/03-createFunctionMockTimeBase.sql
diff --git a/db/versions/10459-chocolateMedeola/04-createFunctionNow.sql b/db/versions/.archive/10459-chocolateMedeola/04-createFunctionNow.sql
similarity index 100%
rename from db/versions/10459-chocolateMedeola/04-createFunctionNow.sql
rename to db/versions/.archive/10459-chocolateMedeola/04-createFunctionNow.sql
diff --git a/db/versions/10460-crimsonDendro/00-firstScript.sql b/db/versions/.archive/10460-crimsonDendro/00-firstScript.sql
similarity index 100%
rename from db/versions/10460-crimsonDendro/00-firstScript.sql
rename to db/versions/.archive/10460-crimsonDendro/00-firstScript.sql
diff --git a/db/versions/10461-filtroPorTipos/00-firstScript.sql b/db/versions/.archive/10461-filtroPorTipos/00-firstScript.sql
similarity index 100%
rename from db/versions/10461-filtroPorTipos/00-firstScript.sql
rename to db/versions/.archive/10461-filtroPorTipos/00-firstScript.sql
diff --git a/db/versions/10463-wheatMonstera/00-firstScript.sql b/db/versions/.archive/10463-wheatMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10463-wheatMonstera/00-firstScript.sql
rename to db/versions/.archive/10463-wheatMonstera/00-firstScript.sql
diff --git a/db/versions/10468-goldenGerbera/00-firstScript.sql b/db/versions/.archive/10468-goldenGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10468-goldenGerbera/00-firstScript.sql
rename to db/versions/.archive/10468-goldenGerbera/00-firstScript.sql
diff --git a/db/versions/10469-bronzeEucalyptus/00-firstScript.sql b/db/versions/.archive/10469-bronzeEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10469-bronzeEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10469-bronzeEucalyptus/00-firstScript.sql
diff --git a/db/versions/10470-notaUltimoUsuario/00-firstScript.sql b/db/versions/.archive/10470-notaUltimoUsuario/00-firstScript.sql
similarity index 100%
rename from db/versions/10470-notaUltimoUsuario/00-firstScript.sql
rename to db/versions/.archive/10470-notaUltimoUsuario/00-firstScript.sql
diff --git a/db/versions/10471-orangeMastic/00-firstScript.sql b/db/versions/.archive/10471-orangeMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10471-orangeMastic/00-firstScript.sql
rename to db/versions/.archive/10471-orangeMastic/00-firstScript.sql
diff --git a/db/versions/10472-bronzeOak/00-firstScript.sql b/db/versions/.archive/10472-bronzeOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10472-bronzeOak/00-firstScript.sql
rename to db/versions/.archive/10472-bronzeOak/00-firstScript.sql
diff --git a/db/versions/10477-goldenDendro/00-firstScript.sql b/db/versions/.archive/10477-goldenDendro/00-firstScript.sql
similarity index 100%
rename from db/versions/10477-goldenDendro/00-firstScript.sql
rename to db/versions/.archive/10477-goldenDendro/00-firstScript.sql
diff --git a/db/versions/10478-tealGalax/00-dropBasket.sql b/db/versions/.archive/10478-tealGalax/00-dropBasket.sql
similarity index 100%
rename from db/versions/10478-tealGalax/00-dropBasket.sql
rename to db/versions/.archive/10478-tealGalax/00-dropBasket.sql
diff --git a/db/versions/10478-tealGalax/00-firstScript.sql b/db/versions/.archive/10478-tealGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10478-tealGalax/00-firstScript.sql
rename to db/versions/.archive/10478-tealGalax/00-firstScript.sql
diff --git a/db/versions/10478-tealGalax/01-orderConfigured.sql b/db/versions/.archive/10478-tealGalax/01-orderConfigured.sql
similarity index 100%
rename from db/versions/10478-tealGalax/01-orderConfigured.sql
rename to db/versions/.archive/10478-tealGalax/01-orderConfigured.sql
diff --git a/db/versions/10478-tealGalax/02-configuredUpdate.sql b/db/versions/.archive/10478-tealGalax/02-configuredUpdate.sql
similarity index 100%
rename from db/versions/10478-tealGalax/02-configuredUpdate.sql
rename to db/versions/.archive/10478-tealGalax/02-configuredUpdate.sql
diff --git a/db/versions/10478-tealGalax/99-privileges.sql b/db/versions/.archive/10478-tealGalax/99-privileges.sql
similarity index 100%
rename from db/versions/10478-tealGalax/99-privileges.sql
rename to db/versions/.archive/10478-tealGalax/99-privileges.sql
diff --git a/db/versions/10480-blueTulip/00-firstScript.sql b/db/versions/.archive/10480-blueTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10480-blueTulip/00-firstScript.sql
rename to db/versions/.archive/10480-blueTulip/00-firstScript.sql
diff --git a/db/versions/10481-brownAspidistra/00-firstScript.sql b/db/versions/.archive/10481-brownAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10481-brownAspidistra/00-firstScript.sql
rename to db/versions/.archive/10481-brownAspidistra/00-firstScript.sql
diff --git a/db/versions/10482-blueMastic/00-firstScript.sql b/db/versions/.archive/10482-blueMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10482-blueMastic/00-firstScript.sql
rename to db/versions/.archive/10482-blueMastic/00-firstScript.sql
diff --git a/db/versions/10485-aquaCamellia/00-firstScript.sql b/db/versions/.archive/10485-aquaCamellia/00-firstScript.sql
similarity index 100%
rename from db/versions/10485-aquaCamellia/00-firstScript.sql
rename to db/versions/.archive/10485-aquaCamellia/00-firstScript.sql
diff --git a/db/versions/10488-grayCarnation/00-firstScript.sql b/db/versions/.archive/10488-grayCarnation/00-firstScript.sql
similarity index 100%
rename from db/versions/10488-grayCarnation/00-firstScript.sql
rename to db/versions/.archive/10488-grayCarnation/00-firstScript.sql
diff --git a/db/versions/10491-orangeDracena/00-firstScript.sql b/db/versions/.archive/10491-orangeDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10491-orangeDracena/00-firstScript.sql
rename to db/versions/.archive/10491-orangeDracena/00-firstScript.sql
diff --git a/db/versions/10492-wheatIvy/00-firstScript.sql b/db/versions/.archive/10492-wheatIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10492-wheatIvy/00-firstScript.sql
rename to db/versions/.archive/10492-wheatIvy/00-firstScript.sql
diff --git a/db/versions/10493-purpleAnthurium/00-firstScript.sql b/db/versions/.archive/10493-purpleAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10493-purpleAnthurium/00-firstScript.sql
rename to db/versions/.archive/10493-purpleAnthurium/00-firstScript.sql
diff --git a/db/versions/10495-whiteFern/00-firstScript.sql b/db/versions/.archive/10495-whiteFern/00-firstScript.sql
similarity index 100%
rename from db/versions/10495-whiteFern/00-firstScript.sql
rename to db/versions/.archive/10495-whiteFern/00-firstScript.sql
diff --git a/db/versions/10498-redAspidistra/00-firstScript.sql b/db/versions/.archive/10498-redAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10498-redAspidistra/00-firstScript.sql
rename to db/versions/.archive/10498-redAspidistra/00-firstScript.sql
diff --git a/db/versions/10500-limeChrysanthemum/00-firstScript.sql b/db/versions/.archive/10500-limeChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10500-limeChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10500-limeChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10500-limeRaphis/00-firstScript.sql b/db/versions/.archive/10500-limeRaphis/00-firstScript.sql
similarity index 100%
rename from db/versions/10500-limeRaphis/00-firstScript.sql
rename to db/versions/.archive/10500-limeRaphis/00-firstScript.sql
diff --git a/db/versions/10501-orangeAnthurium/00-firstScript.sql b/db/versions/.archive/10501-orangeAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10501-orangeAnthurium/00-firstScript.sql
rename to db/versions/.archive/10501-orangeAnthurium/00-firstScript.sql
diff --git a/db/versions/10502-azureCarnation/00-firstScript.sql b/db/versions/.archive/10502-azureCarnation/00-firstScript.sql
similarity index 100%
rename from db/versions/10502-azureCarnation/00-firstScript.sql
rename to db/versions/.archive/10502-azureCarnation/00-firstScript.sql
diff --git a/db/versions/10502-yellowCordyline/00-firstScript.sql b/db/versions/.archive/10502-yellowCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10502-yellowCordyline/00-firstScript.sql
rename to db/versions/.archive/10502-yellowCordyline/00-firstScript.sql
diff --git a/db/versions/10504-maroonPalmetto/00-firstScript.sql b/db/versions/.archive/10504-maroonPalmetto/00-firstScript.sql
similarity index 100%
rename from db/versions/10504-maroonPalmetto/00-firstScript.sql
rename to db/versions/.archive/10504-maroonPalmetto/00-firstScript.sql
diff --git a/db/versions/10506-aquaPaniculata/01-firstScript.sql b/db/versions/.archive/10506-aquaPaniculata/01-firstScript.sql
similarity index 100%
rename from db/versions/10506-aquaPaniculata/01-firstScript.sql
rename to db/versions/.archive/10506-aquaPaniculata/01-firstScript.sql
diff --git a/db/versions/10506-aquaPaniculata/02-secondScript.sql b/db/versions/.archive/10506-aquaPaniculata/02-secondScript.sql
similarity index 100%
rename from db/versions/10506-aquaPaniculata/02-secondScript.sql
rename to db/versions/.archive/10506-aquaPaniculata/02-secondScript.sql
diff --git a/db/versions/10506-aquaPaniculata/03-thirdScript.sql b/db/versions/.archive/10506-aquaPaniculata/03-thirdScript.sql
similarity index 100%
rename from db/versions/10506-aquaPaniculata/03-thirdScript.sql
rename to db/versions/.archive/10506-aquaPaniculata/03-thirdScript.sql
diff --git a/db/versions/10506-crimsonRoebelini/00-firstScript.sql b/db/versions/.archive/10506-crimsonRoebelini/00-firstScript.sql
similarity index 100%
rename from db/versions/10506-crimsonRoebelini/00-firstScript.sql
rename to db/versions/.archive/10506-crimsonRoebelini/00-firstScript.sql
diff --git a/db/versions/10507-greenAspidistra/00-firstScript.sql b/db/versions/.archive/10507-greenAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10507-greenAspidistra/00-firstScript.sql
rename to db/versions/.archive/10507-greenAspidistra/00-firstScript.sql
diff --git a/db/versions/10508-maroonMonstera/00-firstScript.sql b/db/versions/.archive/10508-maroonMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10508-maroonMonstera/00-firstScript.sql
rename to db/versions/.archive/10508-maroonMonstera/00-firstScript.sql
diff --git a/db/versions/10510-salmonMoss/00-dropBusinessFk.sql b/db/versions/.archive/10510-salmonMoss/00-dropBusinessFk.sql
similarity index 100%
rename from db/versions/10510-salmonMoss/00-dropBusinessFk.sql
rename to db/versions/.archive/10510-salmonMoss/00-dropBusinessFk.sql
diff --git a/db/versions/10510-salmonMoss/01-createTableProfessionalCategory.sql b/db/versions/.archive/10510-salmonMoss/01-createTableProfessionalCategory.sql
similarity index 100%
rename from db/versions/10510-salmonMoss/01-createTableProfessionalCategory.sql
rename to db/versions/.archive/10510-salmonMoss/01-createTableProfessionalCategory.sql
diff --git a/db/versions/10510-salmonMoss/02-exportToNewTable.sql b/db/versions/.archive/10510-salmonMoss/02-exportToNewTable.sql
similarity index 100%
rename from db/versions/10510-salmonMoss/02-exportToNewTable.sql
rename to db/versions/.archive/10510-salmonMoss/02-exportToNewTable.sql
diff --git a/db/versions/10510-salmonMoss/03-RecreateFK.sql b/db/versions/.archive/10510-salmonMoss/03-RecreateFK.sql
similarity index 100%
rename from db/versions/10510-salmonMoss/03-RecreateFK.sql
rename to db/versions/.archive/10510-salmonMoss/03-RecreateFK.sql
diff --git a/db/versions/10510-salmonMoss/04-kkPostgresqlTable.sql b/db/versions/.archive/10510-salmonMoss/04-kkPostgresqlTable.sql
similarity index 100%
rename from db/versions/10510-salmonMoss/04-kkPostgresqlTable.sql
rename to db/versions/.archive/10510-salmonMoss/04-kkPostgresqlTable.sql
diff --git a/db/versions/10511-chocolateChrysanthemum/00-firstScript.sql b/db/versions/.archive/10511-chocolateChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10511-chocolateChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10511-chocolateChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10512-purpleRoebelini/00-firstScript.sql b/db/versions/.archive/10512-purpleRoebelini/00-firstScript.sql
similarity index 100%
rename from db/versions/10512-purpleRoebelini/00-firstScript.sql
rename to db/versions/.archive/10512-purpleRoebelini/00-firstScript.sql
diff --git a/db/versions/10513-aquaCataractarum/00-firstScript.sql b/db/versions/.archive/10513-aquaCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10513-aquaCataractarum/00-firstScript.sql
rename to db/versions/.archive/10513-aquaCataractarum/00-firstScript.sql
diff --git a/db/versions/10514-silverAspidistra/00-firstScript.sql b/db/versions/.archive/10514-silverAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10514-silverAspidistra/00-firstScript.sql
rename to db/versions/.archive/10514-silverAspidistra/00-firstScript.sql
diff --git a/db/versions/10516-crimsonSalal/00-firstScript.sql b/db/versions/.archive/10516-crimsonSalal/00-firstScript.sql
similarity index 100%
rename from db/versions/10516-crimsonSalal/00-firstScript.sql
rename to db/versions/.archive/10516-crimsonSalal/00-firstScript.sql
diff --git a/db/versions/10521-salmonLilium/00-firstScript.sql b/db/versions/.archive/10521-salmonLilium/00-firstScript.sql
similarity index 100%
rename from db/versions/10521-salmonLilium/00-firstScript.sql
rename to db/versions/.archive/10521-salmonLilium/00-firstScript.sql
diff --git a/db/versions/10522-yellowMedeola/00-firstScript.sql b/db/versions/.archive/10522-yellowMedeola/00-firstScript.sql
similarity index 100%
rename from db/versions/10522-yellowMedeola/00-firstScript.sql
rename to db/versions/.archive/10522-yellowMedeola/00-firstScript.sql
diff --git a/db/versions/10523-tealCataractarum/00-firstScript.sql b/db/versions/.archive/10523-tealCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10523-tealCataractarum/00-firstScript.sql
rename to db/versions/.archive/10523-tealCataractarum/00-firstScript.sql
diff --git a/db/versions/10524-limeCordyline/00-firstScript.sql b/db/versions/.archive/10524-limeCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10524-limeCordyline/00-firstScript.sql
rename to db/versions/.archive/10524-limeCordyline/00-firstScript.sql
diff --git a/db/versions/10524-limeCordyline/01-rateEditorFk.sql b/db/versions/.archive/10524-limeCordyline/01-rateEditorFk.sql
similarity index 100%
rename from db/versions/10524-limeCordyline/01-rateEditorFk.sql
rename to db/versions/.archive/10524-limeCordyline/01-rateEditorFk.sql
diff --git a/db/versions/10525-yellowRuscus/00-firstScript.sql b/db/versions/.archive/10525-yellowRuscus/00-firstScript.sql
similarity index 100%
rename from db/versions/10525-yellowRuscus/00-firstScript.sql
rename to db/versions/.archive/10525-yellowRuscus/00-firstScript.sql
diff --git a/db/versions/10526-goldenOak/00-firstScript.sql b/db/versions/.archive/10526-goldenOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10526-goldenOak/00-firstScript.sql
rename to db/versions/.archive/10526-goldenOak/00-firstScript.sql
diff --git a/db/versions/10528-orangeRoebelini/00-firstScript.sql b/db/versions/.archive/10528-orangeRoebelini/00-firstScript.sql
similarity index 100%
rename from db/versions/10528-orangeRoebelini/00-firstScript.sql
rename to db/versions/.archive/10528-orangeRoebelini/00-firstScript.sql
diff --git a/db/versions/10530-orangeCyca/00-firstScript.sql b/db/versions/.archive/10530-orangeCyca/00-firstScript.sql
similarity index 100%
rename from db/versions/10530-orangeCyca/00-firstScript.sql
rename to db/versions/.archive/10530-orangeCyca/00-firstScript.sql
diff --git a/db/versions/10531-chocolateFern/00-firstScript.sql b/db/versions/.archive/10531-chocolateFern/00-firstScript.sql
similarity index 100%
rename from db/versions/10531-chocolateFern/00-firstScript.sql
rename to db/versions/.archive/10531-chocolateFern/00-firstScript.sql
diff --git a/db/versions/10532-tealTulip/00-firstScript.sql b/db/versions/.archive/10532-tealTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10532-tealTulip/00-firstScript.sql
rename to db/versions/.archive/10532-tealTulip/00-firstScript.sql
diff --git a/db/versions/10533-crimsonLaurel/00-firstScript.sql b/db/versions/.archive/10533-crimsonLaurel/00-firstScript.sql
similarity index 100%
rename from db/versions/10533-crimsonLaurel/00-firstScript.sql
rename to db/versions/.archive/10533-crimsonLaurel/00-firstScript.sql
diff --git a/db/versions/10537-grayCordyline/00-firstScript.sql b/db/versions/.archive/10537-grayCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10537-grayCordyline/00-firstScript.sql
rename to db/versions/.archive/10537-grayCordyline/00-firstScript.sql
diff --git a/db/versions/10538-silverAspidistra/00-createChronopostConfig.sql b/db/versions/.archive/10538-silverAspidistra/00-createChronopostConfig.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/00-createChronopostConfig.sql
rename to db/versions/.archive/10538-silverAspidistra/00-createChronopostConfig.sql
diff --git a/db/versions/10538-silverAspidistra/01-createChronopostService.sql b/db/versions/.archive/10538-silverAspidistra/01-createChronopostService.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/01-createChronopostService.sql
rename to db/versions/.archive/10538-silverAspidistra/01-createChronopostService.sql
diff --git a/db/versions/10538-silverAspidistra/02-createChronopostExpedition.sql b/db/versions/.archive/10538-silverAspidistra/02-createChronopostExpedition.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/02-createChronopostExpedition.sql
rename to db/versions/.archive/10538-silverAspidistra/02-createChronopostExpedition.sql
diff --git a/db/versions/10538-silverAspidistra/03-createChronopostSenderAddress.sql b/db/versions/.archive/10538-silverAspidistra/03-createChronopostSenderAddress.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/03-createChronopostSenderAddress.sql
rename to db/versions/.archive/10538-silverAspidistra/03-createChronopostSenderAddress.sql
diff --git a/db/versions/10538-silverAspidistra/04-addgrantPrivilegies.sql b/db/versions/.archive/10538-silverAspidistra/04-addgrantPrivilegies.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/04-addgrantPrivilegies.sql
rename to db/versions/.archive/10538-silverAspidistra/04-addgrantPrivilegies.sql
diff --git a/db/versions/10538-silverAspidistra/05-updateChronopostConfig.sql b/db/versions/.archive/10538-silverAspidistra/05-updateChronopostConfig.sql
similarity index 100%
rename from db/versions/10538-silverAspidistra/05-updateChronopostConfig.sql
rename to db/versions/.archive/10538-silverAspidistra/05-updateChronopostConfig.sql
diff --git a/db/versions/10539-pinkPalmetto/00-firstScript.sql b/db/versions/.archive/10539-pinkPalmetto/00-firstScript.sql
similarity index 100%
rename from db/versions/10539-pinkPalmetto/00-firstScript.sql
rename to db/versions/.archive/10539-pinkPalmetto/00-firstScript.sql
diff --git a/db/versions/10540-bronzeOrchid/00-firstScript.sql b/db/versions/.archive/10540-bronzeOrchid/00-firstScript.sql
similarity index 100%
rename from db/versions/10540-bronzeOrchid/00-firstScript.sql
rename to db/versions/.archive/10540-bronzeOrchid/00-firstScript.sql
diff --git a/db/versions/10545-maroonDracena/00-firstScript.sql b/db/versions/.archive/10545-maroonDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10545-maroonDracena/00-firstScript.sql
rename to db/versions/.archive/10545-maroonDracena/00-firstScript.sql
diff --git a/db/versions/10546-redOak/00-firstScript.sql b/db/versions/.archive/10546-redOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10546-redOak/00-firstScript.sql
rename to db/versions/.archive/10546-redOak/00-firstScript.sql
diff --git a/db/versions/10547-aquaDendro/00-firstScript.sql b/db/versions/.archive/10547-aquaDendro/00-firstScript.sql
similarity index 100%
rename from db/versions/10547-aquaDendro/00-firstScript.sql
rename to db/versions/.archive/10547-aquaDendro/00-firstScript.sql
diff --git a/db/versions/10549-goldenHydrangea/00-updateUpdateLog.sql b/db/versions/.archive/10549-goldenHydrangea/00-updateUpdateLog.sql
similarity index 100%
rename from db/versions/10549-goldenHydrangea/00-updateUpdateLog.sql
rename to db/versions/.archive/10549-goldenHydrangea/00-updateUpdateLog.sql
diff --git a/db/versions/10549-goldenHydrangea/01-updateInsertLog.sql b/db/versions/.archive/10549-goldenHydrangea/01-updateInsertLog.sql
similarity index 100%
rename from db/versions/10549-goldenHydrangea/01-updateInsertLog.sql
rename to db/versions/.archive/10549-goldenHydrangea/01-updateInsertLog.sql
diff --git a/db/versions/10549-goldenHydrangea/02-updateDeleteLog.sql b/db/versions/.archive/10549-goldenHydrangea/02-updateDeleteLog.sql
similarity index 100%
rename from db/versions/10549-goldenHydrangea/02-updateDeleteLog.sql
rename to db/versions/.archive/10549-goldenHydrangea/02-updateDeleteLog.sql
diff --git a/db/versions/10549-goldenHydrangea/03-deleteEmptyLog.sql b/db/versions/.archive/10549-goldenHydrangea/03-deleteEmptyLog.sql
similarity index 100%
rename from db/versions/10549-goldenHydrangea/03-deleteEmptyLog.sql
rename to db/versions/.archive/10549-goldenHydrangea/03-deleteEmptyLog.sql
diff --git a/db/versions/10549-goldenHydrangea/04-optimizeLogTables.sql b/db/versions/.archive/10549-goldenHydrangea/04-optimizeLogTables.sql
similarity index 100%
rename from db/versions/10549-goldenHydrangea/04-optimizeLogTables.sql
rename to db/versions/.archive/10549-goldenHydrangea/04-optimizeLogTables.sql
diff --git a/db/versions/10550-grayMonstera/00-editorFk.sql b/db/versions/.archive/10550-grayMonstera/00-editorFk.sql
similarity index 100%
rename from db/versions/10550-grayMonstera/00-editorFk.sql
rename to db/versions/.archive/10550-grayMonstera/00-editorFk.sql
diff --git a/db/versions/10550-grayMonstera/01-originFk.sql b/db/versions/.archive/10550-grayMonstera/01-originFk.sql
similarity index 100%
rename from db/versions/10550-grayMonstera/01-originFk.sql
rename to db/versions/.archive/10550-grayMonstera/01-originFk.sql
diff --git a/db/versions/10552-blackAnthurium/00-firstScript.sql b/db/versions/.archive/10552-blackAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10552-blackAnthurium/00-firstScript.sql
rename to db/versions/.archive/10552-blackAnthurium/00-firstScript.sql
diff --git a/db/versions/10554-maroonFern/00-firstScript.sql b/db/versions/.archive/10554-maroonFern/00-firstScript.sql
similarity index 100%
rename from db/versions/10554-maroonFern/00-firstScript.sql
rename to db/versions/.archive/10554-maroonFern/00-firstScript.sql
diff --git a/db/versions/10557-whiteCordyline/00-firstScript.sql b/db/versions/.archive/10557-whiteCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10557-whiteCordyline/00-firstScript.sql
rename to db/versions/.archive/10557-whiteCordyline/00-firstScript.sql
diff --git a/db/versions/10559-brownDracena/00-firstScript.sql b/db/versions/.archive/10559-brownDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10559-brownDracena/00-firstScript.sql
rename to db/versions/.archive/10559-brownDracena/00-firstScript.sql
diff --git a/db/versions/10560-crimsonCataractarum/00-firstScript.sql b/db/versions/.archive/10560-crimsonCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10560-crimsonCataractarum/00-firstScript.sql
rename to db/versions/.archive/10560-crimsonCataractarum/00-firstScript.sql
diff --git a/db/versions/10562-whiteDendro/00-firstScript.sql b/db/versions/.archive/10562-whiteDendro/00-firstScript.sql
similarity index 100%
rename from db/versions/10562-whiteDendro/00-firstScript.sql
rename to db/versions/.archive/10562-whiteDendro/00-firstScript.sql
diff --git a/db/versions/10563-azureMonstera/00-delivery_ticketFk.sql b/db/versions/.archive/10563-azureMonstera/00-delivery_ticketFk.sql
similarity index 100%
rename from db/versions/10563-azureMonstera/00-delivery_ticketFk.sql
rename to db/versions/.archive/10563-azureMonstera/00-delivery_ticketFk.sql
diff --git a/db/versions/10566-azureArborvitae/00-firstScript.sql b/db/versions/.archive/10566-azureArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10566-azureArborvitae/00-firstScript.sql
rename to db/versions/.archive/10566-azureArborvitae/00-firstScript.sql
diff --git a/db/versions/10567-salmonAspidistra/00-firstScript.sql b/db/versions/.archive/10567-salmonAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10567-salmonAspidistra/00-firstScript.sql
rename to db/versions/.archive/10567-salmonAspidistra/00-firstScript.sql
diff --git a/db/versions/10568-grayAnthurium/00-firstScript.sql b/db/versions/.archive/10568-grayAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10568-grayAnthurium/00-firstScript.sql
rename to db/versions/.archive/10568-grayAnthurium/00-firstScript.sql
diff --git a/db/versions/10569-salmonLaurel/00-firstScript.sql b/db/versions/.archive/10569-salmonLaurel/00-firstScript.sql
similarity index 100%
rename from db/versions/10569-salmonLaurel/00-firstScript.sql
rename to db/versions/.archive/10569-salmonLaurel/00-firstScript.sql
diff --git a/db/versions/10570-goldenTulip/00-createSendingConfig.sql b/db/versions/.archive/10570-goldenTulip/00-createSendingConfig.sql
similarity index 100%
rename from db/versions/10570-goldenTulip/00-createSendingConfig.sql
rename to db/versions/.archive/10570-goldenTulip/00-createSendingConfig.sql
diff --git a/db/versions/10570-goldenTulip/01-createSendingServiceWeekday.sql b/db/versions/.archive/10570-goldenTulip/01-createSendingServiceWeekday.sql
similarity index 100%
rename from db/versions/10570-goldenTulip/01-createSendingServiceWeekday.sql
rename to db/versions/.archive/10570-goldenTulip/01-createSendingServiceWeekday.sql
diff --git a/db/versions/10570-goldenTulip/02-createSendingService.sql b/db/versions/.archive/10570-goldenTulip/02-createSendingService.sql
similarity index 100%
rename from db/versions/10570-goldenTulip/02-createSendingService.sql
rename to db/versions/.archive/10570-goldenTulip/02-createSendingService.sql
diff --git a/db/versions/10570-goldenTulip/03-permisos.sql b/db/versions/.archive/10570-goldenTulip/03-permisos.sql
similarity index 100%
rename from db/versions/10570-goldenTulip/03-permisos.sql
rename to db/versions/.archive/10570-goldenTulip/03-permisos.sql
diff --git a/db/versions/10571-navyCyca/00-firstScript.sql b/db/versions/.archive/10571-navyCyca/00-firstScript.sql
similarity index 100%
rename from db/versions/10571-navyCyca/00-firstScript.sql
rename to db/versions/.archive/10571-navyCyca/00-firstScript.sql
diff --git a/db/versions/10573-tealChico/00-firstScript.sql b/db/versions/.archive/10573-tealChico/00-firstScript.sql
similarity index 100%
rename from db/versions/10573-tealChico/00-firstScript.sql
rename to db/versions/.archive/10573-tealChico/00-firstScript.sql
diff --git a/db/versions/10575-crimsonAnthurium/00-firstScript.sql b/db/versions/.archive/10575-crimsonAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10575-crimsonAnthurium/00-firstScript.sql
rename to db/versions/.archive/10575-crimsonAnthurium/00-firstScript.sql
diff --git a/db/versions/10577-salmonMonstera/00-firstScript.sql b/db/versions/.archive/10577-salmonMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10577-salmonMonstera/00-firstScript.sql
rename to db/versions/.archive/10577-salmonMonstera/00-firstScript.sql
diff --git a/db/versions/10578-brownCarnation/00-firstScript.sql b/db/versions/.archive/10578-brownCarnation/00-firstScript.sql
similarity index 100%
rename from db/versions/10578-brownCarnation/00-firstScript.sql
rename to db/versions/.archive/10578-brownCarnation/00-firstScript.sql
diff --git a/db/versions/10579-aquaRoebelini/00-firstScript.sql b/db/versions/.archive/10579-aquaRoebelini/00-firstScript.sql
similarity index 100%
rename from db/versions/10579-aquaRoebelini/00-firstScript.sql
rename to db/versions/.archive/10579-aquaRoebelini/00-firstScript.sql
diff --git a/db/versions/10580-purpleCataractarum/00-itemTypeDropConstraint.sql b/db/versions/.archive/10580-purpleCataractarum/00-itemTypeDropConstraint.sql
similarity index 100%
rename from db/versions/10580-purpleCataractarum/00-itemTypeDropConstraint.sql
rename to db/versions/.archive/10580-purpleCataractarum/00-itemTypeDropConstraint.sql
diff --git a/db/versions/10580-purpleCataractarum/01-itemTypeAddConstraint.sql b/db/versions/.archive/10580-purpleCataractarum/01-itemTypeAddConstraint.sql
similarity index 100%
rename from db/versions/10580-purpleCataractarum/01-itemTypeAddConstraint.sql
rename to db/versions/.archive/10580-purpleCataractarum/01-itemTypeAddConstraint.sql
diff --git a/db/versions/10581-grayPaniculata/00-itemTypeAutoIncrement.sql b/db/versions/.archive/10581-grayPaniculata/00-itemTypeAutoIncrement.sql
similarity index 100%
rename from db/versions/10581-grayPaniculata/00-itemTypeAutoIncrement.sql
rename to db/versions/.archive/10581-grayPaniculata/00-itemTypeAutoIncrement.sql
diff --git a/db/versions/10582-purpleOrchid/00-firstScript.sql b/db/versions/.archive/10582-purpleOrchid/00-firstScript.sql
similarity index 100%
rename from db/versions/10582-purpleOrchid/00-firstScript.sql
rename to db/versions/.archive/10582-purpleOrchid/00-firstScript.sql
diff --git a/db/versions/10583-turquoiseGerbera/00-firstScript.sql b/db/versions/.archive/10583-turquoiseGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10583-turquoiseGerbera/00-firstScript.sql
rename to db/versions/.archive/10583-turquoiseGerbera/00-firstScript.sql
diff --git a/db/versions/10584-azureGerbera/00-firstScript.sql b/db/versions/.archive/10584-azureGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10584-azureGerbera/00-firstScript.sql
rename to db/versions/.archive/10584-azureGerbera/00-firstScript.sql
diff --git a/db/versions/10585-pinkMedeola/00-ticketLog.sql b/db/versions/.archive/10585-pinkMedeola/00-ticketLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/00-ticketLog.sql
rename to db/versions/.archive/10585-pinkMedeola/00-ticketLog.sql
diff --git a/db/versions/10585-pinkMedeola/01-entryLog.sql b/db/versions/.archive/10585-pinkMedeola/01-entryLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/01-entryLog.sql
rename to db/versions/.archive/10585-pinkMedeola/01-entryLog.sql
diff --git a/db/versions/10585-pinkMedeola/02-claimLog.sql b/db/versions/.archive/10585-pinkMedeola/02-claimLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/02-claimLog.sql
rename to db/versions/.archive/10585-pinkMedeola/02-claimLog.sql
diff --git a/db/versions/10585-pinkMedeola/03-clientLog.sql b/db/versions/.archive/10585-pinkMedeola/03-clientLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/03-clientLog.sql
rename to db/versions/.archive/10585-pinkMedeola/03-clientLog.sql
diff --git a/db/versions/10585-pinkMedeola/04-invoiceInLog.sql b/db/versions/.archive/10585-pinkMedeola/04-invoiceInLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/04-invoiceInLog.sql
rename to db/versions/.archive/10585-pinkMedeola/04-invoiceInLog.sql
diff --git a/db/versions/10585-pinkMedeola/05-itemLog.sql b/db/versions/.archive/10585-pinkMedeola/05-itemLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/05-itemLog.sql
rename to db/versions/.archive/10585-pinkMedeola/05-itemLog.sql
diff --git a/db/versions/10585-pinkMedeola/06-routeLog.sql b/db/versions/.archive/10585-pinkMedeola/06-routeLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/06-routeLog.sql
rename to db/versions/.archive/10585-pinkMedeola/06-routeLog.sql
diff --git a/db/versions/10585-pinkMedeola/07-shelvingLog.sql b/db/versions/.archive/10585-pinkMedeola/07-shelvingLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/07-shelvingLog.sql
rename to db/versions/.archive/10585-pinkMedeola/07-shelvingLog.sql
diff --git a/db/versions/10585-pinkMedeola/08-supplierLog.sql b/db/versions/.archive/10585-pinkMedeola/08-supplierLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/08-supplierLog.sql
rename to db/versions/.archive/10585-pinkMedeola/08-supplierLog.sql
diff --git a/db/versions/10585-pinkMedeola/09-travelLog.sql b/db/versions/.archive/10585-pinkMedeola/09-travelLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/09-travelLog.sql
rename to db/versions/.archive/10585-pinkMedeola/09-travelLog.sql
diff --git a/db/versions/10585-pinkMedeola/10-workerLog.sql b/db/versions/.archive/10585-pinkMedeola/10-workerLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/10-workerLog.sql
rename to db/versions/.archive/10585-pinkMedeola/10-workerLog.sql
diff --git a/db/versions/10585-pinkMedeola/11-zoneLog.sql b/db/versions/.archive/10585-pinkMedeola/11-zoneLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/11-zoneLog.sql
rename to db/versions/.archive/10585-pinkMedeola/11-zoneLog.sql
diff --git a/db/versions/10585-pinkMedeola/12-userLog.sql b/db/versions/.archive/10585-pinkMedeola/12-userLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/12-userLog.sql
rename to db/versions/.archive/10585-pinkMedeola/12-userLog.sql
diff --git a/db/versions/10585-pinkMedeola/13-roleLog.sql b/db/versions/.archive/10585-pinkMedeola/13-roleLog.sql
similarity index 100%
rename from db/versions/10585-pinkMedeola/13-roleLog.sql
rename to db/versions/.archive/10585-pinkMedeola/13-roleLog.sql
diff --git a/db/versions/10587-navyOak/00-arcRead_addMinimum.sql b/db/versions/.archive/10587-navyOak/00-arcRead_addMinimum.sql
similarity index 100%
rename from db/versions/10587-navyOak/00-arcRead_addMinimum.sql
rename to db/versions/.archive/10587-navyOak/00-arcRead_addMinimum.sql
diff --git a/db/versions/10593-greenLilium/00-firstScript.sql b/db/versions/.archive/10593-greenLilium/00-firstScript.sql
similarity index 100%
rename from db/versions/10593-greenLilium/00-firstScript.sql
rename to db/versions/.archive/10593-greenLilium/00-firstScript.sql
diff --git a/db/versions/10596-purpleCamellia/00-firstScript.sql b/db/versions/.archive/10596-purpleCamellia/00-firstScript.sql
similarity index 100%
rename from db/versions/10596-purpleCamellia/00-firstScript.sql
rename to db/versions/.archive/10596-purpleCamellia/00-firstScript.sql
diff --git a/db/versions/10597-navyAralia/00-firstScript.sql b/db/versions/.archive/10597-navyAralia/00-firstScript.sql
similarity index 100%
rename from db/versions/10597-navyAralia/00-firstScript.sql
rename to db/versions/.archive/10597-navyAralia/00-firstScript.sql
diff --git a/db/versions/10598-purpleGalax/00-workerLog.sql b/db/versions/.archive/10598-purpleGalax/00-workerLog.sql
similarity index 100%
rename from db/versions/10598-purpleGalax/00-workerLog.sql
rename to db/versions/.archive/10598-purpleGalax/00-workerLog.sql
diff --git a/db/versions/10598-purpleGalax/01-supplierLog.sql b/db/versions/.archive/10598-purpleGalax/01-supplierLog.sql
similarity index 100%
rename from db/versions/10598-purpleGalax/01-supplierLog.sql
rename to db/versions/.archive/10598-purpleGalax/01-supplierLog.sql
diff --git a/db/versions/10598-purpleGalax/02-workerTimeControlLog.sql b/db/versions/.archive/10598-purpleGalax/02-workerTimeControlLog.sql
similarity index 100%
rename from db/versions/10598-purpleGalax/02-workerTimeControlLog.sql
rename to db/versions/.archive/10598-purpleGalax/02-workerTimeControlLog.sql
diff --git a/db/versions/10598-purpleGalax/03-workerClockLog.sql b/db/versions/.archive/10598-purpleGalax/03-workerClockLog.sql
similarity index 100%
rename from db/versions/10598-purpleGalax/03-workerClockLog.sql
rename to db/versions/.archive/10598-purpleGalax/03-workerClockLog.sql
diff --git a/db/versions/10599-orangeHydrangea/00-firstScript.sql b/db/versions/.archive/10599-orangeHydrangea/00-firstScript.sql
similarity index 100%
rename from db/versions/10599-orangeHydrangea/00-firstScript.sql
rename to db/versions/.archive/10599-orangeHydrangea/00-firstScript.sql
diff --git a/db/versions/10601-orangeErica/00-firstScript.sql b/db/versions/.archive/10601-orangeErica/00-firstScript.sql
similarity index 100%
rename from db/versions/10601-orangeErica/00-firstScript.sql
rename to db/versions/.archive/10601-orangeErica/00-firstScript.sql
diff --git a/db/versions/10602-whiteArborvitae/00-firstScript.sql b/db/versions/.archive/10602-whiteArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10602-whiteArborvitae/00-firstScript.sql
rename to db/versions/.archive/10602-whiteArborvitae/00-firstScript.sql
diff --git a/db/versions/10606-pinkChico/00-firstScript.sql b/db/versions/.archive/10606-pinkChico/00-firstScript.sql
similarity index 100%
rename from db/versions/10606-pinkChico/00-firstScript.sql
rename to db/versions/.archive/10606-pinkChico/00-firstScript.sql
diff --git a/db/versions/10608-pinkAsparagus/00-firstScript.sql b/db/versions/.archive/10608-pinkAsparagus/00-firstScript.sql
similarity index 100%
rename from db/versions/10608-pinkAsparagus/00-firstScript.sql
rename to db/versions/.archive/10608-pinkAsparagus/00-firstScript.sql
diff --git a/db/versions/10609-grayRaphis/00-firstScript.sql b/db/versions/.archive/10609-grayRaphis/00-firstScript.sql
similarity index 100%
rename from db/versions/10609-grayRaphis/00-firstScript.sql
rename to db/versions/.archive/10609-grayRaphis/00-firstScript.sql
diff --git a/db/versions/10610-goldenArborvitae/00-updateCompanyId.sql b/db/versions/.archive/10610-goldenArborvitae/00-updateCompanyId.sql
similarity index 100%
rename from db/versions/10610-goldenArborvitae/00-updateCompanyId.sql
rename to db/versions/.archive/10610-goldenArborvitae/00-updateCompanyId.sql
diff --git a/db/versions/10610-goldenArborvitae/01-updateSupplierId.sql b/db/versions/.archive/10610-goldenArborvitae/01-updateSupplierId.sql
similarity index 100%
rename from db/versions/10610-goldenArborvitae/01-updateSupplierId.sql
rename to db/versions/.archive/10610-goldenArborvitae/01-updateSupplierId.sql
diff --git a/db/versions/10610-goldenArborvitae/02-invoiceOutCompany.sql b/db/versions/.archive/10610-goldenArborvitae/02-invoiceOutCompany.sql
similarity index 100%
rename from db/versions/10610-goldenArborvitae/02-invoiceOutCompany.sql
rename to db/versions/.archive/10610-goldenArborvitae/02-invoiceOutCompany.sql
diff --git a/db/versions/10611-blueGerbera/00-firstScript.sql b/db/versions/.archive/10611-blueGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10611-blueGerbera/00-firstScript.sql
rename to db/versions/.archive/10611-blueGerbera/00-firstScript.sql
diff --git a/db/versions/10613-purpleAspidistra/00-firstScript.sql b/db/versions/.archive/10613-purpleAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10613-purpleAspidistra/00-firstScript.sql
rename to db/versions/.archive/10613-purpleAspidistra/00-firstScript.sql
diff --git a/db/versions/10614-chocolateGalax/00-firstScript.sql b/db/versions/.archive/10614-chocolateGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10614-chocolateGalax/00-firstScript.sql
rename to db/versions/.archive/10614-chocolateGalax/00-firstScript.sql
diff --git a/db/versions/10615-azureCataractarum/00-firstScript.sql b/db/versions/.archive/10615-azureCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10615-azureCataractarum/00-firstScript.sql
rename to db/versions/.archive/10615-azureCataractarum/00-firstScript.sql
diff --git a/db/versions/10616-yellowIvy/00-firstScript.sql b/db/versions/.archive/10616-yellowIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10616-yellowIvy/00-firstScript.sql
rename to db/versions/.archive/10616-yellowIvy/00-firstScript.sql
diff --git a/db/versions/10616-yellowIvy/01-firstScript.sql b/db/versions/.archive/10616-yellowIvy/01-firstScript.sql
similarity index 100%
rename from db/versions/10616-yellowIvy/01-firstScript.sql
rename to db/versions/.archive/10616-yellowIvy/01-firstScript.sql
diff --git a/db/versions/10617-aquaAralia/00-firstScript.sql b/db/versions/.archive/10617-aquaAralia/00-firstScript.sql
similarity index 100%
rename from db/versions/10617-aquaAralia/00-firstScript.sql
rename to db/versions/.archive/10617-aquaAralia/00-firstScript.sql
diff --git a/db/versions/10618-whiteArborvitae/00-firstScript.sql b/db/versions/.archive/10618-whiteArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10618-whiteArborvitae/00-firstScript.sql
rename to db/versions/.archive/10618-whiteArborvitae/00-firstScript.sql
diff --git a/db/versions/10619-chocolateErica/00-firstScript.sql b/db/versions/.archive/10619-chocolateErica/00-firstScript.sql
similarity index 100%
rename from db/versions/10619-chocolateErica/00-firstScript.sql
rename to db/versions/.archive/10619-chocolateErica/00-firstScript.sql
diff --git a/db/versions/10620-azurePalmetto/00-firstScript.sql b/db/versions/.archive/10620-azurePalmetto/00-firstScript.sql
similarity index 100%
rename from db/versions/10620-azurePalmetto/00-firstScript.sql
rename to db/versions/.archive/10620-azurePalmetto/00-firstScript.sql
diff --git a/db/versions/10624-blueAnthurium/00-firstScript.sql b/db/versions/.archive/10624-blueAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10624-blueAnthurium/00-firstScript.sql
rename to db/versions/.archive/10624-blueAnthurium/00-firstScript.sql
diff --git a/db/versions/10625-whiteOak/00-firstScript.sql b/db/versions/.archive/10625-whiteOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10625-whiteOak/00-firstScript.sql
rename to db/versions/.archive/10625-whiteOak/00-firstScript.sql
diff --git a/db/versions/10626-silverRaphis/00-firstScript.sql b/db/versions/.archive/10626-silverRaphis/00-firstScript.sql
similarity index 100%
rename from db/versions/10626-silverRaphis/00-firstScript.sql
rename to db/versions/.archive/10626-silverRaphis/00-firstScript.sql
diff --git a/db/versions/10628-grayOrchid/00-firstScript.sql b/db/versions/.archive/10628-grayOrchid/00-firstScript.sql
similarity index 100%
rename from db/versions/10628-grayOrchid/00-firstScript.sql
rename to db/versions/.archive/10628-grayOrchid/00-firstScript.sql
diff --git a/db/versions/10630-brownMastic/00-firstScript.sql b/db/versions/.archive/10630-brownMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10630-brownMastic/00-firstScript.sql
rename to db/versions/.archive/10630-brownMastic/00-firstScript.sql
diff --git a/db/versions/10631-yellowBamboo/00-firstScript.sql b/db/versions/.archive/10631-yellowBamboo/00-firstScript.sql
similarity index 100%
rename from db/versions/10631-yellowBamboo/00-firstScript.sql
rename to db/versions/.archive/10631-yellowBamboo/00-firstScript.sql
diff --git a/db/versions/10632-wheatPaniculata/00-firstScript.sql b/db/versions/.archive/10632-wheatPaniculata/00-firstScript.sql
similarity index 100%
rename from db/versions/10632-wheatPaniculata/00-firstScript.sql
rename to db/versions/.archive/10632-wheatPaniculata/00-firstScript.sql
diff --git a/db/versions/10633-orangeArborvitae/00-firstScript.sql b/db/versions/.archive/10633-orangeArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10633-orangeArborvitae/00-firstScript.sql
rename to db/versions/.archive/10633-orangeArborvitae/00-firstScript.sql
diff --git a/db/versions/10634-pinkCymbidium/00-firstScript.sql b/db/versions/.archive/10634-pinkCymbidium/00-firstScript.sql
similarity index 100%
rename from db/versions/10634-pinkCymbidium/00-firstScript.sql
rename to db/versions/.archive/10634-pinkCymbidium/00-firstScript.sql
diff --git a/db/versions/10637-yellowAspidistra/00-firstScript.sql b/db/versions/.archive/10637-yellowAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10637-yellowAspidistra/00-firstScript.sql
rename to db/versions/.archive/10637-yellowAspidistra/00-firstScript.sql
diff --git a/db/versions/10640-redPalmetto/00-companyFkDrop.sql b/db/versions/.archive/10640-redPalmetto/00-companyFkDrop.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/00-companyFkDrop.sql
rename to db/versions/.archive/10640-redPalmetto/00-companyFkDrop.sql
diff --git a/db/versions/10640-redPalmetto/01-companyFkAi.sql b/db/versions/.archive/10640-redPalmetto/01-companyFkAi.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/01-companyFkAi.sql
rename to db/versions/.archive/10640-redPalmetto/01-companyFkAi.sql
diff --git a/db/versions/10640-redPalmetto/02-companyFkCreate.sql b/db/versions/.archive/10640-redPalmetto/02-companyFkCreate.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/02-companyFkCreate.sql
rename to db/versions/.archive/10640-redPalmetto/02-companyFkCreate.sql
diff --git a/db/versions/10640-redPalmetto/04-supplierFkDrop.sql b/db/versions/.archive/10640-redPalmetto/04-supplierFkDrop.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/04-supplierFkDrop.sql
rename to db/versions/.archive/10640-redPalmetto/04-supplierFkDrop.sql
diff --git a/db/versions/10640-redPalmetto/05-supplierFkAi.sql b/db/versions/.archive/10640-redPalmetto/05-supplierFkAi.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/05-supplierFkAi.sql
rename to db/versions/.archive/10640-redPalmetto/05-supplierFkAi.sql
diff --git a/db/versions/10640-redPalmetto/06-supplierFkCreate.sql b/db/versions/.archive/10640-redPalmetto/06-supplierFkCreate.sql
similarity index 100%
rename from db/versions/10640-redPalmetto/06-supplierFkCreate.sql
rename to db/versions/.archive/10640-redPalmetto/06-supplierFkCreate.sql
diff --git a/db/versions/10642-crimsonAspidistra/00-firstScript.sql b/db/versions/.archive/10642-crimsonAspidistra/00-firstScript.sql
similarity index 100%
rename from db/versions/10642-crimsonAspidistra/00-firstScript.sql
rename to db/versions/.archive/10642-crimsonAspidistra/00-firstScript.sql
diff --git a/db/versions/10643-blueCataractarum/00-firstScript.sql b/db/versions/.archive/10643-blueCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10643-blueCataractarum/00-firstScript.sql
rename to db/versions/.archive/10643-blueCataractarum/00-firstScript.sql
diff --git a/db/versions/10644-aquaLaurel/00-firstScript.sql b/db/versions/.archive/10644-aquaLaurel/00-firstScript.sql
similarity index 100%
rename from db/versions/10644-aquaLaurel/00-firstScript.sql
rename to db/versions/.archive/10644-aquaLaurel/00-firstScript.sql
diff --git a/db/versions/10645-purplePalmetto/00-addNewFields.sql b/db/versions/.archive/10645-purplePalmetto/00-addNewFields.sql
similarity index 100%
rename from db/versions/10645-purplePalmetto/00-addNewFields.sql
rename to db/versions/.archive/10645-purplePalmetto/00-addNewFields.sql
diff --git a/db/versions/10645-purplePalmetto/01-updateCollectionWagonPrimaryKey.sql b/db/versions/.archive/10645-purplePalmetto/01-updateCollectionWagonPrimaryKey.sql
similarity index 100%
rename from db/versions/10645-purplePalmetto/01-updateCollectionWagonPrimaryKey.sql
rename to db/versions/.archive/10645-purplePalmetto/01-updateCollectionWagonPrimaryKey.sql
diff --git a/db/versions/10645-purplePalmetto/02-updateWagonPrimaryKey.sql b/db/versions/.archive/10645-purplePalmetto/02-updateWagonPrimaryKey.sql
similarity index 100%
rename from db/versions/10645-purplePalmetto/02-updateWagonPrimaryKey.sql
rename to db/versions/.archive/10645-purplePalmetto/02-updateWagonPrimaryKey.sql
diff --git a/db/versions/10645-purplePalmetto/03-addFieldToPackingSite.sql b/db/versions/.archive/10645-purplePalmetto/03-addFieldToPackingSite.sql
similarity index 100%
rename from db/versions/10645-purplePalmetto/03-addFieldToPackingSite.sql
rename to db/versions/.archive/10645-purplePalmetto/03-addFieldToPackingSite.sql
diff --git a/db/versions/10647-goldenBamboo/00-renombrarTabla.sql b/db/versions/.archive/10647-goldenBamboo/00-renombrarTabla.sql
similarity index 100%
rename from db/versions/10647-goldenBamboo/00-renombrarTabla.sql
rename to db/versions/.archive/10647-goldenBamboo/00-renombrarTabla.sql
diff --git a/db/versions/10648-blackBirch/00-firstScript.sql b/db/versions/.archive/10648-blackBirch/00-firstScript.sql
similarity index 100%
rename from db/versions/10648-blackBirch/00-firstScript.sql
rename to db/versions/.archive/10648-blackBirch/00-firstScript.sql
diff --git a/db/versions/10649-yellowAsparagus/00-firstScript.sql b/db/versions/.archive/10649-yellowAsparagus/00-firstScript.sql
similarity index 100%
rename from db/versions/10649-yellowAsparagus/00-firstScript.sql
rename to db/versions/.archive/10649-yellowAsparagus/00-firstScript.sql
diff --git a/db/versions/10651-chocolatePalmetto/00-comparativeCountryFk.sql b/db/versions/.archive/10651-chocolatePalmetto/00-comparativeCountryFk.sql
similarity index 100%
rename from db/versions/10651-chocolatePalmetto/00-comparativeCountryFk.sql
rename to db/versions/.archive/10651-chocolatePalmetto/00-comparativeCountryFk.sql
diff --git a/db/versions/10651-chocolatePalmetto/01-comparativeAddConfig.sql b/db/versions/.archive/10651-chocolatePalmetto/01-comparativeAddConfig.sql
similarity index 100%
rename from db/versions/10651-chocolatePalmetto/01-comparativeAddConfig.sql
rename to db/versions/.archive/10651-chocolatePalmetto/01-comparativeAddConfig.sql
diff --git a/db/versions/10651-chocolatePalmetto/02-nightTaskAddNewTask.sql b/db/versions/.archive/10651-chocolatePalmetto/02-nightTaskAddNewTask.sql
similarity index 100%
rename from db/versions/10651-chocolatePalmetto/02-nightTaskAddNewTask.sql
rename to db/versions/.archive/10651-chocolatePalmetto/02-nightTaskAddNewTask.sql
diff --git a/db/versions/10651-chocolatePalmetto/03-grantProc.vn.sql b/db/versions/.archive/10651-chocolatePalmetto/03-grantProc.vn.sql
similarity index 79%
rename from db/versions/10651-chocolatePalmetto/03-grantProc.vn.sql
rename to db/versions/.archive/10651-chocolatePalmetto/03-grantProc.vn.sql
index 151d1a24b..f6118b993 100644
--- a/db/versions/10651-chocolatePalmetto/03-grantProc.vn.sql
+++ b/db/versions/.archive/10651-chocolatePalmetto/03-grantProc.vn.sql
@@ -1,2 +1,2 @@
GRANT EXECUTE ON PROCEDURE vn.item_comparative TO claimManager, buyer;
-FLUSH PRIVILEGES;
+FLUSH PRIVILEGES;
\ No newline at end of file
diff --git a/db/versions/10652-maroonPhormium/00-firstScript.sql b/db/versions/.archive/10652-maroonPhormium/00-firstScript.sql
similarity index 100%
rename from db/versions/10652-maroonPhormium/00-firstScript.sql
rename to db/versions/.archive/10652-maroonPhormium/00-firstScript.sql
diff --git a/db/versions/10653-redHydrangea/00-firstScript.sql b/db/versions/.archive/10653-redHydrangea/00-firstScript.sql
similarity index 100%
rename from db/versions/10653-redHydrangea/00-firstScript.sql
rename to db/versions/.archive/10653-redHydrangea/00-firstScript.sql
diff --git a/db/versions/10655-navyRuscus/00-firstScript.sql b/db/versions/.archive/10655-navyRuscus/00-firstScript.sql
similarity index 100%
rename from db/versions/10655-navyRuscus/00-firstScript.sql
rename to db/versions/.archive/10655-navyRuscus/00-firstScript.sql
diff --git a/db/versions/10656-navyMastic/00-firstScript.sql b/db/versions/.archive/10656-navyMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10656-navyMastic/00-firstScript.sql
rename to db/versions/.archive/10656-navyMastic/00-firstScript.sql
diff --git a/db/versions/10657-redDracena/00-renameErrorProduction.sql b/db/versions/.archive/10657-redDracena/00-renameErrorProduction.sql
similarity index 100%
rename from db/versions/10657-redDracena/00-renameErrorProduction.sql
rename to db/versions/.archive/10657-redDracena/00-renameErrorProduction.sql
diff --git a/db/versions/10657-redDracena/01-changeNightTask.sql b/db/versions/.archive/10657-redDracena/01-changeNightTask.sql
similarity index 100%
rename from db/versions/10657-redDracena/01-changeNightTask.sql
rename to db/versions/.archive/10657-redDracena/01-changeNightTask.sql
diff --git a/db/versions/10657-redDracena/02-addCodeToClaimResponsible.sql b/db/versions/.archive/10657-redDracena/02-addCodeToClaimResponsible.sql
similarity index 100%
rename from db/versions/10657-redDracena/02-addCodeToClaimResponsible.sql
rename to db/versions/.archive/10657-redDracena/02-addCodeToClaimResponsible.sql
diff --git a/db/versions/10657-redDracena/03-grantSelectGrafana.sql b/db/versions/.archive/10657-redDracena/03-grantSelectGrafana.sql
similarity index 100%
rename from db/versions/10657-redDracena/03-grantSelectGrafana.sql
rename to db/versions/.archive/10657-redDracena/03-grantSelectGrafana.sql
diff --git a/db/versions/10658-whiteDracena/00-firstScript.sql b/db/versions/.archive/10658-whiteDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10658-whiteDracena/00-firstScript.sql
rename to db/versions/.archive/10658-whiteDracena/00-firstScript.sql
diff --git a/db/versions/10659-azureDracena/00-firstScript.sql b/db/versions/.archive/10659-azureDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10659-azureDracena/00-firstScript.sql
rename to db/versions/.archive/10659-azureDracena/00-firstScript.sql
diff --git a/db/versions/10661-crimsonIvy/00-firstScript.sql b/db/versions/.archive/10661-crimsonIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10661-crimsonIvy/00-firstScript.sql
rename to db/versions/.archive/10661-crimsonIvy/00-firstScript.sql
diff --git a/db/versions/10662-wheatErica/00-firstScript.sql b/db/versions/.archive/10662-wheatErica/00-firstScript.sql
similarity index 100%
rename from db/versions/10662-wheatErica/00-firstScript.sql
rename to db/versions/.archive/10662-wheatErica/00-firstScript.sql
diff --git a/db/versions/10663-tealCymbidium/00-firstScript.sql b/db/versions/.archive/10663-tealCymbidium/00-firstScript.sql
similarity index 100%
rename from db/versions/10663-tealCymbidium/00-firstScript.sql
rename to db/versions/.archive/10663-tealCymbidium/00-firstScript.sql
diff --git a/db/versions/10665-maroonSalal/00-firstScript.sql b/db/versions/.archive/10665-maroonSalal/00-firstScript.sql
similarity index 100%
rename from db/versions/10665-maroonSalal/00-firstScript.sql
rename to db/versions/.archive/10665-maroonSalal/00-firstScript.sql
diff --git a/db/versions/10666-limeGerbera/00-firstScript.sql b/db/versions/.archive/10666-limeGerbera/00-firstScript.sql
similarity index 100%
rename from db/versions/10666-limeGerbera/00-firstScript.sql
rename to db/versions/.archive/10666-limeGerbera/00-firstScript.sql
diff --git a/db/versions/10667-blackChrysanthemum/00-firstScript.sql b/db/versions/.archive/10667-blackChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10667-blackChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10667-blackChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10668-tealBirch/00-firstScript.sql b/db/versions/.archive/10668-tealBirch/00-firstScript.sql
similarity index 100%
rename from db/versions/10668-tealBirch/00-firstScript.sql
rename to db/versions/.archive/10668-tealBirch/00-firstScript.sql
diff --git a/db/versions/10671-maroonIvy/00-firstScript.sql b/db/versions/.archive/10671-maroonIvy/00-firstScript.sql
similarity index 100%
rename from db/versions/10671-maroonIvy/00-firstScript.sql
rename to db/versions/.archive/10671-maroonIvy/00-firstScript.sql
diff --git a/db/versions/10675-grayRuscus/00-firstScript.sql b/db/versions/.archive/10675-grayRuscus/00-firstScript.sql
similarity index 100%
rename from db/versions/10675-grayRuscus/00-firstScript.sql
rename to db/versions/.archive/10675-grayRuscus/00-firstScript.sql
diff --git a/db/versions/10676-aquaTulip/00-firstScript.sql b/db/versions/.archive/10676-aquaTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10676-aquaTulip/00-firstScript.sql
rename to db/versions/.archive/10676-aquaTulip/00-firstScript.sql
diff --git a/db/versions/10677-yellowMoss/00-firstScript.sql b/db/versions/.archive/10677-yellowMoss/00-firstScript.sql
similarity index 100%
rename from db/versions/10677-yellowMoss/00-firstScript.sql
rename to db/versions/.archive/10677-yellowMoss/00-firstScript.sql
diff --git a/db/versions/10678-orangeMedeola/00-firstScript.sql b/db/versions/.archive/10678-orangeMedeola/00-firstScript.sql
similarity index 100%
rename from db/versions/10678-orangeMedeola/00-firstScript.sql
rename to db/versions/.archive/10678-orangeMedeola/00-firstScript.sql
diff --git a/db/versions/10679-inventoryDiscrepancy/00-tables.sql b/db/versions/.archive/10679-inventoryDiscrepancy/00-tables.sql
similarity index 100%
rename from db/versions/10679-inventoryDiscrepancy/00-tables.sql
rename to db/versions/.archive/10679-inventoryDiscrepancy/00-tables.sql
diff --git a/db/versions/10680-turquoiseLilium/00-firstScript.sql b/db/versions/.archive/10680-turquoiseLilium/00-firstScript.sql
similarity index 100%
rename from db/versions/10680-turquoiseLilium/00-firstScript.sql
rename to db/versions/.archive/10680-turquoiseLilium/00-firstScript.sql
diff --git a/db/versions/10682-crimsonEucalyptus/00-firstScript.sql b/db/versions/.archive/10682-crimsonEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10682-crimsonEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10682-crimsonEucalyptus/00-firstScript.sql
diff --git a/db/versions/10683-bronzeMastic/00-firstScript.sql b/db/versions/.archive/10683-bronzeMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10683-bronzeMastic/00-firstScript.sql
rename to db/versions/.archive/10683-bronzeMastic/00-firstScript.sql
diff --git a/db/versions/10684-tealEucalyptus/00-firstScript.sql b/db/versions/.archive/10684-tealEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10684-tealEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10684-tealEucalyptus/00-firstScript.sql
diff --git a/db/versions/10685-blueMedeola/00-firstScript.sql b/db/versions/.archive/10685-blueMedeola/00-firstScript.sql
similarity index 100%
rename from db/versions/10685-blueMedeola/00-firstScript.sql
rename to db/versions/.archive/10685-blueMedeola/00-firstScript.sql
diff --git a/db/versions/10690-azureGalax/00-firstScript.sql b/db/versions/.archive/10690-azureGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10690-azureGalax/00-firstScript.sql
rename to db/versions/.archive/10690-azureGalax/00-firstScript.sql
diff --git a/db/versions/10691-bronzeCamellia/00-firstScript.sql b/db/versions/.archive/10691-bronzeCamellia/00-firstScript.sql
similarity index 100%
rename from db/versions/10691-bronzeCamellia/00-firstScript.sql
rename to db/versions/.archive/10691-bronzeCamellia/00-firstScript.sql
diff --git a/db/versions/10692-silverLilium/00-firstScript.sql b/db/versions/.archive/10692-silverLilium/00-firstScript.sql
similarity index 100%
rename from db/versions/10692-silverLilium/00-firstScript.sql
rename to db/versions/.archive/10692-silverLilium/00-firstScript.sql
diff --git a/db/versions/10693-chocolateCordyline/00-firstScript.sql b/db/versions/.archive/10693-chocolateCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10693-chocolateCordyline/00-firstScript.sql
rename to db/versions/.archive/10693-chocolateCordyline/00-firstScript.sql
diff --git a/db/versions/10694-bluePaniculata/00-firstScript.sql b/db/versions/.archive/10694-bluePaniculata/00-firstScript.sql
similarity index 100%
rename from db/versions/10694-bluePaniculata/00-firstScript.sql
rename to db/versions/.archive/10694-bluePaniculata/00-firstScript.sql
diff --git a/db/versions/10695-pinkMastic/00-firstScript.sql b/db/versions/.archive/10695-pinkMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10695-pinkMastic/00-firstScript.sql
rename to db/versions/.archive/10695-pinkMastic/00-firstScript.sql
diff --git a/db/versions/10696-blackCataractarum/00-firstScript.sql b/db/versions/.archive/10696-blackCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10696-blackCataractarum/00-firstScript.sql
rename to db/versions/.archive/10696-blackCataractarum/00-firstScript.sql
diff --git a/db/versions/10698-yellowGalax/00-firstScript.sql b/db/versions/.archive/10698-yellowGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10698-yellowGalax/00-firstScript.sql
rename to db/versions/.archive/10698-yellowGalax/00-firstScript.sql
diff --git a/db/versions/10699-aquaOak/00-firstScript.sql b/db/versions/.archive/10699-aquaOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10699-aquaOak/00-firstScript.sql
rename to db/versions/.archive/10699-aquaOak/00-firstScript.sql
diff --git a/db/versions/10700-salmonTulip/00-firstScript.sql b/db/versions/.archive/10700-salmonTulip/00-firstScript.sql
similarity index 100%
rename from db/versions/10700-salmonTulip/00-firstScript.sql
rename to db/versions/.archive/10700-salmonTulip/00-firstScript.sql
diff --git a/db/versions/10701-turquoisePaniculata/00-firstScript.sql b/db/versions/.archive/10701-turquoisePaniculata/00-firstScript.sql
similarity index 100%
rename from db/versions/10701-turquoisePaniculata/00-firstScript.sql
rename to db/versions/.archive/10701-turquoisePaniculata/00-firstScript.sql
diff --git a/db/versions/10702-crimsonCymbidium/00-firstScript.sql b/db/versions/.archive/10702-crimsonCymbidium/00-firstScript.sql
similarity index 100%
rename from db/versions/10702-crimsonCymbidium/00-firstScript.sql
rename to db/versions/.archive/10702-crimsonCymbidium/00-firstScript.sql
diff --git a/db/versions/10704-wheatMastic/00-firstScript.sql b/db/versions/.archive/10704-wheatMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10704-wheatMastic/00-firstScript.sql
rename to db/versions/.archive/10704-wheatMastic/00-firstScript.sql
diff --git a/db/versions/10705-yellowBirch/00-firstScript.sql b/db/versions/.archive/10705-yellowBirch/00-firstScript.sql
similarity index 100%
rename from db/versions/10705-yellowBirch/00-firstScript.sql
rename to db/versions/.archive/10705-yellowBirch/00-firstScript.sql
diff --git a/db/versions/10707-azureFern/00-firstScript.sql b/db/versions/.archive/10707-azureFern/00-firstScript.sql
similarity index 100%
rename from db/versions/10707-azureFern/00-firstScript.sql
rename to db/versions/.archive/10707-azureFern/00-firstScript.sql
diff --git a/db/versions/10708-greenChrysanthemum/00-firstScript.sql b/db/versions/.archive/10708-greenChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10708-greenChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10708-greenChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10712-crimsonCordyline/00-firstScript.sql b/db/versions/.archive/10712-crimsonCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10712-crimsonCordyline/00-firstScript.sql
rename to db/versions/.archive/10712-crimsonCordyline/00-firstScript.sql
diff --git a/db/versions/10714-azureOak/00-firstScript.sql b/db/versions/.archive/10714-azureOak/00-firstScript.sql
similarity index 100%
rename from db/versions/10714-azureOak/00-firstScript.sql
rename to db/versions/.archive/10714-azureOak/00-firstScript.sql
diff --git a/db/versions/10716-chocolateCamellia/00-firstScript.sql b/db/versions/.archive/10716-chocolateCamellia/00-firstScript.sql
similarity index 100%
rename from db/versions/10716-chocolateCamellia/00-firstScript.sql
rename to db/versions/.archive/10716-chocolateCamellia/00-firstScript.sql
diff --git a/db/versions/10717-silverRose/00-firstScript.sql b/db/versions/.archive/10717-silverRose/00-firstScript.sql
similarity index 100%
rename from db/versions/10717-silverRose/00-firstScript.sql
rename to db/versions/.archive/10717-silverRose/00-firstScript.sql
diff --git a/db/versions/10718-orangeRaphis/00-firstScript.sql b/db/versions/.archive/10718-orangeRaphis/00-firstScript.sql
similarity index 100%
rename from db/versions/10718-orangeRaphis/00-firstScript.sql
rename to db/versions/.archive/10718-orangeRaphis/00-firstScript.sql
diff --git a/db/versions/10719-orangeMonstera/00-firstScript.sql b/db/versions/.archive/10719-orangeMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10719-orangeMonstera/00-firstScript.sql
rename to db/versions/.archive/10719-orangeMonstera/00-firstScript.sql
diff --git a/db/versions/10720-wheatCymbidium/00-firstScript.sql b/db/versions/.archive/10720-wheatCymbidium/00-firstScript.sql
similarity index 100%
rename from db/versions/10720-wheatCymbidium/00-firstScript.sql
rename to db/versions/.archive/10720-wheatCymbidium/00-firstScript.sql
diff --git a/db/versions/10721-blueEucalyptus/00-firstScript.sql b/db/versions/.archive/10721-blueEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10721-blueEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10721-blueEucalyptus/00-firstScript.sql
diff --git a/db/versions/.archive/10722-azureAralia/00-firstScript.vn.sql b/db/versions/.archive/10722-azureAralia/00-firstScript.vn.sql
new file mode 100644
index 000000000..2d04dfe03
--- /dev/null
+++ b/db/versions/.archive/10722-azureAralia/00-firstScript.vn.sql
@@ -0,0 +1,289 @@
+CREATE ROLE 'salix', 'android', 'hedera-web', 'grafana';
+
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'salix'@'10.0.%.%', 'android'@'10.0.%.%', 'hedera-web'@'10.0.%.%', 'grafana'@'10.0.%.%';
+
+GRANT 'salix' TO 'salix'@'10.0.%.%';
+GRANT 'android' TO 'android'@'10.0.%.%';
+GRANT 'hedera-web' TO 'hedera-web'@'10.0.%.%';
+GRANT 'grafana' TO 'grafana'@'10.0.%.%';
+
+SET DEFAULT ROLE 'salix' FOR 'salix'@'10.0.%.%';
+SET DEFAULT ROLE 'android' FOR 'android'@'10.0.%.%';
+SET DEFAULT ROLE 'hedera-web' FOR 'hedera-web'@'10.0.%.%';
+SET DEFAULT ROLE 'grafana' FOR 'grafana'@'10.0.%.%';
+
+-- salix
+ -- GRANT `$root` TO `salix` WITH ADMIN OPTION; Access denied for user 'root'@'%'
+GRANT CREATE USER ON *.* TO `salix` WITH GRANT OPTION;
+GRANT SELECT, UPDATE ON `mysql`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE, EVENT ON `account`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `bs`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `util`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `pbx`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE, EVENT ON `vn`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `salix`.* TO `salix`;
+GRANT SELECT ON `managedesktop`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `edi`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `tmp`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `sage`.* TO `salix`;
+GRANT SELECT, CREATE TEMPORARY TABLES, EXECUTE ON `cache`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `nst`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `salix`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `postgresql`.* TO `salix`;
+
+-- android
+GRANT USAGE ON *.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `android`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `vn`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `cache`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `android`;
+GRANT SELECT, EXECUTE ON `pbx`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE TEMPORARY TABLES ON `tmp`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `android`;
+GRANT SELECT ON `edi`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `account`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, SHOW VIEW ON `bi`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `Consumos`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vncontrol`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `srt`.* TO `android`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `psico`.* TO `android`;
+GRANT SELECT ON `salix`.`AccessToken` TO `android`;
+GRANT EXECUTE ON PROCEDURE `util`.`debugadd` TO `android`;
+GRANT EXECUTE ON PROCEDURE `util`.`log_add` TO `android`;
+GRANT EXECUTE ON FUNCTION `util`.`vn_now` TO `android`;
+
+-- hedera-web
+GRANT USAGE ON *.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `stock`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `account`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `hedera-web`;
+GRANT SELECT ON `util`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `edi`.* TO `hedera-web`;
+GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `salix`.* TO `hedera-web`;
+
+-- grafana
+GRANT USAGE ON *.* TO `grafana` WITH MAX_USER_CONNECTIONS 50;
+GRANT EXECUTE ON `util`.* TO `grafana`;
+GRANT SELECT ON `vn`.`mistakeType` TO `grafana`;
+GRANT SELECT ON `vn`.`collectionHotbed` TO `grafana`;
+GRANT SELECT ON `bs`.`clientDied` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionScan` TO `grafana`;
+GRANT SELECT ON `vn`.`sale` TO `grafana`;
+GRANT SELECT ON `vn`.`printQueue` TO `grafana`;
+GRANT SELECT ON `vn`.`operator` TO `grafana`;
+GRANT SELECT ON `vn`.`itemType` TO `grafana`;
+GRANT SELECT ON `vn`.`expedition` TO `grafana`;
+GRANT SELECT ON `srt`.`bufferState` TO `grafana`;
+GRANT SELECT ON `edi`.`offerList` TO `grafana`;
+GRANT SELECT ON `vn`.`creditInsurance` TO `grafana`;
+GRANT SELECT ON `vn`.`workerTimeControl` TO `grafana`;
+GRANT SELECT ON `vn`.`volumeConfig` TO `grafana`;
+GRANT SELECT ON `vn`.`agency` TO `grafana`;
+GRANT SELECT ON `vn`.`alertLevel` TO `grafana`;
+GRANT SELECT (user_id, extension) ON `pbx`.`sip` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionStateType` TO `grafana`;
+GRANT SELECT ON `vn`.`businessType` TO `grafana`;
+GRANT SELECT ON `vn`.`time` TO `grafana`;
+GRANT SELECT ON `hedera`.`visitUser` TO `grafana`;
+GRANT SELECT ON `vn`.`workCenter` TO `grafana`;
+GRANT SELECT ON `vn`.`ticket` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketWeekly` TO `grafana`;
+GRANT SELECT ON `vn`.`claimEnd` TO `grafana`;
+GRANT SELECT ON `vn`.`arcRead` TO `grafana`;
+GRANT SELECT ON `vn`.`saleGoal` TO `grafana`;
+GRANT SELECT ON `edi`.`supplyResponse` TO `grafana`;
+GRANT SELECT ON `vn`.`invoiceInTax` TO `grafana`;
+GRANT SELECT ON `bs`.`salesPersonEvolution` TO `grafana`;
+GRANT SELECT ON `vn`.`saleComponent` TO `grafana`;
+GRANT SELECT ON `vn`.`itemShelvingStock` TO `grafana`;
+GRANT SELECT ON `vn`.`clientChain` TO `grafana`;
+GRANT SELECT ON `edi`.`VMPSettings` TO `grafana`;
+GRANT SELECT ON `util`.`debug` TO `grafana`;
+GRANT SELECT ON `vn`.`claimResponsible` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketState` TO `grafana`;
+GRANT SELECT ON `vn`.`packingSiteLog` TO `grafana`;
+GRANT SELECT ON `bs`.`sale` TO `grafana`;
+GRANT SELECT ON `vn`.`ink` TO `grafana`;
+GRANT SELECT ON `bs`.`inventoryDiscrepancyDetail` TO `grafana`;
+GRANT SELECT ON `vn`.`clientCredit` TO `grafana`;
+GRANT SELECT ON `vn`.`workerMana` TO `grafana`;
+GRANT SELECT ON `vn`.`greugeType` TO `grafana`;
+GRANT SELECT ON `vn`.`supplierPackaging` TO `grafana`;
+GRANT SELECT ON `vn`.`mdbVersion` TO `grafana`;
+GRANT SELECT ON `vn`.`clientLog` TO `grafana`;
+GRANT SELECT ON `vn`.`calendar` TO `grafana`;
+GRANT SELECT ON `vn`.`campaign` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketService` TO `grafana`;
+GRANT SELECT ON `vn`.`report` TO `grafana`;
+GRANT SELECT ON `vn`.`buyer` TO `grafana`;
+GRANT SELECT ON `bs`.`defaulter` TO `grafana`;
+GRANT SELECT ON `vn`.`componentType` TO `grafana`;
+GRANT SELECT ON `vn`.`clientManaCache` TO `grafana`;
+GRANT SELECT ON `vn`.`invoiceIn` TO `grafana`;
+GRANT SELECT ON `edi`.`deliveryInformation` TO `grafana`;
+GRANT SELECT ON `srt`.`bufferType` TO `grafana`;
+GRANT SELECT ON `account`.`role` TO `grafana`;
+GRANT SELECT ON `edi`.`supplyOffer` TO `grafana`;
+GRANT SELECT ON `vn`.`travel` TO `grafana`;
+GRANT SELECT ON `srt`.`bufferFreeLength` TO `grafana`;
+GRANT SELECT ON `vn`.`worker` TO `grafana`;
+GRANT SELECT ON `vn`.`client` TO `grafana`;
+GRANT SELECT ON `vn`.`supplier` TO `grafana`;
+GRANT SELECT ON `vn`.`zoneEstimatedDelivery` TO `grafana`;
+GRANT SELECT ON `vn`.`workerDistributionCategory` TO `grafana`;
+GRANT SELECT ON `vn`.`entry` TO `grafana`;
+GRANT SELECT ON `vn`.`claimBeginning` TO `grafana`;
+GRANT SELECT ON `vn`.`payMethod` TO `grafana`;
+GRANT SELECT ON `vn`.`collection` TO `grafana`;
+GRANT SELECT ON `srt`.`routePalletized` TO `grafana`;
+GRANT SELECT ON `bs`.`inventoryDiscrepancy` TO `grafana`;
+GRANT SELECT ON `vn`.`itemImageQueue` TO `grafana`;
+GRANT SELECT ON `bi`.`rutasBoard` TO `grafana`;
+GRANT SELECT ON `vn`.`department` TO `grafana`;
+GRANT SELECT ON `bs`.`workerLabourDataByMonth` TO `grafana`;
+GRANT SELECT ON `vn`.`route` TO `grafana`;
+GRANT SELECT ON `vn`.`routeCommission` TO `grafana`;
+GRANT SELECT ON `bs`.`m3` TO `grafana`;
+GRANT SELECT ON `vn`.`itemCost` TO `grafana`;
+GRANT SELECT ON `vn`.`zone` TO `grafana`;
+GRANT SELECT ON `vn`.`mdbApp` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketPackaging` TO `grafana`;
+GRANT SELECT ON `vn`.`itemTaxCountry` TO `grafana`;
+GRANT SELECT ON `vn`.`sectorCollection` TO `grafana`;
+GRANT SELECT ON `vn`.`address` TO `grafana`;
+GRANT SELECT ON `vn`.`deviceProductionLog` TO `grafana`;
+GRANT SELECT ON `vn`.`itemPackingType` TO `grafana`;
+GRANT SELECT ON `vn`.`workerJourney` TO `grafana`;
+GRANT SELECT ON `srt`.`expedition` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionMistake` TO `grafana`;
+GRANT SELECT ON `vn`.`productionError` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionState` TO `grafana`;
+GRANT SELECT ON `bs`.`salesByItemTypeDay` TO `grafana`;
+GRANT SELECT ON `vn`.`packingSite` TO `grafana`;
+GRANT SELECT ON `vn`.`businessCalendar` TO `grafana`;
+GRANT SELECT ON `vn`.`chain` TO `grafana`;
+GRANT SELECT ON `vn`.`clientRisk` TO `grafana`;
+GRANT SELECT ON `vn`.`claimRedelivery` TO `grafana`;
+GRANT SELECT ON `vn`.`business` TO `grafana`;
+GRANT SELECT ON `bs`.`clientAnnualConsumption` TO `grafana`;
+GRANT SELECT ON `vn`.`dock` TO `grafana`;
+GRANT SELECT ON `vn`.`item` TO `grafana`;
+GRANT SELECT ON `vn`.`province` TO `grafana`;
+GRANT SELECT ON `vn`.`shelving` TO `grafana`;
+GRANT SELECT ON `vn`.`claim` TO `grafana`;
+GRANT SELECT ON `vn`.`clientType` TO `grafana`;
+GRANT SELECT ON `vn`.`supplierAccount` TO `grafana`;
+GRANT SELECT ON `vn`.`workerDepartment` TO `grafana`;
+GRANT SELECT ON `pbx`.`cdr` TO `grafana`;
+GRANT SELECT ON `vn`.`workerTimeControlConfig` TO `grafana`;
+GRANT SELECT ON `vn`.`workerMistake` TO `grafana`;
+GRANT SELECT ON `edi`.`putOrder` TO `grafana`;
+GRANT SELECT ON `vn`.`saleMistake` TO `grafana`;
+GRANT SELECT ON `vn`.`deviceProductionUser` TO `grafana`;
+GRANT SELECT ON `vn`.`contactChannel` TO `grafana`;
+GRANT SELECT ON `vn`.`deviceLog` TO `grafana`;
+GRANT SELECT ON `vn`.`vehicle` TO `grafana`;
+GRANT SELECT ON `vn`.`packaging` TO `grafana`;
+GRANT SELECT ON `bs`.`workerProductivityConfig` TO `grafana`;
+GRANT SELECT ON `srt`.`antenna` TO `grafana`;
+GRANT SELECT ON `vn`.`cmr` TO `grafana`;
+GRANT SELECT ON `vn`.`accounting` TO `grafana`;
+GRANT SELECT ON `vn`.`creditClassification` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketLog` TO `grafana`;
+GRANT SELECT ON `srt`.`moving` TO `grafana`;
+GRANT SELECT ON `vn`.`claimDevelopment` TO `grafana`;
+GRANT SELECT ON `srt`.`expeditionLog` TO `grafana`;
+GRANT SELECT ON `bs`.`compradores_evolution` TO `grafana`;
+GRANT SELECT ON `vn`.`currency` TO `grafana`;
+GRANT SELECT ON `vn`.`claimObservation` TO `grafana`;
+GRANT SELECT ON `vn`.`salesPreviousPreparated` TO `grafana`;
+GRANT SELECT ON `vn`.`claimState` TO `grafana`;
+GRANT SELECT ON `vn`.`company` TO `grafana`;
+GRANT SELECT ON `srt`.`buffer` TO `grafana`;
+GRANT SELECT ON `vn`.`greuge` TO `grafana`;
+GRANT SELECT ON `vn`.`routeComplement` TO `grafana`;
+GRANT SELECT ON `vn`.`saleVolume` TO `grafana`;
+GRANT SELECT ON `vn`.`component` TO `grafana`;
+GRANT SELECT ON `vn`.`train` TO `grafana`;
+GRANT SELECT ON `srt`.`ticketPalletized` TO `grafana`;
+GRANT SELECT ON `vn`.`autonomy` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionMistakeType` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketParking` TO `grafana`;
+GRANT SELECT ON `vn`.`itemShelving` TO `grafana`;
+GRANT SELECT ON `vn`.`state` TO `grafana`;
+GRANT SELECT ON `vn`.`taxClass` TO `grafana`;
+GRANT SELECT ON `bs`.`salesByWeek` TO `grafana`;
+GRANT SELECT ON `vn`.`invoiceInDueDay` TO `grafana`;
+GRANT SELECT ON `vn`.`sectorProductivity` TO `grafana`;
+GRANT SELECT ON `bs`.`salesByclientSalesPerson` TO `grafana`;
+GRANT SELECT ON `edi`.`marketPlace` TO `grafana`;
+GRANT SELECT ON `vn`.`routeAction` TO `grafana`;
+GRANT SELECT ON `vn`.`deviceProduction` TO `grafana`;
+GRANT SELECT ON `vn`.`invoiceOut` TO `grafana`;
+GRANT SELECT ON `vn`.`printer` TO `grafana`;
+GRANT SELECT ON `vn`.`mdbBranch` TO `grafana`;
+GRANT SELECT ON `bs`.`workerProductivity` TO `grafana`;
+GRANT SELECT ON `vn`.`config` TO `grafana`;
+GRANT SELECT ON `hedera`.`userSession` TO `grafana`;
+GRANT SELECT ON `vn`.`receipt` TO `grafana`;
+GRANT SELECT ON `vn`.`buy` TO `grafana`;
+GRANT SELECT ON `vn`.`calendarHolidays` TO `grafana`;
+GRANT SELECT ON `vn`.`parking` TO `grafana`;
+GRANT SELECT ON `vn`.`role` TO `grafana`;
+GRANT SELECT ON `vn`.`errorLogApp` TO `grafana`;
+GRANT SELECT ON `vn`.`continent` TO `grafana`;
+GRANT SELECT ON `srt`.`lastRFID` TO `grafana`;
+GRANT SELECT ON `vn`.`farmingInvoiceIn` TO `grafana`;
+GRANT SELECT ON `vn`.`agencyMode` TO `grafana`;
+GRANT SELECT ON `vn`.`absenceType` TO `grafana`;
+GRANT SELECT ON `vn`.`saleGroupDetail` TO `grafana`;
+GRANT SELECT ON `vn`.`workerMistakeType` TO `grafana`;
+GRANT SELECT ON `vn`.`mdbVersionTree` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionTruck` TO `grafana`;
+GRANT SELECT ON `vn`.`routeConfig` TO `grafana`;
+GRANT SELECT ON `vn`.`claimReason` TO `grafana`;
+GRANT SELECT ON `edi`.`log` TO `grafana`;
+GRANT SELECT ON `srt`.`failureLog` TO `grafana`;
+GRANT SELECT ON `bs`.`clientNewBorn` TO `grafana`;
+GRANT SELECT ON `vn`.`farming` TO `grafana`;
+GRANT SELECT ON `hedera`.`order` TO `grafana`;
+GRANT SELECT ON `bs`.`packingSpeed` TO `grafana`;
+GRANT SELECT ON `vn`.`expense` TO `grafana`;
+GRANT SELECT ON `vn`.`workerLabour` TO `grafana`;
+GRANT SELECT ON `hedera`.`orderRow` TO `grafana`;
+GRANT SELECT ON `srt`.`movingLog` TO `grafana`;
+GRANT SELECT ON `vn`.`warehouse` TO `grafana`;
+GRANT SELECT ON `vn`.`sector` TO `grafana`;
+GRANT SELECT ON `vn`.`salesPersonGoal` TO `grafana`;
+GRANT SELECT ON `srt`.`movingState` TO `grafana`;
+GRANT SELECT ON `vn`.`claimResult` TO `grafana`;
+GRANT SELECT ON `vn`.`routesMonitor` TO `grafana`;
+GRANT SELECT ON `vn`.`expeditionPallet` TO `grafana`;
+GRANT SELECT ON `bs`.`ventas` TO `grafana`;
+GRANT SELECT ON `vn`.`intrastat` TO `grafana`;
+GRANT SELECT ON `vn`.`printQueueArgs` TO `grafana`;
+GRANT SELECT ON `bi`.`Greuge_Evolution` TO `grafana`;
+GRANT SELECT ON `vn`.`host` TO `grafana`;
+GRANT SELECT ON `vn`.`country` TO `grafana`;
+GRANT SELECT ON `bs`.`waste` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketTracking` TO `grafana`;
+GRANT SELECT ON `vn`.`itemCategory` TO `grafana`;
+GRANT SELECT ON `vn`.`saleTracking` TO `grafana`;
+GRANT SELECT ON `vn`.`producer` TO `grafana`;
+GRANT SELECT ON `cache`.`stock` TO `grafana`;
+GRANT SELECT (name, active, role, email, id, nickname) ON `account`.`user` TO `grafana`;
+GRANT SELECT ON `vn`.`deliveryMethod` TO `grafana`;
+GRANT SELECT ON `vn`.`ticketCollection` TO `grafana`;
+GRANT EXECUTE ON PROCEDURE `vn`.`zone_upcomingdeliveries` TO `grafana`;
+GRANT EXECUTE ON PROCEDURE `vn`.`zone_getaddresses` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `util`.`firstdayofmonth` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `util`.`dayend` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `vn`.`lastdayofweek` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `vn`.`firstdayofweek` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `util`.`quarterfirstday` TO `grafana`;
+GRANT EXECUTE ON FUNCTION `util`.`firstdayofyear` TO `grafana`;
+
+FLUSH PRIVILEGES;
diff --git a/db/versions/10725-wheatAnthurium/00-firstScript.sql b/db/versions/.archive/10725-wheatAnthurium/00-firstScript.sql
similarity index 100%
rename from db/versions/10725-wheatAnthurium/00-firstScript.sql
rename to db/versions/.archive/10725-wheatAnthurium/00-firstScript.sql
diff --git a/db/versions/10726-blackMastic/00-firstScript.sql b/db/versions/.archive/10726-blackMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10726-blackMastic/00-firstScript.sql
rename to db/versions/.archive/10726-blackMastic/00-firstScript.sql
diff --git a/db/versions/10727-limeErica/00-addPrinterField.sql b/db/versions/.archive/10727-limeErica/00-addPrinterField.sql
similarity index 100%
rename from db/versions/10727-limeErica/00-addPrinterField.sql
rename to db/versions/.archive/10727-limeErica/00-addPrinterField.sql
diff --git a/db/versions/10727-limeErica/01-createTableScreenModel.sql b/db/versions/.archive/10727-limeErica/01-createTableScreenModel.sql
similarity index 100%
rename from db/versions/10727-limeErica/01-createTableScreenModel.sql
rename to db/versions/.archive/10727-limeErica/01-createTableScreenModel.sql
diff --git a/db/versions/10727-limeErica/02-createTableScreen.sql b/db/versions/.archive/10727-limeErica/02-createTableScreen.sql
similarity index 100%
rename from db/versions/10727-limeErica/02-createTableScreen.sql
rename to db/versions/.archive/10727-limeErica/02-createTableScreen.sql
diff --git a/db/versions/10727-limeErica/03-createTableScreenModel.sql b/db/versions/.archive/10727-limeErica/03-createTableScreenModel.sql
similarity index 100%
rename from db/versions/10727-limeErica/03-createTableScreenModel.sql
rename to db/versions/.archive/10727-limeErica/03-createTableScreenModel.sql
diff --git a/db/versions/10727-limeErica/04-createTableScanner.sql b/db/versions/.archive/10727-limeErica/04-createTableScanner.sql
similarity index 100%
rename from db/versions/10727-limeErica/04-createTableScanner.sql
rename to db/versions/.archive/10727-limeErica/04-createTableScanner.sql
diff --git a/db/versions/10727-limeErica/05-createTablePackingSiteDeviceLog.sql b/db/versions/.archive/10727-limeErica/05-createTablePackingSiteDeviceLog.sql
similarity index 100%
rename from db/versions/10727-limeErica/05-createTablePackingSiteDeviceLog.sql
rename to db/versions/.archive/10727-limeErica/05-createTablePackingSiteDeviceLog.sql
diff --git a/db/versions/10727-limeErica/06-alterTablePrinterModel.sql b/db/versions/.archive/10727-limeErica/06-alterTablePrinterModel.sql
similarity index 100%
rename from db/versions/10727-limeErica/06-alterTablePrinterModel.sql
rename to db/versions/.archive/10727-limeErica/06-alterTablePrinterModel.sql
diff --git a/db/versions/10727-limeErica/07-AddFieldsToPackingSite.sql b/db/versions/.archive/10727-limeErica/07-AddFieldsToPackingSite.sql
similarity index 100%
rename from db/versions/10727-limeErica/07-AddFieldsToPackingSite.sql
rename to db/versions/.archive/10727-limeErica/07-AddFieldsToPackingSite.sql
diff --git a/db/versions/10730-whiteChrysanthemum/00-firstScript.sql b/db/versions/.archive/10730-whiteChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10730-whiteChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10730-whiteChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10733-azureErica/00-firstScript.sql b/db/versions/.archive/10733-azureErica/00-firstScript.sql
similarity index 100%
rename from db/versions/10733-azureErica/00-firstScript.sql
rename to db/versions/.archive/10733-azureErica/00-firstScript.sql
diff --git a/db/versions/10736-maroonChico/00-workerBossNull.sql b/db/versions/.archive/10736-maroonChico/00-workerBossNull.sql
similarity index 100%
rename from db/versions/10736-maroonChico/00-workerBossNull.sql
rename to db/versions/.archive/10736-maroonChico/00-workerBossNull.sql
diff --git a/db/versions/10739-turquoiseCordyline/00-firstScript.sql b/db/versions/.archive/10739-turquoiseCordyline/00-firstScript.sql
similarity index 100%
rename from db/versions/10739-turquoiseCordyline/00-firstScript.sql
rename to db/versions/.archive/10739-turquoiseCordyline/00-firstScript.sql
diff --git a/db/versions/10740-pinkCataractarum/00-firstScript.sql b/db/versions/.archive/10740-pinkCataractarum/00-firstScript.sql
similarity index 100%
rename from db/versions/10740-pinkCataractarum/00-firstScript.sql
rename to db/versions/.archive/10740-pinkCataractarum/00-firstScript.sql
diff --git a/db/versions/10741-maroonMastic/01-refactorCplusTrascendency472.sql b/db/versions/.archive/10741-maroonMastic/01-refactorCplusTrascendency472.sql
similarity index 100%
rename from db/versions/10741-maroonMastic/01-refactorCplusTrascendency472.sql
rename to db/versions/.archive/10741-maroonMastic/01-refactorCplusTrascendency472.sql
diff --git a/db/versions/10741-maroonMastic/02-refactorCplusTrascendency477.sql b/db/versions/.archive/10741-maroonMastic/02-refactorCplusTrascendency477.sql
similarity index 100%
rename from db/versions/10741-maroonMastic/02-refactorCplusTrascendency477.sql
rename to db/versions/.archive/10741-maroonMastic/02-refactorCplusTrascendency477.sql
diff --git a/db/versions/10741-maroonMastic/03-refactorCplusInvoiceType477.sql b/db/versions/.archive/10741-maroonMastic/03-refactorCplusInvoiceType477.sql
similarity index 100%
rename from db/versions/10741-maroonMastic/03-refactorCplusInvoiceType477.sql
rename to db/versions/.archive/10741-maroonMastic/03-refactorCplusInvoiceType477.sql
diff --git a/db/versions/10741-maroonMastic/04-refactorCplusInvoiceType472.sql b/db/versions/.archive/10741-maroonMastic/04-refactorCplusInvoiceType472.sql
similarity index 100%
rename from db/versions/10741-maroonMastic/04-refactorCplusInvoiceType472.sql
rename to db/versions/.archive/10741-maroonMastic/04-refactorCplusInvoiceType472.sql
diff --git a/db/versions/10741-maroonMastic/05-fixes.sql b/db/versions/.archive/10741-maroonMastic/05-fixes.sql
similarity index 100%
rename from db/versions/10741-maroonMastic/05-fixes.sql
rename to db/versions/.archive/10741-maroonMastic/05-fixes.sql
diff --git a/db/versions/10744-aquaBirch/00-firstScript.sql b/db/versions/.archive/10744-aquaBirch/00-firstScript.sql
similarity index 100%
rename from db/versions/10744-aquaBirch/00-firstScript.sql
rename to db/versions/.archive/10744-aquaBirch/00-firstScript.sql
diff --git a/db/versions/10746-aquaMastic/00-firstScript.sql b/db/versions/.archive/10746-aquaMastic/00-firstScript.sql
similarity index 100%
rename from db/versions/10746-aquaMastic/00-firstScript.sql
rename to db/versions/.archive/10746-aquaMastic/00-firstScript.sql
diff --git a/db/versions/10747-brownRaphis/00-firstScript.sql b/db/versions/.archive/10747-brownRaphis/00-firstScript.sql
similarity index 100%
rename from db/versions/10747-brownRaphis/00-firstScript.sql
rename to db/versions/.archive/10747-brownRaphis/00-firstScript.sql
diff --git a/db/versions/10748-navyRose/00-firstScript.sql b/db/versions/.archive/10748-navyRose/00-firstScript.sql
similarity index 100%
rename from db/versions/10748-navyRose/00-firstScript.sql
rename to db/versions/.archive/10748-navyRose/00-firstScript.sql
diff --git a/db/versions/10748-navyRose/01-SecondScript.sql b/db/versions/.archive/10748-navyRose/01-SecondScript.sql
similarity index 100%
rename from db/versions/10748-navyRose/01-SecondScript.sql
rename to db/versions/.archive/10748-navyRose/01-SecondScript.sql
diff --git a/db/versions/10749-chocolateEucalyptus/00-firstScript.sql b/db/versions/.archive/10749-chocolateEucalyptus/00-firstScript.sql
similarity index 100%
rename from db/versions/10749-chocolateEucalyptus/00-firstScript.sql
rename to db/versions/.archive/10749-chocolateEucalyptus/00-firstScript.sql
diff --git a/db/versions/10750-limeAsparagus/00-firstScript.sql b/db/versions/.archive/10750-limeAsparagus/00-firstScript.sql
similarity index 100%
rename from db/versions/10750-limeAsparagus/00-firstScript.sql
rename to db/versions/.archive/10750-limeAsparagus/00-firstScript.sql
diff --git a/db/versions/10750-wheatGalax/00-ticket_addGrants.sql b/db/versions/.archive/10750-wheatGalax/00-ticket_addGrants.sql
similarity index 100%
rename from db/versions/10750-wheatGalax/00-ticket_addGrants.sql
rename to db/versions/.archive/10750-wheatGalax/00-ticket_addGrants.sql
diff --git a/db/versions/10751-silverArborvitae/00-firstScript.sql b/db/versions/.archive/10751-silverArborvitae/00-firstScript.sql
similarity index 100%
rename from db/versions/10751-silverArborvitae/00-firstScript.sql
rename to db/versions/.archive/10751-silverArborvitae/00-firstScript.sql
diff --git a/db/versions/10752-crimsonChrysanthemum/00-firstScript.sql b/db/versions/.archive/10752-crimsonChrysanthemum/00-firstScript.sql
similarity index 100%
rename from db/versions/10752-crimsonChrysanthemum/00-firstScript.sql
rename to db/versions/.archive/10752-crimsonChrysanthemum/00-firstScript.sql
diff --git a/db/versions/10753-blueDracena/00-firstScript.sql b/db/versions/.archive/10753-blueDracena/00-firstScript.sql
similarity index 100%
rename from db/versions/10753-blueDracena/00-firstScript.sql
rename to db/versions/.archive/10753-blueDracena/00-firstScript.sql
diff --git a/db/versions/10754-purpleMonstera/00-firstScript.sql b/db/versions/.archive/10754-purpleMonstera/00-firstScript.sql
similarity index 100%
rename from db/versions/10754-purpleMonstera/00-firstScript.sql
rename to db/versions/.archive/10754-purpleMonstera/00-firstScript.sql
diff --git a/db/versions/10755-redGalax/00-firstScript.sql b/db/versions/.archive/10755-redGalax/00-firstScript.sql
similarity index 100%
rename from db/versions/10755-redGalax/00-firstScript.sql
rename to db/versions/.archive/10755-redGalax/00-firstScript.sql
diff --git a/db/versions/10724-maroonOrchid/00-firstScript.sql b/db/versions/10724-maroonOrchid/00-firstScript.sql
new file mode 100644
index 000000000..0e9e73e4b
--- /dev/null
+++ b/db/versions/10724-maroonOrchid/00-firstScript.sql
@@ -0,0 +1,33 @@
+-- Place your SQL code here
+USE vn;
+ALTER TABLE `vn`.`saleGroup`
+ADD COLUMN IF NOT EXISTS `ticketFk` int(11) NULL,
+ADD COLUMN IF NOT EXISTS `editorFk` int(10) unsigned DEFAULT NULL;
+
+ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_FK
+ FOREIGN KEY (ticketFk) REFERENCES vn.ticket(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE vn.saleGroup
+ MODIFY COLUMN userFk int(10) unsigned DEFAULT NULL NULL;
+
+ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_userFK
+ FOREIGN KEY (userFk) REFERENCES account.`user`(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_parkingFK
+ FOREIGN KEY (parkingFk) REFERENCES vn.`parking`(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_sectorFK
+ FOREIGN KEY (sectorFk) REFERENCES vn.`sector`(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+UPDATE `vn`.`saleGroup` sg
+ JOIN (
+ SELECT sgd.saleGroupFk, s.ticketFk
+ FROM saleGroupDetail sgd
+ JOIN sale s ON s.id = sgd.saleFk
+ GROUP BY sgd.saleGroupFk
+ ) sub ON sg.id = sub.saleGroupFk
+ SET sg.ticketFk = sub.ticketFk;
+
+ALTER TABLE vn.ticketLog MODIFY COLUMN changedModel enum('Ticket','Sale','TicketWeekly','TicketTracking','TicketService','TicketRequest',
+ 'TicketRefund','TicketPackaging','TicketObservation','TicketDms','Expedition','Sms','SaleGroup')
+ CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Ticket' NOT NULL;
diff --git a/db/versions/10738-greenCordyline/00-addFieldToTravel.sql b/db/versions/10738-greenCordyline/00-addFieldToTravel.sql
new file mode 100644
index 000000000..af4903c95
--- /dev/null
+++ b/db/versions/10738-greenCordyline/00-addFieldToTravel.sql
@@ -0,0 +1,9 @@
+ALTER TABLE vn.travel DROP FOREIGN KEY IF EXISTS travel_FK_1 ;
+ALTER TABLE vn.travel DROP COLUMN IF EXISTS awbFk;
+
+ALTER TABLE vn.travel
+ ADD awbFk SMALLINT(11) UNSIGNED;
+
+ALTER TABLE vn.travel
+ ADD CONSTRAINT travel_FK_1 FOREIGN KEY (awbFk) REFERENCES vn.awb(id)
+ ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/db/versions/10738-greenCordyline/01-copyDataToTravel.sql b/db/versions/10738-greenCordyline/01-copyDataToTravel.sql
new file mode 100644
index 000000000..0469d4ce8
--- /dev/null
+++ b/db/versions/10738-greenCordyline/01-copyDataToTravel.sql
@@ -0,0 +1,9 @@
+UPDATE vn.travel t
+ JOIN(SELECT t.id travelFk, d.awbFk
+ FROM vn.dua d
+ JOIN vn.duaEntry de ON de.duaFk = d.id
+ JOIN vn.`entry` e ON e.id = de.entryFk
+ JOIN vn.travel t ON t.id = e.travelFk
+ GROUP BY t.id
+ )sub ON sub.travelFk = t.id
+ SET t.awbFk = sub.awbFk;
diff --git a/db/versions/10738-greenCordyline/03-deprecateDuaAwbFk.sql b/db/versions/10738-greenCordyline/03-deprecateDuaAwbFk.sql
new file mode 100644
index 000000000..3daf86f9b
--- /dev/null
+++ b/db/versions/10738-greenCordyline/03-deprecateDuaAwbFk.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.dua CHANGE awbFk awbFk__ smallint(11) unsigned DEFAULT NULL NULL COMMENT '@Deprecated refs #5871 01/10/2023';
+ALTER TABLE vn.dua DROP FOREIGN KEY dua_fk2;
diff --git a/db/versions/10758-boxPicking/02-agencyMode.sql b/db/versions/10758-boxPicking/02-agencyMode.sql
new file mode 100644
index 000000000..0cb71d5af
--- /dev/null
+++ b/db/versions/10758-boxPicking/02-agencyMode.sql
@@ -0,0 +1,3 @@
+UPDATE vn.agencyMode am
+ SET am.code = 'REC_ALG'
+ WHERE am.name = 'REC_ALGEMESI';
\ No newline at end of file
diff --git a/db/versions/10758-boxPicking/03-item.sql b/db/versions/10758-boxPicking/03-item.sql
new file mode 100644
index 000000000..1ba254dc0
--- /dev/null
+++ b/db/versions/10758-boxPicking/03-item.sql
@@ -0,0 +1,3 @@
+ALTER TABLE vn.item ADD isBoxPickingMode BOOLEAN DEFAULT FALSE NOT NULL
+COMMENT 'FALSE: using item.packingOut TRUE: boxPicking using itemShelving.packing';
+
diff --git a/db/versions/10764-navyTulip/00-firstScript.sql b/db/versions/10764-navyTulip/00-firstScript.sql
new file mode 100644
index 000000000..9cfbe0ccb
--- /dev/null
+++ b/db/versions/10764-navyTulip/00-firstScript.sql
@@ -0,0 +1,7 @@
+USE sage;
+
+CREATE TABLE `accountingEntryError` (
+ `accountingEntryFk` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`accountingEntryFk`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci
+ COMMENT='Listado de asientos presentes en Sage para notificar su error';
\ No newline at end of file
diff --git a/db/versions/10781-crimsonMonstera/00-firstScript.sql b/db/versions/10781-crimsonMonstera/00-firstScript.sql
new file mode 100644
index 000000000..5babdb003
--- /dev/null
+++ b/db/versions/10781-crimsonMonstera/00-firstScript.sql
@@ -0,0 +1,9 @@
+ALTER TABLE `vn`.`workerTimeControl`
+ ADD COLUMN IF NOT EXISTS `logExclude` tinyint(1) AS (IF(`manual`, FALSE, TRUE)) VIRTUAL,
+ ADD COLUMN IF NOT EXISTS `editorFk` int(10) unsigned DEFAULT NULL;
+
+ALTER TABLE `vn`.`calendar`
+ ADD COLUMN IF NOT EXISTS `editorFk` int(10) unsigned DEFAULT NULL;
+
+ALTER TABLE vn.workerLog MODIFY COLUMN changedModel enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Worker' NOT NULL;
+
diff --git a/db/versions/10784-tealCamellia/00-firstScript.sql b/db/versions/10784-tealCamellia/00-firstScript.sql
new file mode 100644
index 000000000..a5c5b519f
--- /dev/null
+++ b/db/versions/10784-tealCamellia/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE `vn`.`itemShelving`
+ADD COLUMN IF NOT EXISTS `editorFk` int(10) unsigned DEFAULT NULL;
\ No newline at end of file
diff --git a/db/versions/10808-maroonRoebelini/00-firstScript.sql b/db/versions/10808-maroonRoebelini/00-firstScript.sql
new file mode 100644
index 000000000..7f45f2522
--- /dev/null
+++ b/db/versions/10808-maroonRoebelini/00-firstScript.sql
@@ -0,0 +1,2 @@
+INSERT INTO bs.nightTask (`order`,`schema`,`procedure`)
+ VALUES (652,'sage','clean');
\ No newline at end of file
diff --git a/db/versions/10809-purpleDendro/00-firstScript.sql b/db/versions/10809-purpleDendro/00-firstScript.sql
new file mode 100644
index 000000000..53511fcb3
--- /dev/null
+++ b/db/versions/10809-purpleDendro/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.operator ADD linesLimit int DEFAULT NULL NULL COMMENT 'Límite de lineas en una colección para la asignación de pedidos';
+ALTER TABLE vn.operator ADD volumeLimit decimal DEFAULT NULL NULL COMMENT 'Límite de volumen en una colección para la asignación de pedidos';
diff --git a/db/versions/10810-turquoiseCataractarum/00-firstScript.sql b/db/versions/10810-turquoiseCataractarum/00-firstScript.sql
new file mode 100644
index 000000000..3e939e069
--- /dev/null
+++ b/db/versions/10810-turquoiseCataractarum/00-firstScript.sql
@@ -0,0 +1,7 @@
+USE sage;
+
+CREATE OR REPLACE TABLE `accountingEntryError` (
+ `accountingEntryFk` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`accountingEntryFk`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci
+ COMMENT='Listado de asientos presentes en Sage para notificar su error';
\ No newline at end of file
diff --git a/db/versions/10811-pinkBirch/00-firstScript.sql b/db/versions/10811-pinkBirch/00-firstScript.sql
new file mode 100644
index 000000000..1d02ec0d6
--- /dev/null
+++ b/db/versions/10811-pinkBirch/00-firstScript.sql
@@ -0,0 +1,7 @@
+ALTER TABLE vn.travel DROP KEY shipment_1;
+
+ALTER TABLE `vn`.`travel` ADD CONSTRAINT shipment_1 UNIQUE KEY (shipped,landed,warehouseInFk,warehouseOutFk,agencyModeFk,`ref`);
+
+ALTER TABLE vn.travel DROP FOREIGN KEY travel_ibfk_3;
+
+ALTER TABLE vn.travel CHANGE agencyFk agencyFk__ smallint(5) unsigned NOT NULL COMMENT '@deprecated 2024-10-01 refs #6604';
diff --git a/db/versions/10812-goldenPaniculata/00-update.sql b/db/versions/10812-goldenPaniculata/00-update.sql
new file mode 100644
index 000000000..3d882e546
--- /dev/null
+++ b/db/versions/10812-goldenPaniculata/00-update.sql
@@ -0,0 +1,8 @@
+UPDATE IGNORE vn.dms
+ SET dmsTypeFk = (SELECT id FROM vn.dmsType WHERE code = 'vehicle')
+ WHERE id IN (
+ SELECT d.id
+ FROM vn.dms d
+ JOIN vn.dmsType dt ON dt.id = d.dmsTypeFk
+ WHERE dt.code = 'vehicles'
+ );
diff --git a/db/versions/10812-goldenPaniculata/01-delete.sql b/db/versions/10812-goldenPaniculata/01-delete.sql
new file mode 100644
index 000000000..6d98064cc
--- /dev/null
+++ b/db/versions/10812-goldenPaniculata/01-delete.sql
@@ -0,0 +1 @@
+DELETE IGNORE FROM vn.dmsType WHERE code = 'vehicles';
diff --git a/db/versions/10812-goldenPaniculata/02-rename.sql b/db/versions/10812-goldenPaniculata/02-rename.sql
new file mode 100644
index 000000000..d98292e2f
--- /dev/null
+++ b/db/versions/10812-goldenPaniculata/02-rename.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.dmsType CHANGE `path` path__ varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL COMMENT '@deprecated 2024-01-08 refs #6410';
+ALTER TABLE vn.dmsType MODIFY COLUMN path__ varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL COMMENT '@deprecated 2024-01-08 refs #6410';
diff --git a/db/versions/10812-goldenPaniculata/03-changePosition.sql b/db/versions/10812-goldenPaniculata/03-changePosition.sql
new file mode 100644
index 000000000..9aea1fdf8
--- /dev/null
+++ b/db/versions/10812-goldenPaniculata/03-changePosition.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.dmsType CHANGE code code varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL AFTER id;
diff --git a/db/versions/10812-goldenPaniculata/04-unique.sql b/db/versions/10812-goldenPaniculata/04-unique.sql
new file mode 100644
index 000000000..5cbe32b0d
--- /dev/null
+++ b/db/versions/10812-goldenPaniculata/04-unique.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.dmsType ADD CONSTRAINT dmsType_unique UNIQUE KEY (code);
diff --git a/db/versions/10813-salmonChico/00-firstScript.sql b/db/versions/10813-salmonChico/00-firstScript.sql
new file mode 100644
index 000000000..d5bd26ca3
--- /dev/null
+++ b/db/versions/10813-salmonChico/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.entryObservation DROP FOREIGN KEY entry_id_entryFk;
+ALTER TABLE vn.entryObservation ADD CONSTRAINT entry_id_entryFk FOREIGN KEY (entryFk) REFERENCES vn.entry(id) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/db/versions/10815-brownGalax/00-firstScript.sql b/db/versions/10815-brownGalax/00-firstScript.sql
new file mode 100644
index 000000000..7812988aa
--- /dev/null
+++ b/db/versions/10815-brownGalax/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE vn.comparative DROP KEY comparative_UN;
+ALTER TABLE vn.comparative ADD CONSTRAINT comparative_unique UNIQUE KEY (timePeriod,itemFk,warehouseFk,countryFk);
\ No newline at end of file
diff --git a/db/versions/10816-yellowMonstera/00-firstScript.sql b/db/versions/10816-yellowMonstera/00-firstScript.sql
new file mode 100644
index 000000000..3dd5378f0
--- /dev/null
+++ b/db/versions/10816-yellowMonstera/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.operator MODIFY COLUMN volumeLimit decimal(10,6) DEFAULT NULL NULL COMMENT 'Límite de volumen en una colección para la asignación de pedidos';
diff --git a/db/changes/240401/02-invoiceOutConfig_refLen.sql b/db/versions/10817-navyChico/00-invoiceOutConfig_refLen.sql
similarity index 75%
rename from db/changes/240401/02-invoiceOutConfig_refLen.sql
rename to db/versions/10817-navyChico/00-invoiceOutConfig_refLen.sql
index a5f5c2088..8b91889f2 100644
--- a/db/changes/240401/02-invoiceOutConfig_refLen.sql
+++ b/db/versions/10817-navyChico/00-invoiceOutConfig_refLen.sql
@@ -1,2 +1,2 @@
-ALTER TABLE `vn`.`invoiceOutConfig`
+ALTER TABLE vn.invoiceOutConfig
ADD IF NOT EXISTS refLen TINYINT UNSIGNED DEFAULT 5 NOT NULL COMMENT 'Invoice reference identifier length';
diff --git a/db/versions/10818-crimsonCamellia/00-firstScript.sql b/db/versions/10818-crimsonCamellia/00-firstScript.sql
new file mode 100644
index 000000000..81550be61
--- /dev/null
+++ b/db/versions/10818-crimsonCamellia/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.supplier MODIFY COLUMN isSerious tinyint(1) unsigned DEFAULT 0 NOT NULL;
diff --git a/db/versions/10819-blueIvy/00-firstScript.sql b/db/versions/10819-blueIvy/00-firstScript.sql
new file mode 100644
index 000000000..b9145ec69
--- /dev/null
+++ b/db/versions/10819-blueIvy/00-firstScript.sql
@@ -0,0 +1,18 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn`.`ticketStateToday`
+AS SELECT
+ `ts`.`ticketFk` AS `ticketFk`,
+ `ts`.`state` AS `state`,
+ `ts`.`productionOrder` AS `productionOrder`,
+ `ts`.`alertLevel` AS `alertLevel`,
+ `ts`.`userFk` AS `userFk`,
+ `ts`.`code` AS `code`,
+ `ts`.`updated` AS `updated`,
+ `ts`.`isPicked` AS `isPicked`
+FROM
+ (`vn`.`ticketState` `ts`
+JOIN `vn`.`ticket` `t` ON
+ (`t`.`id` = `ts`.`ticketFk`))
+WHERE
+ `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `vn`.`MIDNIGHT`(`util`.`VN_CURDATE`());
diff --git a/db/versions/10820-limeAspidistra/00-grants.sql b/db/versions/10820-limeAspidistra/00-grants.sql
new file mode 100644
index 000000000..5e85236d4
--- /dev/null
+++ b/db/versions/10820-limeAspidistra/00-grants.sql
@@ -0,0 +1,14 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_replaceItem`() BEGIN END;
+GRANT EXECUTE ON PROCEDURE `vn`.`sale_replaceItem` TO `employee`;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_isInDepartment`()
+ RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+ RETURN 1;
+END$$
+DELIMITER ;
+
+GRANT EXECUTE ON FUNCTION `vn`.`worker_isInDepartment` TO `employee`;
+FLUSH PRIVILEGES;
diff --git a/db/versions/10827-purpleRaphis/00-firstScript.sql b/db/versions/10827-purpleRaphis/00-firstScript.sql
new file mode 100644
index 000000000..6f3a48ff1
--- /dev/null
+++ b/db/versions/10827-purpleRaphis/00-firstScript.sql
@@ -0,0 +1,10 @@
+-- Place your SQL code here
+CREATE TABLE `vn`.`negativeOrigin` (
+ `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `itemFk` INT NOT NULL,
+ `type` ENUM('FALTAS', 'CONTENEDOR', 'ENTRADAS', 'OVERBOOKING') NOT NULL,
+ `dated` DATE DEFAULT CURRENT_DATE,
+ `quantity` DECIMAL(10,2) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `unique_constraint` (`itemFk`, `type`, `dated`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
diff --git a/db/versions/10828-purpleRuscus/00-firstScript.sql b/db/versions/10828-purpleRuscus/00-firstScript.sql
new file mode 100644
index 000000000..6a02da353
--- /dev/null
+++ b/db/versions/10828-purpleRuscus/00-firstScript.sql
@@ -0,0 +1 @@
+REVOKE SELECT ON TABLE vn2008.clientes_regalos_lista_enc FROM employee;
\ No newline at end of file
diff --git a/db/versions/10828-purpleRuscus/01-RevokeClientes_regalos_lista.sql b/db/versions/10828-purpleRuscus/01-RevokeClientes_regalos_lista.sql
new file mode 100644
index 000000000..7971d9e47
--- /dev/null
+++ b/db/versions/10828-purpleRuscus/01-RevokeClientes_regalos_lista.sql
@@ -0,0 +1 @@
+REVOKE SELECT ON TABLE vn2008.credit FROM financialBoss;
\ No newline at end of file
diff --git a/db/changes/240601/00-util_tx_commit.sql b/db/versions/10832-purpleAralia/00-util_tx_commit.sql
similarity index 100%
rename from db/changes/240601/00-util_tx_commit.sql
rename to db/versions/10832-purpleAralia/00-util_tx_commit.sql
diff --git a/db/changes/240601/00-util_tx_rollback.sql b/db/versions/10832-purpleAralia/00-util_tx_rollback.sql
similarity index 100%
rename from db/changes/240601/00-util_tx_rollback.sql
rename to db/versions/10832-purpleAralia/00-util_tx_rollback.sql
diff --git a/db/changes/240601/00-util_tx_start.sql b/db/versions/10832-purpleAralia/00-util_tx_start.sql
similarity index 100%
rename from db/changes/240601/00-util_tx_start.sql
rename to db/versions/10832-purpleAralia/00-util_tx_start.sql
diff --git a/db/changes/240601/00-update_procedure_TravelCloneWithEntries.sql b/db/versions/10832-purpleAralia/01-update_procedure_TravelCloneWithEntries.sql
similarity index 100%
rename from db/changes/240601/00-update_procedure_TravelCloneWithEntries.sql
rename to db/versions/10832-purpleAralia/01-update_procedure_TravelCloneWithEntries.sql
diff --git a/db/changes/240601/00-grant_privileges_util_tx.sql b/db/versions/10832-purpleAralia/02-grant_privileges_util_tx.sql
similarity index 100%
rename from db/changes/240601/00-grant_privileges_util_tx.sql
rename to db/versions/10832-purpleAralia/02-grant_privileges_util_tx.sql
diff --git a/myt.config.yml b/myt.config.yml
index 56ab7818a..59cb47be7 100755
--- a/myt.config.yml
+++ b/myt.config.yml
@@ -3,7 +3,6 @@ versionSchema: util
replace: true
sumViews: false
mockDate: '2001-01-01 12:00:00'
-subdir: db
schemas:
- account
- bi
@@ -72,7 +71,7 @@ fixtures:
- ticketUpdateAction
- volumeConfig
- workCenter
- - workerBusinessAgreement
+ - workerTimeControlError
cache:
- cache
hedera: