From cb90e86f64ac93459b9115dd6e594f8b3c3fb683 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 29 Oct 2019 11:28:35 +0100 Subject: [PATCH] #1846 exportar produccion a la local --- db/changes/10060-summer/00-dms.sql | 23 - db/changes/10071-coffee/00-ACL.sql | 6 - db/changes/10071-coffee/00-claimLog.sql | 2 - .../10071-coffee/00-ticketAfterUpdate.sql | 14 - db/changes/10080-september/00-ACL.sql | 2 - .../10080-september/00-catalog_calculate.sql | 117 - .../00-catalog_componentCalculate.sql | 258 - .../10080-september/00-saleComponent.sql | 2 - .../10080-september/00-ticketCalculate.sql | 16 - db/changes/10080-september/00-warehouse.sql | 26 - .../10080-september/00-zoneGetLanded.sql | 47 - .../10080-september/00-zoneGetShipped.sql | 47 - db/dump/dumpedFixtures.sql | 42 +- db/dump/fixtures.sql | 12 +- db/dump/structure.sql | 4617 ++++++++++++----- .../01_descriptor.spec.js | 9 +- 16 files changed, 3268 insertions(+), 1972 deletions(-) delete mode 100644 db/changes/10060-summer/00-dms.sql delete mode 100644 db/changes/10071-coffee/00-ACL.sql delete mode 100644 db/changes/10071-coffee/00-claimLog.sql delete mode 100644 db/changes/10071-coffee/00-ticketAfterUpdate.sql delete mode 100644 db/changes/10080-september/00-ACL.sql delete mode 100644 db/changes/10080-september/00-catalog_calculate.sql delete mode 100644 db/changes/10080-september/00-catalog_componentCalculate.sql delete mode 100644 db/changes/10080-september/00-saleComponent.sql delete mode 100644 db/changes/10080-september/00-ticketCalculate.sql delete mode 100644 db/changes/10080-september/00-warehouse.sql delete mode 100644 db/changes/10080-september/00-zoneGetLanded.sql delete mode 100644 db/changes/10080-september/00-zoneGetShipped.sql diff --git a/db/changes/10060-summer/00-dms.sql b/db/changes/10060-summer/00-dms.sql deleted file mode 100644 index c06ba22fd..000000000 --- a/db/changes/10060-summer/00-dms.sql +++ /dev/null @@ -1,23 +0,0 @@ -ALTER TABLE `vn2008`.`gestdoc` -ADD COLUMN `contentType` VARCHAR(100) NULL AFTER `file`; - -CREATE - OR REPLACE ALGORITHM = UNDEFINED - DEFINER = `root`@`%` - SQL SECURITY DEFINER -VIEW `vn`.`dms` AS - SELECT - `g`.`id` AS `id`, - `g`.`gesttip_id` AS `dmsTypeFk`, - `g`.`file` AS `file`, - `g`.`contentType` AS `contentType`, - `g`.`trabajador_id` AS `workerFk`, - `g`.`warehouse_id` AS `warehouseFk`, - `g`.`emp_id` AS `companyFk`, - `g`.`orden` AS `hardCopyNumber`, - `g`.`original` AS `hasFile`, - `g`.`sref` AS `reference`, - `g`.`brief` AS `description`, - `g`.`odbc_date` AS `created` - FROM - `vn2008`.`gestdoc` `g`; diff --git a/db/changes/10071-coffee/00-ACL.sql b/db/changes/10071-coffee/00-ACL.sql deleted file mode 100644 index eab2c83f5..000000000 --- a/db/changes/10071-coffee/00-ACL.sql +++ /dev/null @@ -1,6 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('Dms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('ClaimDms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'), - ('ClaimDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Claim', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10071-coffee/00-claimLog.sql b/db/changes/10071-coffee/00-claimLog.sql deleted file mode 100644 index f7864adfc..000000000 --- a/db/changes/10071-coffee/00-claimLog.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`claimLog` -CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ; diff --git a/db/changes/10071-coffee/00-ticketAfterUpdate.sql b/db/changes/10071-coffee/00-ticketAfterUpdate.sql deleted file mode 100644 index 427ddc977..000000000 --- a/db/changes/10071-coffee/00-ticketAfterUpdate.sql +++ /dev/null @@ -1,14 +0,0 @@ -DROP TRIGGER IF EXISTS `vn2008`.`ticket_afterUpdate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`ticket_afterUpdate` - AFTER UPDATE ON `Tickets` - FOR EACH ROW -BEGIN - IF !(NEW.Id_Ticket <=> OLD.Id_Ticket) - OR !(NEW.warehouse_id <=> OLD.warehouse_id) - OR !(NEW.Fecha <=> OLD.Fecha) THEN - CALL stock.log_add('ticket', NEW.Id_Ticket, OLD.Id_Ticket); - END IF; -END$$ -DELIMITER ; diff --git a/db/changes/10080-september/00-ACL.sql b/db/changes/10080-september/00-ACL.sql deleted file mode 100644 index 77f0bd44d..000000000 --- a/db/changes/10080-september/00-ACL.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES ('Sale', 'updateConcept', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10080-september/00-catalog_calculate.sql b/db/changes/10080-september/00-catalog_calculate.sql deleted file mode 100644 index 5124c19f3..000000000 --- a/db/changes/10080-september/00-catalog_calculate.sql +++ /dev/null @@ -1,117 +0,0 @@ -DROP procedure IF EXISTS `vn`.`catalog_calculate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_calculate`( - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT) -proc: BEGIN -/** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - * @return tmp.zoneGetShipped - - **/ - - DECLARE vAvailableCalc INT; - DECLARE vShipped DATE; - DECLARE vClient INT; - DECLARE vWarehouseFk SMALLINT; - DECLARE vZoneFk INT; - DECLARE vDone BOOL; - DECLARE cTravelTree CURSOR FOR - SELECT id, warehouseFk, shipped FROM tmp.zoneGetShipped; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Establece los almacenes y las fechas que van a entrar al disponible - - SELECT clientFk INTO vClient - FROM address WHERE id = vAddressFk; - - CALL vn.zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buyFk` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT '0', - KEY `itemFk` (`itemFk`), - KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH - ) ENGINE=MEMORY DEFAULT CHARSET=utf8; - - OPEN cTravelTree; - - l: LOOP - SET vDone = FALSE; - FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL buyUltimate (vWarehouseFk, vShipped); - - INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk) - SELECT vWarehouseFk, - i.item_id, - IFNULL(i.available, 0), - bu.buyFk - FROM `cache`.available i - JOIN tmp.item br ON br.itemFk = i.item_id - LEFT JOIN item it ON it.id = i.item_id - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id - WHERE i.calc_id = vAvailableCalc - AND it.id != 100 - AND i.available > 0; - - DROP TEMPORARY TABLE tmp.buyUltimate; - END LOOP; - - CLOSE cTravelTree; - - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem - ENGINE = MEMORY - SELECT - b.itemFk, - SUM(b.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, - i.image, - o.code origin, - bl.price, - bl.priceKg - FROM tmp.ticketLot b - JOIN item i ON b.itemFk = i.id - LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible - JOIN origin o ON o.id = i.originFk - JOIN ( - SELECT MIN(price) price, itemFk, priceKg - FROM tmp.ticketComponentPrice - GROUP BY itemFk - ) bl ON bl.itemFk = b.itemFk - GROUP BY b.itemFk; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10080-september/00-catalog_componentCalculate.sql b/db/changes/10080-september/00-catalog_componentCalculate.sql deleted file mode 100644 index 6d64fc03a..000000000 --- a/db/changes/10080-september/00-catalog_componentCalculate.sql +++ /dev/null @@ -1,258 +0,0 @@ - -DROP procedure IF EXISTS `vn`.`catalog_componentCalculate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_componentCalculate`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAgencyModeFk Id del modo de agencia - * @param tmp.ticketLot (warehouseFk,available,itemFk,buyFk) - * - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) grouping, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice,(b.packing * b.weight) / 1000, NULL) weightPacking - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, z.warehouseFk - FROM priceFixed pf - JOIN zone z ON z.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0 - WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - cr.id, - GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN componentRate cr - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((z.price - z.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - HAVING cost <> 0; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN componentRate cr ON cr.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE cr.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate - FROM tmp.ticketComponent tc - JOIN componentRate cr ON cr.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) grouping, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightPacking priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing grouping, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available grouping, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END$$ - -DELIMITER ; - diff --git a/db/changes/10080-september/00-saleComponent.sql b/db/changes/10080-september/00-saleComponent.sql deleted file mode 100644 index ebb8b7176..000000000 --- a/db/changes/10080-september/00-saleComponent.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn2008`.`Movimientos_componentes` -CHANGE COLUMN `Valor` `Valor` DECIMAL(10,4) NOT NULL ; diff --git a/db/changes/10080-september/00-ticketCalculate.sql b/db/changes/10080-september/00-ticketCalculate.sql deleted file mode 100644 index 5f38f0e9a..000000000 --- a/db/changes/10080-september/00-ticketCalculate.sql +++ /dev/null @@ -1,16 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculate`( - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT) -proc: BEGIN --- OBSOLETO utilizar catalog_calculate - CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk); -END$$ - -DELIMITER ; - diff --git a/db/changes/10080-september/00-warehouse.sql b/db/changes/10080-september/00-warehouse.sql deleted file mode 100644 index 1af6e8a20..000000000 --- a/db/changes/10080-september/00-warehouse.sql +++ /dev/null @@ -1,26 +0,0 @@ -ALTER TABLE `vn2008`.`warehouse` -ADD COLUMN `hasStowaway` TINYINT(1) NOT NULL DEFAULT 0 AFTER `hasConfectionTeam`; - - -UPDATE `vn2008`.`warehouse` SET `hasStowaway` = '1' WHERE (`id` = '1'); - - - -CREATE - OR REPLACE ALGORITHM = UNDEFINED - DEFINER = `root`@`%` - SQL SECURITY DEFINER -VIEW `vn`.`warehouse` AS - SELECT - `t`.`id` AS `id`, - `t`.`name` AS `name`, - `t`.`inventario` AS `isInventory`, - `t`.`fuente` AS `isFeedStock`, - `t`.`is_comparative` AS `isComparative`, - `t`.`comisionantes` AS `hasComission`, - `t`.`reserve` AS `hasAvailable`, - `t`.`isManaged` AS `isManaged`, - `t`.`tpv` AS `isForTicket`, - `t`.`hasStowaway` AS `hasStowaway` - FROM - `vn2008`.`warehouse` `t`; diff --git a/db/changes/10080-september/00-zoneGetLanded.sql b/db/changes/10080-september/00-zoneGetLanded.sql deleted file mode 100644 index 5a50a6171..000000000 --- a/db/changes/10080-september/00-zoneGetLanded.sql +++ /dev/null @@ -1,47 +0,0 @@ -DROP procedure IF EXISTS `vn`.`zoneGetLanded`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) -BEGIN -/** -* Devuelve una tabla temporal con el dia de recepcion para vShipped. -* -* @param vShipped Fecha de preparacion de mercancia -* @param vAddressFk Id de consignatario, %NULL para recogida -* @param vAgencyModeFk Id agencia -* @table tmp.zoneGetLanded Datos de recepción -*/ - DECLARE vPostalCode varchar(10); - - SELECT postalCode INTO vPostalCode - FROM address WHERE id = vAddressFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; - CREATE TEMPORARY TABLE tmp.zoneGetLanded - ENGINE = MEMORY - SELECT - id zoneFk, - vShipped shipped, - delivered landed, - vWarehouseFk warehouseFk, - agencyModeFk, - isIncluded - FROM ( - SELECT zi.isIncluded, zc.delivered, z.id, z.agencyModeFk - FROM vn.zoneGeo zgSon - JOIN vn.zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt - JOIN zoneIncluded zi ON zi.geoFk = zgFather.id - JOIN zone z ON z.id = zi.zoneFk - JOIN zoneCalendar zc ON zc.zoneFk = z.id - WHERE zgSon.`name` LIKE vPostalCode - AND zc.delivered = TIMESTAMPADD(DAY,z.travelingDays, vShipped) - AND IF(vShipped = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) - AND z.agencyModeFk = vAgencyModeFk - AND z.warehouseFk = vWarehouseFk - ORDER BY zgFather.depth DESC) t - GROUP BY zoneFk - HAVING isIncluded > 0 - LIMIT 1; -END$$ - -DELIMITER ; diff --git a/db/changes/10080-september/00-zoneGetShipped.sql b/db/changes/10080-september/00-zoneGetShipped.sql deleted file mode 100644 index e44435797..000000000 --- a/db/changes/10080-september/00-zoneGetShipped.sql +++ /dev/null @@ -1,47 +0,0 @@ -DROP procedure IF EXISTS `vn`.`zoneGetShipped`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) -BEGIN -/** - * Devuelve la mínima fecha de envía para cada warehouse - * - * @param vLanded La fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.zoneGetShipped - */ - - DECLARE vPostalCode varchar(10); - - SELECT postalCode INTO vPostalCode - FROM address WHERE id = vAddressFk; - - SELECT * FROM ( - SELECT * FROM ( - SELECT z.id zoneFk, - TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, - vLanded landed, - vWarehouseFk warehouseFk, - z.agencyModeFk, - zi.isIncluded - FROM zoneGeo zgSon - JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt - JOIN zoneIncluded zi ON zi.geoFk = zgFather.id - JOIN zone z ON z.id = zi.zoneFk - JOIN zoneCalendar zc ON zc.zoneFk = z.id - WHERE zgSon.`name` LIKE vPostalCode - AND zc.delivered = vLanded - AND z.agencyModeFk = vAgencyModeFk - AND z.warehouseFk = vWarehouseFk - AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) - ORDER BY z.id, zgFather.depth DESC, isIncluded DESC) t - GROUP BY zoneFk - HAVING isIncluded > 0 - ORDER BY shipped) - t - GROUP BY agencyModeFk; -END$$ - -DELIMITER ; - diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index d963b5662..6c4962b99 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:52 +-- Dump completed on 2019-10-29 8:19:03 USE `account`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:52 +-- Dump completed on 2019-10-29 8:19:04 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:52 +-- Dump completed on 2019-10-29 8:19:04 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -227,7 +227,7 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'Color',0,0,'ink',NULL,NULL),(2,'Forma',1,0,NULL,NULL,NULL),(3,'Material',1,0,NULL,NULL,NULL),(4,'Longitud',1,1,NULL,'mm',NULL),(5,'Diámetro',1,1,NULL,'mm',NULL),(6,'Perímetro',1,1,NULL,'mm',NULL),(7,'Ancho de la base',1,1,NULL,'mm',NULL),(8,'Altura',1,1,NULL,'mm',NULL),(9,'Volumen',1,1,NULL,'ml',NULL),(10,'Densidad',1,1,NULL,NULL,NULL),(11,'Calidad',1,0,NULL,NULL,NULL),(12,'Textura',1,0,NULL,NULL,NULL),(13,'Material del mango',1,0,NULL,NULL,NULL),(14,'Compra mínima',1,0,NULL,NULL,NULL),(15,'Nº pétalos',1,1,NULL,NULL,NULL),(16,'Ancho',1,1,NULL,'mm',NULL),(18,'Profundidad',1,1,NULL,'mm',NULL),(19,'Largo',1,1,NULL,'mm',NULL),(20,'Ancho superior',1,1,NULL,'mm',NULL),(21,'Ancho inferior',1,1,NULL,'mm',NULL),(22,'Gramaje',1,1,NULL,'g',NULL),(23,'Tallos',1,1,NULL,NULL,NULL),(24,'Estado',1,0,NULL,NULL,NULL),(25,'Color principal',0,0,'ink',NULL,NULL),(26,'Color secundario',0,0,'ink',NULL,NULL),(27,'Longitud(cm)',1,1,NULL,'cm',NULL),(28,'Diámetro base',1,1,'','mm',NULL),(29,'Colección',1,0,NULL,NULL,NULL),(30,'Uds / caja',1,1,NULL,NULL,NULL),(31,'Contenido',1,0,NULL,NULL,NULL),(32,'Peso',1,1,NULL,'g',NULL),(33,'Grosor',1,1,NULL,'mm',NULL),(34,'Marca',1,0,NULL,NULL,NULL),(35,'Origen',0,0,'origin',NULL,NULL),(36,'Proveedor',1,0,NULL,NULL,NULL),(37,'Productor',0,0,'producer',NULL,NULL),(38,'Duración',1,1,NULL,'s',NULL),(39,'Flor',1,0,NULL,NULL,NULL),(40,'Soporte',1,0,NULL,NULL,NULL),(41,'Tamaño flor',1,0,NULL,NULL,NULL),(42,'Apertura',1,0,NULL,NULL,NULL),(43,'Tallo',1,0,NULL,NULL,NULL),(44,'Nº hojas',1,1,NULL,NULL,NULL),(45,'Dimensiones',1,0,NULL,NULL,NULL),(46,'Diámetro boca',1,1,NULL,'mm',NULL),(47,'Nº flores',1,1,NULL,NULL,NULL),(48,'Uds / paquete',1,1,NULL,NULL,NULL),(49,'Maceta',1,1,NULL,'cm',NULL),(50,'Textura flor',1,0,NULL,NULL,NULL),(51,'Textura hoja',1,0,NULL,NULL,NULL),(52,'Tipo de IVA',1,0,NULL,NULL,NULL),(53,'Tronco',1,0,NULL,NULL,NULL),(54,'Hoja',1,0,NULL,NULL,NULL),(55,'Formato',1,0,NULL,NULL,NULL),(56,'Genero',1,0,NULL,NULL,NULL),(57,'Especie',1,0,NULL,NULL,NULL),(58,'Variedad',1,0,NULL,NULL,NULL),(59,'Medida grande',1,0,NULL,NULL,NULL),(60,'Medida mediano',1,0,NULL,NULL,NULL),(61,'Medida pequeño',1,0,NULL,NULL,NULL),(62,'Medida pequeño',1,0,NULL,NULL,NULL),(63,'Recipiente interior',1,0,NULL,NULL,NULL),(64,'Material secundario',1,0,NULL,NULL,NULL),(65,'Colores',1,0,NULL,NULL,NULL),(66,'Referencia',1,0,NULL,NULL,NULL),(67,'Categoria',1,0,NULL,NULL,NULL),(68,'Amb',1,0,NULL,NULL,NULL),(69,'Anchura',1,1,NULL,'cm',NULL),(70,'Hueco interior',1,0,NULL,NULL,NULL),(71,'Tamaño',1,0,NULL,NULL,NULL),(72,'Color botón',1,0,NULL,NULL,NULL),(73,'Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'Obtentor',1,0,NULL,NULL,NULL),(75,'Longitud del brote',1,0,NULL,NULL,NULL),(76,'Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'Madera de',1,0,NULL,NULL,NULL),(78,'Unidad de venta',1,0,NULL,NULL,NULL),(79,'Temporal',1,0,NULL,NULL,NULL),(80,'Gramaje/tallo',1,1,NULL,'g',NULL),(81,'Peso/paquete',1,1,NULL,'g',NULL),(82,'Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'Nº planchas',1,1,NULL,NULL,NULL),(84,'Nº páginas',1,1,NULL,NULL,NULL),(85,'Editorial',1,0,NULL,NULL,NULL),(86,'Idioma',1,0,NULL,NULL,NULL),(87,'Fecha publicación',1,0,NULL,NULL,NULL),(88,'Cubierta',1,0,NULL,NULL,NULL),(89,'Encuadernación',1,0,NULL,NULL,NULL),(90,'Autor',1,0,NULL,NULL,NULL),(91,'Envoltorio',1,0,NULL,NULL,NULL),(92,'Nombre temporal',1,0,NULL,NULL,NULL),(93,'Modelo',1,0,NULL,NULL,NULL),(94,'Producto',1,0,NULL,NULL,NULL),(95,'Título',1,0,NULL,NULL,NULL),(96,'Tomo',1,0,NULL,NULL,NULL),(97,'Articulo',1,0,NULL,NULL,NULL),(98,'Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'Edad',1,0,NULL,NULL,NULL),(100,'Agotado',1,0,NULL,NULL,NULL),(101,'Altura con asa',1,1,NULL,'cm',NULL),(102,'Nº tallos',1,1,NULL,NULL,NULL),(103,'Cultivo',1,0,NULL,NULL,NULL),(104,'Sabor',1,0,NULL,NULL,NULL),(105,'Talla',1,0,NULL,NULL,NULL),(106,'Calibre',1,1,NULL,NULL,NULL),(107,'Dulzura',1,1,NULL,'bx',NULL),(108,'Piezas',1,0,NULL,NULL,NULL),(109,'Altura con patas',1,0,NULL,NULL,NULL); +INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -287,7 +287,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0),(2,'Libre',1,0,'FREE',NULL,2,0,0),(3,'OK',3,0,'OK',3,28,1,0),(4,'Impreso',4,1,'PRINTED',2,29,1,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1),(9,'Encajando',9,1,'PACKING',NULL,9,0,1),(10,'Encajado',10,2,'PACKED',NULL,10,0,1),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0),(24,'Encadenado',3,0,'CHAINED',4,24,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0),(28,'zz Previa',3,1,'OK PREVIOUS',3,28,1,0),(29,'zzmpreso Previa',4,1,'PRINTED PREVIOUS',2,29,1,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0),(2,'Libre',1,0,'FREE',NULL,2,0,0),(3,'OK',3,0,'OK',3,28,1,0),(4,'Impreso',4,1,'PRINTED',2,29,1,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1),(9,'Encajando',9,1,'PACKING',NULL,9,0,1),(10,'Encajado',10,2,'PACKED',NULL,10,0,1),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0),(24,'Encadenado',3,0,'CHAINED',4,24,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -300,7 +300,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:53 +-- Dump completed on 2019-10-29 8:19:05 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -349,16 +349,6 @@ INSERT INTO `department` VALUES (1,'VERDNATURA',1,78,1,0,NULL,NULL,NULL,0,0,0,0) /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `escritos` --- - -LOCK TABLES `escritos` WRITE; -/*!40000 ALTER TABLE `escritos` DISABLE KEYS */; -INSERT INTO `escritos` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,'0'),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,'0'),(3,'Cred_Up','Notificación de aumento de crédito',0,'0'),(4,'Cred_down','Notificación de reducción de crédito',0,'0'),(5,'Pet_CC','Petición de datos bancarios B2B',0,'0'),(6,'SolCredito','Solicitud de crédito',0,'0'),(7,'LeyPago','Ley de pagos',0,'0'),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,'0'),(9,'nueva_alta','Documento de nueva alta de cliente',0,'0'),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,'0'),(11,'setup_printer','Email de instalación de impresora',0,'0'),(12,'client-welcome','Email de bienvenida como nuevo cliente',1,'0'),(13,'printer-setup','Email de instalación y configuración de impresora de coronas',1,'0'),(14,'sepa-core','Email de solicitud de datos bancarios core',1,'1'),(15,'letter-debtor-st','Email de aviso inicial por saldo deudor',1,'1'),(16,'letter-debtor-nd','Email de aviso reiterado por saldo deudor',1,'1'),(17,'client-lcr','Email de solicitud de datos bancarios LCR',1,'1'); -/*!40000 ALTER TABLE `escritos` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `Grupos` -- @@ -378,7 +368,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:53 +-- Dump completed on 2019-10-29 8:19:05 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -426,7 +416,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:53 +-- Dump completed on 2019-10-29 8:19:05 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -451,7 +441,7 @@ USE `cache`; LOCK TABLES `cache` WRITE; /*!40000 ALTER TABLE `cache` DISABLE KEYS */; -INSERT INTO `cache` VALUES (1,'equalizator','00:15:00'),(2,'available','00:03:00'),(3,'stock','00:30:00'),(4,'last_buy','00:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:05:00'),(7,'sales','00:03:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:15:00'),(12,'ticketShipping','00:01:00'); +INSERT INTO `cache` VALUES (1,'equalizator','00:15:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','00:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:05:00'),(7,'sales','00:03:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:15:00'),(12,'ticketShipping','00:01:00'); /*!40000 ALTER TABLE `cache` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -464,7 +454,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:53 +-- Dump completed on 2019-10-29 8:19:05 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -532,7 +522,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:53 +-- Dump completed on 2019-10-29 8:19:05 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -557,7 +547,7 @@ USE `postgresql`; LOCK TABLES `calendar_labour_type` WRITE; /*!40000 ALTER TABLE `calendar_labour_type` DISABLE KEYS */; -INSERT INTO `calendar_labour_type` VALUES (1,'Horario general','00:20:00',40),(2,'Horario 35h/semana','00:20:00',35),(3,'Horario 20h/semana','00:00:00',20),(4,'Festivo y Fin de semana','00:00:00',0),(5,'Horario 30h/semana','00:20:00',30),(6,'Horario 25h/semana','00:20:00',25),(7,'Vacaciones trabajadas','00:00:00',0),(8,'Vacaciones','00:00:00',0),(9,'Horario 26h/semana','00:20:00',26),(10,'Horario 28h/semana','00:20:00',28),(11,'Horario 8h/semana','00:00:00',8),(12,'Horario 16h/semana','00:00:00',16),(13,'Horario 32h/semana','00:20:00',32),(14,'Horario 24h/semana','00:20:00',24),(15,'Horario 10h/semana','00:00:00',10),(16,'Horario 27,5h/semana','00:20:00',28),(17,'Horario 13,5h/semana','00:20:00',14),(18,'Horario 31h/semana',NULL,31),(19,'Horario 21,5h/semana',NULL,22),(20,'Horario 34h/semana',NULL,34),(21,'Horario 17h/semana',NULL,17),(22,'Horario 18h/semana',NULL,18),(23,'Horario 37,5 h/semana',NULL,38),(24,'Horario 29 h/semana',NULL,29),(25,'Horario 12h/semana',NULL,12),(26,'Horario 10h/semana',NULL,10),(27,'Horario 15h/semana',NULL,15),(28,'Horario 9h/semana',NULL,9),(29,'Horario 23h/semana',NULL,23),(30,'Horario 21h/semana',NULL,21),(31,'Horario 39h/semana',NULL,39); +INSERT INTO `calendar_labour_type` VALUES (1,'Horario general','00:20:00',40),(2,'Horario 35h/semana','00:20:00',35),(3,'Horario 20h/semana','00:00:00',20),(4,'Festivo y Fin de semana','00:00:00',0),(5,'Horario 30h/semana','00:20:00',30),(6,'Horario 25h/semana','00:20:00',25),(7,'Vacaciones trabajadas','00:00:00',0),(8,'Vacaciones','00:00:00',0),(9,'Horario 26h/semana','00:20:00',26),(10,'Horario 28h/semana','00:20:00',28),(11,'Horario 8h/semana','00:00:00',8),(12,'Horario 16h/semana','00:00:00',16),(13,'Horario 32h/semana','00:20:00',32),(14,'Horario 24h/semana','00:20:00',24),(15,'Horario 10h/semana','00:00:00',10),(16,'Horario 27,5h/semana','00:20:00',28),(17,'Horario 13,5h/semana','00:20:00',14),(18,'Horario 31h/semana',NULL,31),(19,'Horario 21,5h/semana',NULL,22),(20,'Horario 34h/semana',NULL,34),(21,'Horario 17h/semana',NULL,17),(22,'Horario 18h/semana',NULL,18),(23,'Horario 37,5 h/semana',NULL,38),(24,'Horario 29 h/semana',NULL,29),(25,'Horario 12h/semana',NULL,12),(26,'Horario 10h/semana',NULL,10),(27,'Horario 15h/semana',NULL,15),(28,'Horario 9h/semana',NULL,9),(29,'Horario 23h/semana',NULL,23),(30,'Horario 21h/semana',NULL,21),(31,'Horario 39h/semana',NULL,39),(32,'Horario 22/semana',NULL,22); /*!40000 ALTER TABLE `calendar_labour_type` ENABLE KEYS */; UNLOCK TABLES; @@ -577,7 +567,7 @@ UNLOCK TABLES; LOCK TABLES `media_type` WRITE; /*!40000 ALTER TABLE `media_type` DISABLE KEYS */; -INSERT INTO `media_type` VALUES (3,'email'),(8,'extension centr'),(12,'extension movil'),(6,'facebook'),(2,'fijo'),(11,'material'),(10,'movil empresa'),(1,'movil personal'),(5,'msn'),(9,'seg social'),(4,'skype'),(7,'web'); +INSERT INTO `media_type` VALUES (3,'email'),(12,'extension movil'),(6,'facebook'),(2,'fijo'),(11,'material'),(10,'movil empresa'),(1,'movil personal'),(5,'msn'),(9,'seg social'),(4,'skype'),(7,'web'); /*!40000 ALTER TABLE `media_type` ENABLE KEYS */; UNLOCK TABLES; @@ -607,7 +597,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1023,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20007,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2851,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,2,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1024,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20007,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2851,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,2,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -620,4 +610,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 13:22:54 +-- Dump completed on 2019-10-29 8:19:06 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 904e6ecc9..043e444b0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -57,13 +57,13 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, (19,'Francia', 1, 'FR', 1, 25), (30,'Canarias', 1, 'IC', 1, 22); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`) +INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`) VALUES - (1, 'Warehouse One', 1, 1, 1, 1, 1), - (2, 'Warehouse Two', 1, 1, 1, 1, 0), - (3, 'Warehouse Three', 1, 1, 1, 1, 0), - (4, 'Warehouse Four', 1, 1, 1, 1, 0), - (5, 'Warehouse Five', 1, 1, 1, 1, 0); + (1, 'Warehouse One', 1, 1, 1, 1, 1, 1), + (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0), + (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0), + (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0), + (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index cc01e461f..5949652ed 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -365,7 +365,7 @@ CREATE TABLE `user` ( KEY `nickname` (`nickname`), KEY `lang` (`lang`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16659 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=16753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1977,7 +1977,7 @@ CREATE TABLE `analisis_ventas` ( `Importe` double NOT NULL, PRIMARY KEY (`id`), KEY `Año` (`Año`,`Semana`) -) ENGINE=InnoDB AUTO_INCREMENT=95145162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=103478749 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2458,7 +2458,7 @@ CREATE TABLE `rutasBoard` ( KEY `rutasBoard_ix1` (`year`), KEY `rutasBoard_ix2` (`month`), KEY `rutasBoard_ix3` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=177952 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=182527 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3400,6 +3400,48 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `comparativa_add_manual`(IN dat_START DATE, IN dat_END DATE) +BEGIN + + DECLARE datINI DATETIME; + DECLARE datFIN DATETIME; + + -- Seleccionamos la fecha minima/maxima del periodo que vamos a consultar + SELECT MIN(`date`) INTO datINI FROM vn2008.`time` WHERE period = vn2008.vnperiod(dat_START); + SELECT TIMESTAMP(MAX(`date`),'23:59:59') INTO datFIN FROM vn2008.`time` WHERE period = vn2008.vnperiod(dat_END); + + DELETE FROM vn2008.Comparativa WHERE Periodo BETWEEN vn2008.vnperiod(dat_START) and vn2008.vnperiod(dat_END); + + REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) + SELECT tm.period AS Periodo + , M.Id_Article + , t.warehouse_id + , SUM(Cantidad) AS Total + , sum(v.importe) AS precio + FROM vn2008.Movimientos M + JOIN vn2008.Tickets t on t.Id_Ticket = M.Id_Ticket + JOIN bs.ventas v on v.Id_Movimiento = M.Id_Movimiento + JOIN vn2008.`time` tm on tm.`date` = v.fecha + WHERE v.fecha BETWEEN datINI and datFIN + AND t.warehouse_id NOT IN (0,13) + GROUP BY Id_Article, Periodo, t.warehouse_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 DROP PROCEDURE IF EXISTS `comparativa_add_manual__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `comparativa_add_manual__`(IN dat_START DATE, IN dat_END DATE) BEGIN DECLARE datINI DATETIME; @@ -3433,6 +3475,66 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `comparativa_add__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `comparativa_add__`() +BEGIN + DECLARE lastCOMP INT; # Se trata de una variable para almacenar el ultimo valor del Periodo + + SELECT MAX(Periodo) INTO lastCOMP FROM vn2008.Comparativa; + -- Fijaremos las ventas con más de un mes de antiguedad en la tabla Comparativa + + IF lastCOMP < vn2008.vnperiod(CURDATE())- 3 AND vn2008.vnweek(CURDATE()) > 3 THEN + + REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) + SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + FROM bs.ventas v + JOIN vn2008.time tm ON tm.date = v.fecha + JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento + JOIN vn2008.Articles a ON a.Id_Article = m.Id_Article + JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id + JOIN vn2008.reinos r ON r.id = tp.reino_id + JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + WHERE tm.period BETWEEN lastCOMP AND vn2008.vnperiod(CURDATE())- 3 + AND t.Id_Cliente NOT IN(400,200) + AND r.display <> 0 + AND t.warehouse_id NOT IN (0,13) + GROUP BY Id_Article, Periodo, warehouse_id; + + +/* + REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) + SELECT vn2008.vnperiod(T.Fecha) AS Periodo + , Id_Article + , warehouse_id + , SUM(Cantidad) AS Total + , SUM(Cantidad * Preu * (100 - Descuento) / 100) precio + FROM vn2008.Movimientos M + JOIN vn2008.Tickets T USING (Id_Ticket) + JOIN vn2008.Articles A USING (Id_Article) + LEFT JOIN vn2008.Tipos ti ON ti.tipo_id = A.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = ti.reino_id + WHERE T.Fecha BETWEEN TIMESTAMPADD(DAY,-60,CURDATE()) AND TIMESTAMPADD(DAY,-30,CURDATE()) + AND T.Id_Cliente NOT IN(400,200) + AND display <> 0 AND warehouse_id NOT IN (0,13) + GROUP BY Id_Article, Periodo, warehouse_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 DROP PROCEDURE IF EXISTS `customer_risk_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5314,7 +5416,7 @@ CREATE TABLE `m3` ( `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, `euros` decimal(10,2) DEFAULT '0.00', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=333865 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=348493 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5586,7 +5688,7 @@ CREATE TABLE `payMethodClient` ( KEY `FkDateClientPayMethod` (`dated`,`clientFk`), CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5262603 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=5496925 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5660,7 +5762,7 @@ CREATE TABLE `productivity` ( `m3FV` double NOT NULL DEFAULT '0', `m3PCA` double NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=55717733 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=57558212 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8081,25 +8183,28 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ventas_add`(IN datSTART DATETIME, IN datEND DATETIME) BEGIN - DECLARE vStartingPeriod INT; DECLARE vStartingDate DATETIME; DECLARE vEndingDate DATETIME; DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; + IF datSTART < '2015-10-01' OR datEND < '2015-10-01' THEN + CALL util.throw('fechaDemasiadoAntigua'); + END IF; + SET datEND = util.dayEnd(datEND); - SET vStartingDate = GREATEST('2015-10-01',datSTART); + SET vStartingDate = datSTART; SET vEndingDate = vn2008.dayend(vStartingDate); DELETE FROM ventas WHERE fecha between vStartingDate and datEND; - + WHILE vEndingDate <= datEND DO REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id) SELECT Id_Movimiento, - sum( IF(base, Cantidad * Valor, 0) ) as importe, - sum( IF(base, 0, Cantidad * Valor) ) as recargo, + SUM(IF(base, Cantidad * Valor, 0)) as importe, + SUM(IF(base, 0, Cantidad * Valor)) as recargo, vStartingDate, a.tipo_id, cs.Id_Cliente, @@ -8114,17 +8219,10 @@ BEGIN JOIN vn2008.Tickets t using(Id_Ticket) JOIN vn2008.Consignatarios cs using(Id_Consigna) JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - -- JOIN vn2008.empresa e on e.id = empresa_id WHERE t.Fecha between vStartingDate and vEndingDate - AND datEND >= '2015-10-01' - AND ( - c.`Real` != 0 - OR c.Razonsocial = 'MIRIAM FERRER TORIBIO' - OR c.Razonsocial = 'VERDNATURA COMPLEMENTOS' - ) + AND c.typeFk IN ('Normal','handMaking','internalUse') AND m.Cantidad <> 0 AND a.tipo_id != TIPO_PATRIMONIAL - AND c.Id_Trabajador IS NOT NULL AND m.Descuento <> 100 AND (m.Id_Article = 98 or m.Id_Article = 95 or r.mercancia != 0) GROUP BY mc.Id_Movimiento @@ -8156,6 +8254,73 @@ BEGIN call bs.ventas_add(timestampadd(week,-1,curdate()),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 DROP PROCEDURE IF EXISTS `ventas_add__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ventas_add__`(IN datSTART DATETIME, IN datEND DATETIME) +BEGIN + + DECLARE vStartingDate DATETIME; + DECLARE vEndingDate DATETIME; + DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; + + SET datEND = util.dayEnd(datEND); + SET vStartingDate = GREATEST('2015-10-01',datSTART); + SET vEndingDate = vn2008.dayend(vStartingDate); + + DELETE + FROM ventas + WHERE fecha between vStartingDate and datEND; + + WHILE vEndingDate <= datEND DO + + REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id) + SELECT Id_Movimiento, + SUM(IF(base, Cantidad * Valor, 0)) as importe, + SUM(IF(base, 0, Cantidad * Valor)) as recargo, + vStartingDate, + a.tipo_id, + cs.Id_Cliente, + t.empresa_id + FROM vn2008.Movimientos_componentes mc + JOIN bi.tarifa_componentes tc using(Id_Componente) + JOIN bi.tarifa_componentes_series tcs using(tarifa_componentes_series_id) + JOIN vn2008.Movimientos m using(Id_Movimiento) + JOIN vn2008.Articles a using(Id_Article) + JOIN vn2008.Tipos tp using(tipo_id) + JOIN vn2008.reinos r on r.id = tp.reino_id + JOIN vn2008.Tickets t using(Id_Ticket) + JOIN vn2008.Consignatarios cs using(Id_Consigna) + JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente + WHERE t.Fecha between vStartingDate and vEndingDate + AND datEND >= '2015-10-01' + AND c.typeFk IN ('Normal','handMaking','internalUse') + AND m.Cantidad <> 0 + AND a.tipo_id != TIPO_PATRIMONIAL + AND c.Id_Trabajador IS NOT NULL + AND m.Descuento <> 100 + AND (m.Id_Article = 98 or m.Id_Article = 95 or r.mercancia != 0) + GROUP BY mc.Id_Movimiento + HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0; + + SET vStartingDate = TIMESTAMPADD(DAY,1, vStartingDate); + SET vEndingDate = util.dayEnd(vStartingDate); + + END WHILE; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8712,7 +8877,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=420472 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=427497 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8780,7 +8945,7 @@ CREATE TABLE `prod_graphic_source` ( `alert_level` int(11) NOT NULL DEFAULT '0', `Agencia` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1736097 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2194685 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9827,7 +9992,7 @@ CREATE TABLE `deliveryInformation` ( KEY `fgbSupplyResponse_idx2` (`FirstOrderDateTime`), KEY `fgbSupplyResponse_idx3` (`LatestOrderDateTime`), CONSTRAINT `fgbSupplyResponse` FOREIGN KEY (`supplyResponseID`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=22972859 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23557098 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9885,7 +10050,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1074726 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1090965 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9906,7 +10071,7 @@ CREATE TABLE `exchange` ( KEY `buy_edi_id` (`ektFk`), CONSTRAINT `exchange_ibfk_1` FOREIGN KEY (`mailFk`) REFERENCES `mail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `exchange_ibfk_2` FOREIGN KEY (`ektFk`) REFERENCES `ekt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=616189 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=631820 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10168,7 +10333,7 @@ CREATE TABLE `mail` ( UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`senderFk`) REFERENCES `mailSender` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=645441 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=662254 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10424,7 +10589,7 @@ CREATE TABLE `supplyResponse` ( PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' -) ENGINE=InnoDB AUTO_INCREMENT=8308985 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8579292 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11121,7 +11286,7 @@ CREATE TABLE `image` ( PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=162533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=166220 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11685,7 +11850,7 @@ CREATE TABLE `news` ( KEY `tag` (`tag`), CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`account` (`id`) ON UPDATE CASCADE, CONSTRAINT `news_ibfk_2` FOREIGN KEY (`tag`) REFERENCES `newsTag` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13069 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11802,7 +11967,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2175727 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2216881 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11921,7 +12086,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13100407 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13288054 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12342,10 +12507,10 @@ CREATE TABLE `tpvTransaction` ( KEY `user_id` (`clientFk`), KEY `response` (`response`), KEY `error_code` (`errorCode`), - CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn2008`.`Recibos` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=359597 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=366419 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12380,7 +12545,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgentFk`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgentFk`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1958131 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1981341 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12400,7 +12565,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agentFk`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agentFk`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4346138 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4413749 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12425,7 +12590,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccessFk`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visitFk`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccessFk`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2593055 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2621308 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12445,7 +12610,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`userFk`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`accessFk`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3809843 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3871949 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15932,7 +16097,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDB AUTO_INCREMENT=306064 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=311674 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16763,7 +16928,7 @@ CREATE TABLE `bank_account` ( CONSTRAINT `bank_account_bank_account_type_id_fkey` FOREIGN KEY (`bank_account_type_id`) REFERENCES `bank_account_type` (`bank_account_type_id`) ON UPDATE CASCADE, CONSTRAINT `bank_account_nation_id_fkey` FOREIGN KEY (`nation_id`) REFERENCES `nation` (`nation_id`) ON UPDATE CASCADE, CONSTRAINT `bank_profile` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=930 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=932 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16818,7 +16983,7 @@ CREATE TABLE `business` ( KEY `bussiness_provider` (`provider_id`), CONSTRAINT `business_client` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bussiness_provider` FOREIGN KEY (`provider_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2914 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2995 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16957,7 +17122,7 @@ CREATE TABLE `calendar_labour_type` ( `hours_week` smallint(6) DEFAULT NULL, PRIMARY KEY (`calendar_labour_type_id`), UNIQUE KEY `hours_labour_hours_labour_id_key` (`calendar_labour_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17032,7 +17197,7 @@ CREATE TABLE `income_employee` ( KEY `fperson_id` (`person_id`), CONSTRAINT `fincometype_id` FOREIGN KEY (`id_incomeType`) REFERENCES `incometype_employee` (`id_incometype`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fperson_id` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=72197 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=72942 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17066,7 +17231,7 @@ CREATE TABLE `journey` ( PRIMARY KEY (`journey_id`), KEY `fki_business_journey` (`business_id`), CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business_labour` (`business_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2413 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2449 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17102,7 +17267,7 @@ CREATE TABLE `media` ( PRIMARY KEY (`media_id`), KEY `media_media_type_id_idx` (`media_type_id`), CONSTRAINT `media_ibfk_1` FOREIGN KEY (`media_type_id`) REFERENCES `media_type` (`media_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1145 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1156 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17269,7 +17434,7 @@ CREATE TABLE `profile_media` ( KEY `profile_media_profile_id_idx` (`profile_id`), CONSTRAINT `fk_profile_media_media1` FOREIGN KEY (`media_id`) REFERENCES `media` (`media_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `media_ibfk_20` FOREIGN KEY (`profile_id`) REFERENCES `profile` (`profile_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1305 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1317 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -18875,7 +19040,7 @@ CREATE TABLE `debug` ( `variable` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; +) ENGINE=InnoDB AUTO_INCREMENT=546 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19815,7 +19980,7 @@ CREATE TABLE `addressObservation` ( KEY `addressObservationFgn_idx` (`observationTypeFk`), CONSTRAINT `addressFgn` FOREIGN KEY (`addressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4108 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=4140 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19907,7 +20072,7 @@ CREATE TABLE `agencyMode` ( PRIMARY KEY (`id`), KEY `Agencias` (`name`), KEY `Vista` (`deliveryMethodFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20086,7 +20251,7 @@ CREATE TABLE `autoRadioLogCall` ( PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=1424 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1700 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20274,7 +20439,7 @@ CREATE TABLE `businessReasonEnd` ( `id` tinyint(3) NOT NULL AUTO_INCREMENT, `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20340,7 +20505,7 @@ CREATE TABLE `buy` ( CONSTRAINT `buy_ibfk_3` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=343287549 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=347003652 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20650,7 +20815,7 @@ CREATE TABLE `claim` ( CONSTRAINT `claim_ibfk_3` FOREIGN KEY (`claimStateFk`) REFERENCES `claimState` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_4` FOREIGN KEY (`claimDepartmentFk`) REFERENCES `vn2008`.`cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=69135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=70559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20672,7 +20837,7 @@ CREATE TABLE `claimBeginning` ( KEY `cl_main_id` (`claimFk`), CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=152813 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=155367 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20782,7 +20947,7 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_7` FOREIGN KEY (`claimReasonFk`) REFERENCES `claimReason` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_8` FOREIGN KEY (`claimResultFk`) REFERENCES `claimResult` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59853 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=60743 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20817,7 +20982,7 @@ CREATE TABLE `claimDms` ( PRIMARY KEY (`claimFk`,`dmsFk`), KEY `dmsFk_idx` (`dmsFk`), CONSTRAINT `claimFk` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -20843,7 +21008,7 @@ CREATE TABLE `claimEnd` ( CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=116375 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=118249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20887,7 +21052,7 @@ CREATE TABLE `claimLog` ( KEY `userFk` (`userFk`), CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1710 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4544 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21031,7 +21196,7 @@ CREATE TABLE `claimState` ( PRIMARY KEY (`id`), KEY `roleFgn_idx` (`roleFk`), CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Estados posibles de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Estados posibles de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21165,7 +21330,7 @@ CREATE TABLE `client` ( CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=16657 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21180,15 +21345,6 @@ DELIMITER ;; BEFORE INSERT ON `client` FOR EACH ROW BEGIN - DECLARE isAlreadyUsedIf BOOL; - - SELECT COUNT(*) INTO isAlreadyUsedIf - FROM client - WHERE `fi` = TRIM(NEW.`fi`); - - IF isAlreadyUsedIf THEN - CALL util.throw('El NIF/CIF está repetido'); - END IF; CALL pbx.phone_isValid(NEW.phone); CALL pbx.phone_isValid(NEW.mobile); @@ -21215,16 +21371,7 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vText VARCHAR(255) DEFAULT NULL; - DECLARE isAlreadyUsedIf BOOL; - - SELECT (COUNT(*) > 1) INTO isAlreadyUsedIf - FROM client - WHERE `fi` = TRIM(NEW.`fi`); - - IF isAlreadyUsedIf THEN - CALL util.throw('El NIF/CIF está repetido'); - END IF; - + -- Comprueba que el formato de los teléfonos es válido IF !(NEW.phone <=> OLD.phone) THEN @@ -21331,7 +21478,7 @@ CREATE TABLE `clientContact` ( `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4148 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4150 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21352,7 +21499,7 @@ CREATE TABLE `clientCredit` ( KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=82635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=84200 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21415,7 +21562,7 @@ CREATE TABLE `clientDms` ( PRIMARY KEY (`dmsFk`), KEY `gest_doc_id` (`dmsFk`), KEY `fk_clientes_gestdoc_1_idx` (`clientFk`), - CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -21457,7 +21604,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=231874 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=236131 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21492,8 +21639,49 @@ CREATE TABLE `clientObservation` ( KEY `Id_Cliente` (`clientFk`), CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=77629 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=78262 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`@`%`*/ /*!50003 TRIGGER `vn`.`clientObservation_AFTER_INSERT` AFTER INSERT ON `clientObservation` FOR EACH ROW +BEGIN +/* DECLARE vMailSender VARCHAR(90); + DECLARE vUserName VARCHAR(30); + DECLARE vUserId INT ; + + SELECT u.name, u.id INTO vUserName, vUserId + FROM account.user u + JOIN vn.worker w ON w.userFk = u.id + WHERE w.id = NEW.workerFk; + + SELECT CONCAT(salesPerson.name, '@verdnatura.es, ',vUserName, '@verdnatura.es') INTO vMailSender + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN account.user salesPerson ON salesPerson.id = w.userFk + WHERE c.id = NEW.clientFk + AND salesPerson.id <> vUserId; + + IF vMailSender >'' THEN + INSERT INTO vn.mail SET + `sender` = vMailSender, + `replyTo` = CONCAT(vUserName, '@verdnatura.es'), + `subject` = CONCAT ('Nota añadida al cliente ', NEW.clientFk) , + `body` = CONCAT(vUserName, ' ha añadido la siguiente nota: ', NEW.`text`); + 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 */ ; -- -- Temporary table structure for view `clientObservation__` @@ -21562,7 +21750,7 @@ CREATE TABLE `clientSample` ( PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18322 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18421 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22213,7 +22401,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3238 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3256 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -22258,7 +22446,7 @@ CREATE TABLE `creditInsurance` ( PRIMARY KEY (`id`), KEY `CreditInsurance_Fk1_idx` (`creditClassification`), CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=3103 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -22454,7 +22642,7 @@ CREATE TABLE `device` ( PRIMARY KEY (`id`), KEY `device_fk1_idx` (`userFk`), CONSTRAINT `device_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=276 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=348 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22479,7 +22667,7 @@ CREATE TABLE `deviceProduction` ( KEY `departmentFgn` (`departmentFk`), CONSTRAINT `departmentFgn` FOREIGN KEY (`departmentFk`) REFERENCES `vn2008`.`department` (`department_id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `deviceProductionModelsFgn` FOREIGN KEY (`modelFk`) REFERENCES `deviceProductionModels` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=344 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=359 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22544,27 +22732,106 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `dms` +-- Table structure for table `dms` -- DROP TABLE IF EXISTS `dms`; -/*!50001 DROP VIEW IF EXISTS `dms`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `dms` AS SELECT - 1 AS `id`, - 1 AS `dmsTypeFk`, - 1 AS `file`, - 1 AS `contentType`, - 1 AS `workerFk`, - 1 AS `warehouseFk`, - 1 AS `companyFk`, - 1 AS `hardCopyNumber`, - 1 AS `hasFile`, - 1 AS `reference`, - 1 AS `description`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `dms` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dmsTypeFk` int(11) NOT NULL DEFAULT '1', + `reference` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '791', + `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, + `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, + `hasFile` tinyint(4) NOT NULL DEFAULT '0', + `workerFk` int(11) NOT NULL, + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), + KEY `trabajador_id` (`workerFk`), + KEY `warehouse_id` (`warehouseFk`) +) ENGINE=InnoDB AUTO_INCREMENT=1369291 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`@`%`*/ /*!50003 TRIGGER `vn`.`dms_beforeInsert` BEFORE INSERT ON `vn`.`dms` FOR EACH ROW +BEGIN + DECLARE vHardCopyNumber INT; + DECLARE vDmsTypeCode INT; + -- DECLARE vHasDms INT; + + IF NEW.warehouseFk = 44 THEN + SET NEW.warehouseFk = 1; + END IF; + -- SELECT hasDms INTO vHasDms FROM warehouse WHERE id = NEW.warehouseFk; + +-- IF !vHasDms THEN +-- CALL util.throw ('DMS_UNAVAILABLE_FOR_THIS_WAREHOUSE'); +-- END IF; + + IF NEW.hasFile THEN + SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber + FROM dms + WHERE companyFk = NEW.companyFk + AND warehouseFk = NEW.warehouseFk ; + + SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1) ; + END IF; +-- Marca Firmado a uno cada vez que se escanea un Ticket de forma que desaparezca del TNAC JGF 27/08/13 + 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 = 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`@`%`*/ /*!50003 TRIGGER `vn`.`dms_beforeUpdate` BEFORE UPDATE ON `vn`.`dms` FOR EACH ROW +BEGIN + DECLARE vHardCopyNumber INT; + IF (NEW.hasFile <> 0) AND (OLD.hasFile = 0) AND (NEW.hardCopyNumber IS NULL) THEN + + SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber + FROM dms + WHERE companyFk = NEW.companyFk + AND 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 */ ; -- -- Table structure for table `dmsType` @@ -22605,6 +22872,29 @@ SET character_set_client = utf8; 1 AS `code`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `dms__` +-- + +DROP TABLE IF EXISTS `dms__`; +/*!50001 DROP VIEW IF EXISTS `dms__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `dms__` AS SELECT + 1 AS `id`, + 1 AS `dmsTypeFk`, + 1 AS `file`, + 1 AS `contentType`, + 1 AS `workerFk`, + 1 AS `warehouseFk`, + 1 AS `companyFk`, + 1 AS `hardCopyNumber`, + 1 AS `hasFile`, + 1 AS `reference`, + 1 AS `description`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `doc` -- @@ -22649,10 +22939,10 @@ CREATE TABLE `dua` ( KEY `fk_awb_dua_awb_idx` (`awbFk`), KEY `fk_dua_gestdoc1_idx` (`gestdocFk`), KEY `dua_fk4_idx` (`companyFk`), - CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4271 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22693,7 +22983,7 @@ CREATE TABLE `duaIntrastat` ( KEY `duaIntrastat_fk2_idx` (`duaFk`), CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7085 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22713,7 +23003,7 @@ CREATE TABLE `duaInvoiceIn` ( KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`), CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaInvoiceIn_fk2` FOREIGN KEY (`invoiceInFk`) REFERENCES `vn2008`.`recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5119 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; +) ENGINE=InnoDB AUTO_INCREMENT=5218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22738,7 +23028,7 @@ CREATE TABLE `duaTax` ( CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=9165 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9856 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22874,7 +23164,7 @@ CREATE TABLE `entry` ( CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=179070 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=180472 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23075,7 +23365,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=168919 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=172753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23126,7 +23416,7 @@ CREATE TABLE `envialiaCity` ( PRIMARY KEY (`id`), KEY `agencyFk` (`agencyFk`), KEY `postalCode` (`postalCode`) -) ENGINE=InnoDB AUTO_INCREMENT=1423686 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1504426 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23322,7 +23612,7 @@ CREATE TABLE `expedition` ( KEY `index4` (`ticketFk`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3322463 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3387233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23600,7 +23890,7 @@ CREATE TABLE `greuge` ( KEY `Greuges_cliente_idx` (`clientFk`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3719157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; +) ENGINE=InnoDB AUTO_INCREMENT=3764930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23700,14 +23990,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayLegend` +-- Temporary table structure for view `holidayLegend__` -- -DROP TABLE IF EXISTS `holidayLegend`; -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +DROP TABLE IF EXISTS `holidayLegend__`; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayLegend` AS SELECT +/*!50001 CREATE VIEW `holidayLegend__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; @@ -23852,7 +24142,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=22714 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25433 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24130,7 +24420,7 @@ CREATE TABLE `invoiceOut` ( CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=517213 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=517490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24256,7 +24546,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=131089 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; +) ENGINE=InnoDB AUTO_INCREMENT=131368 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24299,7 +24589,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1160150 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1160471 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24405,14 +24695,14 @@ CREATE TABLE `item` ( CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=370493 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=372970 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -24431,36 +24721,6 @@ BEGIN SET NEW.density = vDensity; END IF; - -- Migration -/* - SET NEW.longName = NEW.Article; - - IF NEW.producerFk is not null THEN - SELECT name INTO vProducerFk FROM producer WHERE id = NEW.producerFk; - SET NEW.subname = vProducerFk; - END IF; - - IF NEW.size IS NOT NULL AND NEW.value5 IS NULL THEN - SET NEW.tag5 ='Medida'; - SET NEW.value5 = NEW.size; - END IF; - - IF NEW.inkFk IS NOT NULL AND NEW.value6 IS NULL THEN - SET NEW.tag6 ='Color'; - SELECT name INTO vInkName FROM vn.ink i where i.id = NEW.inkFk; - SET NEW.value6 = vInkName; - END IF; - - IF NEW.category IS NOT NULL AND NEW.value7 IS NULL THEN - SET NEW.tag7 ='Categoria'; - SET NEW.value7 = NEW.category; - END IF; - - IF NEW.stems IS NOT NULL AND NEW.value8 IS NULL THEN - SET NEW.tag8 ='Tallos'; - SET NEW.value8 = NEW.stems; - END IF; -*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24562,7 +24822,7 @@ CREATE TABLE `itemBarcode` ( UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42076 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42383 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24789,7 +25049,7 @@ CREATE TABLE `itemLog` ( KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=79534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=88268 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24812,7 +25072,7 @@ CREATE TABLE `itemPlacement` ( KEY `Articles_nicho_wh_fk` (`warehouseFk`), CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=923937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=945360 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24830,14 +25090,17 @@ CREATE TABLE `itemPlacementSupply` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userFk` int(10) unsigned NOT NULL COMMENT 'Persona que crea la orden', `repoUserFk` int(10) unsigned DEFAULT NULL COMMENT 'Reponedor que la tiene asignada', + `sectorFk` int(11) NOT NULL DEFAULT '2', PRIMARY KEY (`id`), KEY `itemPlacementSupply_fk1_idx` (`itemFk`), KEY `itemPlacementSupply_fk2_idx` (`userFk`), KEY `itemPlacementSupply_fk2_idx1` (`repoUserFk`), + KEY `itemPlacementSupply_fk4_idx` (`sectorFk`), CONSTRAINT `itemPlacementSupply_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemPlacementSupply_fk3` FOREIGN KEY (`repoUserFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=66694 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; + CONSTRAINT `itemPlacementSupply_fk3` FOREIGN KEY (`repoUserFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemPlacementSupply_fk4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=76477 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24866,6 +25129,32 @@ SET character_set_client = utf8; 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `itemPlacementSupplyList__` +-- + +DROP TABLE IF EXISTS `itemPlacementSupplyList__`; +/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemPlacementSupplyList__` AS SELECT + 1 AS `id`, + 1 AS `itemFk`, + 1 AS `quantity`, + 1 AS `priority`, + 1 AS `created`, + 1 AS `userFk`, + 1 AS `repoUserFk`, + 1 AS `saldo`, + 1 AS `longName`, + 1 AS `subName`, + 1 AS `size`, + 1 AS `workerCode`, + 1 AS `repoCode`, + 1 AS `parking`, + 1 AS `sectorFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `itemPlacement__` -- @@ -24921,15 +25210,57 @@ CREATE TABLE `itemShelving` ( `packing` int(11) unsigned DEFAULT NULL, `packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `level` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1', + `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), KEY `itemShelving_fk3_idx` (`packagingFk`), + KEY `itemShelving_fk3_idx1` (`userFk`), CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=122994 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; +) ENGINE=InnoDB AUTO_INCREMENT=134741 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_INSERT` BEFORE INSERT ON `itemShelving` FOR EACH ROW +BEGIN + + SET NEW.userFk = account.userGetId(); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE` BEFORE UPDATE ON `itemShelving` FOR EACH ROW +BEGIN + + SET NEW.userFk = account.userGetId(); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `itemShelvingAvailable` @@ -25004,8 +25335,8 @@ CREATE TABLE `itemShelvingPlacementSupply` ( KEY `itemShelvingPlacementSupply_fk2_idx` (`itemPlacementSupplyFk`), KEY `itemShelvingPlacementSupply_fk3_idx` (`userFk`), CONSTRAINT `itemShelvingPlacementSupply_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=63490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; + CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=71946 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25017,6 +25348,31 @@ DROP TABLE IF EXISTS `itemShelvingPlacementSupplyStock`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `itemShelvingPlacementSupplyStock` AS SELECT + 1 AS `itemShelvingFk`, + 1 AS `itemFk`, + 1 AS `quantity`, + 1 AS `packing`, + 1 AS `stock`, + 1 AS `longName`, + 1 AS `size`, + 1 AS `subName`, + 1 AS `shelving`, + 1 AS `parking`, + 1 AS `created`, + 1 AS `priority`, + 1 AS `parkingFk`, + 1 AS `sectorFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `itemShelvingPlacementSupplyStock__` +-- + +DROP TABLE IF EXISTS `itemShelvingPlacementSupplyStock__`; +/*!50001 DROP VIEW IF EXISTS `itemShelvingPlacementSupplyStock__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemShelvingPlacementSupplyStock__` AS SELECT 1 AS `itemShelvingFk`, 1 AS `itemFk`, 1 AS `quantity`, @@ -25052,7 +25408,7 @@ CREATE TABLE `itemShelvingSale` ( CONSTRAINT `itemShelvingSale_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk2` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=27331 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; +) ENGINE=InnoDB AUTO_INCREMENT=34770 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25179,7 +25535,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1351662 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1371893 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25324,7 +25680,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=848655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=865183 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25399,7 +25755,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemType_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=281 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; +) ENGINE=InnoDB AUTO_INCREMENT=282 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25448,6 +25804,22 @@ CREATE TABLE `itemTypeI18n` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemTypeI18nFr` +-- + +DROP TABLE IF EXISTS `itemTypeI18nFr`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemTypeI18nFr` ( + `id` int(11) NOT NULL, + `code` text COLLATE utf8_unicode_ci, + `es` text COLLATE utf8_unicode_ci, + `fr` text COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `itemTypeL10n` -- @@ -25693,7 +26065,7 @@ CREATE TABLE `mandate` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`mandateTypeFk`) REFERENCES `mandateType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17123 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=17197 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25839,7 +26211,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1996780 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2037918 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25861,7 +26233,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2170346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2212646 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26091,7 +26463,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=2624 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2762 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26194,7 +26566,7 @@ CREATE TABLE `parking` ( UNIQUE KEY `code_UNIQUE` (`code`), KEY `parking_fk1_idx` (`sectorFk`), CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26462 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=26777 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -26776,7 +27148,7 @@ CREATE TABLE `producer` ( `isVisible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=13508 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13852 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27081,14 +27453,96 @@ CREATE TABLE `rateConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `receipt` +-- Table structure for table `receipt` -- DROP TABLE IF EXISTS `receipt`; -/*!50001 DROP VIEW IF EXISTS `receipt`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `receipt` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `invoiceFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `amountPaid` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountUnpaid` decimal(10,2) NOT NULL DEFAULT '0.00', + `payed` datetime DEFAULT NULL, + `workerFk` int(11) DEFAULT '0', + `bankFk` int(11) DEFAULT '0', + `clientFk` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `isConciliate` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + PRIMARY KEY (`Id`), + KEY `Id_Banco` (`bankFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `empresa_id` (`companyFk`), + KEY `clientDate` (`clientFk`,`payed`), + KEY `id_factura` (`invoiceFk`), + CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=603891 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW + CALL bi.customer_risk_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_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW +BEGIN + CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, OLD.amountPaid); + CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, -NEW.amountPaid); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW + CALL bi.customer_risk_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 */ ; + +-- +-- Temporary table structure for view `receipt__` +-- + +DROP TABLE IF EXISTS `receipt__`; +/*!50001 DROP VIEW IF EXISTS `receipt__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `receipt` AS SELECT +/*!50001 CREATE VIEW `receipt__` AS SELECT 1 AS `id`, 1 AS `invoiceFk`, 1 AS `amountPaid`, @@ -27120,7 +27574,7 @@ CREATE TABLE `recovery` ( KEY `cliente_idx` (`clientFk`), CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=311 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDB AUTO_INCREMENT=313 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27209,8 +27663,8 @@ CREATE TABLE `route` ( KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), KEY `gestdoc_id` (`gestdocFk`), - CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=58055 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=59301 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -27301,7 +27755,7 @@ CREATE TABLE `routeComplement` ( KEY `fgn_routeActionFk_idx` (`routeActionFk`), CONSTRAINT `fgn_routeActionFk` FOREIGN KEY (`routeActionFk`) REFERENCES `routeAction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgn_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=901 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=983 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27404,7 +27858,7 @@ CREATE TABLE `routeLog` ( KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=137343 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=172833 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27515,7 +27969,7 @@ CREATE TABLE `sale` ( KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26058259 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=26240792 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -27549,10 +28003,12 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `sale_beforeUpdate` BEFORE UPDATE ON `sale` FOR EACH ROW -BEGIN +BEGIN + IF NEW.discount > 100 THEN SET NEW.discount = 0; END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27752,8 +28208,9 @@ CREATE TABLE `saleTracking` ( UNIQUE KEY `stateFk_UNIQUE` (`stateFk`,`saleFk`), KEY `Id_Movimiento` (`saleFk`), KEY `fgnStateFk_idx` (`stateFk`), + KEY `saleTracking_idx5` (`created`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20057318 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20603603 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -27871,14 +28328,31 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `sample` +-- Table structure for table `sample` -- DROP TABLE IF EXISTS `sample`; -/*!50001 DROP VIEW IF EXISTS `sample`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sample` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, + `isVisible` tinyint(4) NOT NULL DEFAULT '1', + `hasCompany` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `sample__` +-- + +DROP TABLE IF EXISTS `sample__`; +/*!50001 DROP VIEW IF EXISTS `sample__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `sample` AS SELECT +/*!50001 CREATE VIEW `sample__` AS SELECT 1 AS `id`, 1 AS `code`, 1 AS `description`, @@ -27905,7 +28379,7 @@ CREATE TABLE `sector` ( UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27927,7 +28401,7 @@ CREATE TABLE `sharingCart` ( KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2179 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2194 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -28136,7 +28610,7 @@ CREATE TABLE `sms` ( `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=148755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=152649 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28325,7 +28799,7 @@ CREATE TABLE `stockBuyed` ( UNIQUE KEY `date_UNIQUE` (`date`,`user`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=814563 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=834233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28388,7 +28862,7 @@ CREATE TABLE `supplier` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2908 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2926 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28413,7 +28887,7 @@ CREATE TABLE `supplierAccount` ( KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), KEY `fk_banco_prov_account_idx` (`bankFk`) -) ENGINE=InnoDB AUTO_INCREMENT=860 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=865 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28527,6 +29001,7 @@ DROP TABLE IF EXISTS `tag`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(45) CHARACTER SET utf8 NOT NULL, `name` varchar(25) CHARACTER SET utf8 NOT NULL, `isFree` tinyint(1) NOT NULL DEFAULT '1', `isQuantitatif` tinyint(4) NOT NULL DEFAULT '0', @@ -28768,7 +29243,7 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2431569 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2459711 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -28905,14 +29380,51 @@ CREATE TABLE `ticketConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `ticketDms` +-- Table structure for table `ticketDms` -- DROP TABLE IF EXISTS `ticketDms`; -/*!50001 DROP VIEW IF EXISTS `ticketDms`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketDms` ( + `ticketFk` int(11) NOT NULL, + `dmsFk` int(11) NOT NULL, + PRIMARY KEY (`ticketFk`,`dmsFk`), + KEY `gestdoc_id` (`dmsFk`), + CONSTRAINT `ticketDms_dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketDms_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`@`%`*/ /*!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; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Temporary table structure for view `ticketDms__` +-- + +DROP TABLE IF EXISTS `ticketDms__`; +/*!50001 DROP VIEW IF EXISTS `ticketDms__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketDms` AS SELECT +/*!50001 CREATE VIEW `ticketDms__` AS SELECT 1 AS `ticketFk`, 1 AS `dmsFk`*/; SET character_set_client = @saved_cs_client; @@ -29006,7 +29518,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7462981 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7832496 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29043,7 +29555,7 @@ CREATE TABLE `ticketObservation` ( KEY `observation_type_id` (`observationTypeFk`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1473664 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1492852 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29098,7 +29610,7 @@ CREATE TABLE `ticketPackaging` ( CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=73741 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=75355 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -29161,7 +29673,7 @@ CREATE TABLE `ticketParking` ( KEY `ticketParking_fk1_idx` (`parkingFk`), CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3105 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +) ENGINE=InnoDB AUTO_INCREMENT=6708 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29227,7 +29739,7 @@ CREATE TABLE `ticketRequest` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=50635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=51479 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -29486,7 +29998,7 @@ CREATE TABLE `ticketWeekly` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`ticketFk`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2397961 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2459705 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29760,7 +30272,7 @@ CREATE TABLE `trainingCourse` ( CONSTRAINT `frgnCenter` FOREIGN KEY (`centerFk`) REFERENCES `trainingCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnTrainingCourseType` FOREIGN KEY (`trainingCourseTypeFk`) REFERENCES `trainingCourseType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=434 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29812,7 +30324,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn2008`.`Proveedores_cargueras` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=138681 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=140224 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30048,14 +30560,39 @@ CREATE TABLE `userConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `vehicle` +-- Table structure for table `vehicle` -- DROP TABLE IF EXISTS `vehicle`; -/*!50001 DROP VIEW IF EXISTS `vehicle`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vehicle` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `numberPlate` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `model` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `tradeMark` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `m3` double DEFAULT NULL, + `isActive` tinyint(4) NOT NULL DEFAULT '1', + `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `empresa_id` (`companyFk`), + KEY `provinceFk_idx` (`warehouseFk`), + CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=449 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `vehicle__` +-- + +DROP TABLE IF EXISTS `vehicle__`; +/*!50001 DROP VIEW IF EXISTS `vehicle__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `vehicle` AS SELECT +/*!50001 CREATE VIEW `vehicle__` AS SELECT 1 AS `id`, 1 AS `numberPlate`, 1 AS `tradeMark`, @@ -30085,7 +30622,8 @@ SET character_set_client = utf8; 1 AS `hasAvailable`, 1 AS `isManaged`, 1 AS `isForTicket`, - 1 AS `hasStowaway`*/; + 1 AS `hasStowaway`, + 1 AS `hasDms`*/; SET character_set_client = @saved_cs_client; -- @@ -30119,14 +30657,29 @@ CREATE TABLE `workCenter` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `workCenterHoliday` +-- Table structure for table `workCenterHoliday` -- DROP TABLE IF EXISTS `workCenterHoliday`; -/*!50001 DROP VIEW IF EXISTS `workCenterHoliday`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workCenterHoliday` ( + `workCenterFk` int(11) NOT NULL, + `days` double NOT NULL, + `year` smallint(6) NOT NULL, + PRIMARY KEY (`workCenterFk`,`year`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `workCenterHoliday__` +-- + +DROP TABLE IF EXISTS `workCenterHoliday__`; +/*!50001 DROP VIEW IF EXISTS `workCenterHoliday__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `workCenterHoliday` AS SELECT +/*!50001 CREATE VIEW `workCenterHoliday__` AS SELECT 1 AS `workCenterFk`, 1 AS `days`, 1 AS `year`*/; @@ -30254,8 +30807,8 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, - CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12433 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=12702 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30320,7 +30873,7 @@ CREATE TABLE `workerJourney` ( UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=51536010 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=55379352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30359,7 +30912,7 @@ CREATE TABLE `workerLog` ( KEY `userFk_idx` (`userFk`), CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `workerFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=14891 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15762 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30423,7 +30976,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8262896 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=8281636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30763,7 +31316,7 @@ CREATE TABLE `zone` ( KEY `zone_name_idx` (`name`), CONSTRAINT `fk_zone_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=444 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=452 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30805,7 +31358,7 @@ CREATE TABLE `zoneGeo` ( KEY `name_idx` (`name`), KEY `parentFk` (`parentFk`), KEY `path` (`path`) -) ENGINE=InnoDB AUTO_INCREMENT=597452 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=597454 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -31314,8 +31867,7 @@ BEGIN * @param vM3 m3 del articulo * @param vAddressFk * @param vZoneFk - * @param vRetailedPrice precio de venta sin iva - * @return tmp.catalog_component (warehouse_id, item_id, component_id, cost) + * @returnvRetailedPrice precio de venta sin iva */ DECLARE vBoxVolume BIGINT; @@ -31325,7 +31877,6 @@ BEGIN DECLARE vDeliveryComponent INT DEFAULT 15; DECLARE vComponentMargin INT DEFAULT 29; DECLARE vComponentCost INT DEFAULT 28; - DECLARE vCost DECIMAL(10,2); DECLARE vRetailedPrice DECIMAL(10,2); DECLARE vItem INT DEFAULT 98; @@ -31336,12 +31887,26 @@ BEGIN SELECT clientFk INTO vCustomer FROM address WHERE id = vAddressFk; DROP TEMPORARY TABLE IF EXISTS tmp.catalog_component; - CREATE TEMPORARY TABLE tmp.catalog_component LIKE - vn2008.template_catalog_component; - + CREATE TEMPORARY TABLE tmp.catalog_component ( + `warehouseFk` INT UNSIGNED NOT NULL, + `itemFk` INT NOT NULL, + `componentFk` INT UNSIGNED NOT NULL, + `cost` DECIMAL(10,4) NOT NULL, + INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), + UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); + + -- Cost + INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) + SELECT vWarehouse, vItem, vComponentCost, vCost + FROM vn.rate + WHERE dated <= CURDATE() + AND warehouseFk = vWarehouse + ORDER BY dated DESC + LIMIT 1; + -- Margen - INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) - SELECT vWarehouse, vItem, vComponentMargin, vCost / (100 - rate2) + INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) + SELECT vWarehouse, vItem, vComponentMargin, vCost / ((100 - rate2) / 100) FROM vn.rate WHERE dated <= CURDATE() AND warehouseFk = vWarehouse @@ -31349,20 +31914,20 @@ BEGIN LIMIT 1; -- Recobro - INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3) FROM bi.claims_ratio WHERE Id_Cliente = vCustomer AND recobro > 0.009; -- Componente de maná automático, en función del maná acumulado por el comercial. - INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentMana, ROUND(prices_modifier_rate, 3) FROM client c JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador WHERE ms.prices_modifier_activated AND c.id = vCustomer LIMIT 1; -- Reparto - INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vDeliveryComponent, ROUND( vM3 @@ -32249,12 +32814,14 @@ BEGIN (tls.code ='PICKER_DESIGNED' AND tls.worker = vWorker) OR (tls.code = 'PRINTED_BACK') + OR + (tls.code = 'PRINTED PREVIOUS') ); SELECT ticket INTO vTicket FROM tmp.production_buffer - ORDER BY (code = 'PICKER_DESIGNED') DESC, Hora, Minuto, (code = 'PRINTED_BACK') DESC , loadingOrder + ORDER BY (code = 'PICKER_DESIGNED') DESC, (code = 'PRINTED PREVIOUS') DESC ,Hora, Minuto, loadingOrder LIMIT 1; -- Aviso de ticket para bajar @@ -32869,6 +33436,50 @@ BEGIN AND warehouseFk = vWarehouseFk; RETURN vPlacementReserve; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `itemShelvingPlacementSupply_ClosestGet` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11) + READS SQL DATA +BEGIN + + /* Devuelve el parking más cercano.*/ + DECLARE vColumn INT; + DECLARE vClosestParkingFk INT; + DECLARE vSectorFk INT; + + SELECT p.column, sectorFk INTO vColumn, vSectorFk + FROM vn.parking p + WHERE p.id = vParkingFk; + + SELECT itemShelvingFk INTO vClosestParkingFk + FROM + ( + SELECT ABS(p.column - vColumn) as distance, itemShelvingFk + FROM vn.itemShelvingPlacementSupplyStock ispss + JOIN vn.parking p ON p.id = ispss.parkingFk + JOIN vn.itemPlacementSupplyList ipsl ON ipsl.sectorFk = ispss.sectorFk AND ipsl.itemFk = ispss.itemFk + WHERE p.sectorFk = vSectorFk + AND ipsl.saldo > 0 + ) sub + ORDER BY distance + LIMIT 1; + + RETURN vClosestParkingFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35452,9 +36063,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -35501,7 +36112,7 @@ BEGIN vUserFk, CONCAT('TR ', vFirstname, ' ', vSurnames), vAddress, - vFi, + TRIM(vFi), vPhone, vProvinceFk, vCity, @@ -36467,8 +37078,9 @@ BEGIN * */ -DECLARE vLastDate DATETIME DEFAULT '2018-10-30 23:59'; +DECLARE vLastDate DATETIME DEFAULT '2019-10-30 23:59'; DECLARE vWarehouse INT DEFAULT 1; +DECLARE vPalletVolume INT DEFAULT 2200000; SELECT date(sub2.dat) dat, sub2.longName, @@ -36489,7 +37101,7 @@ FROM i.longName, i.size, i.subName, - sum(e.amount * r.cm3) / 2000000 as entra, + sum(e.amount * r.cm3) / vPalletVolume as entra, 0 as sale FROM vn2008.item_entry_in e JOIN vn.item i ON i.id = e.item_id @@ -36510,7 +37122,7 @@ FROM i.size, i.subName, 0 as entra, - sum(s.amount * r.cm3) / 2000000 as sale + sum(s.amount * r.cm3) / vPalletVolume as sale FROM vn2008.item_out s JOIN vn.item i ON i.id = s.item_id JOIN vn.itemType it ON it.id = i.typeFk @@ -36528,7 +37140,7 @@ FROM i.longName, i.size, i.subName, - st.amount * r.cm3 / 2000000 , + st.amount * r.cm3 / vPalletVolume , @saldo := 0 FROM cache.stock st JOIN vn.item i ON i.id = st.item_id @@ -36543,8 +37155,12 @@ FROM LEFT JOIN ( SELECT itemFk, - - sum(visible / packing) as pal - FROM vn.itemShelving WHERE shelvingFk = 'FUE' + - sum(ish.visible ) * r.cm3 / vPalletVolume as pal + FROM vn.itemShelving ish + JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = 1 + LEFT JOIN vn.shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN vn.parking p ON p.id = sh.parkingFk + WHERE (sh.code = 'FUE' OR p.code = 'FUE-PI') GROUP BY itemFk) fue ON fue.itemFk = sub2.itemFk AND sub2.dat = util.yesterday() ; END ;; @@ -37190,7 +37806,7 @@ BEGIN s.nif TERNIF, s.name TERNOM, d.companyFk, - IFNULL(d.bookEntried, d.booked) FECREGCON + d.booked FECREGCON FROM duaTax dt JOIN dua d ON dt.duaFk = d.id JOIN (SELECT account, rate @@ -37206,87 +37822,7 @@ BEGIN JOIN supplier s ON s.id = d.companyFk WHERE d.id = vDuaFk GROUP BY dt.rate; -/* - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - FECHA_EX, - FECHA_OP, - FACTURAEX, - NFACTICK, - L340, - LDIFADUAN, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id, - FECREGCON - ) - SELECT - vBookNumber ASIEN, - vBookDated FECHA, - tr.account SUBCTA, - inv.account CONTRA, - dt.tax EURODEBE, - dt.base BASEEURO, - CONCAT('COMPRA s/fra ',inv.supplierRef,':',LEFT(inv.name, 10)) CONCEPTO, - inv.serialNumber FACTURA, - dt.rate IVA, - '*' AUXILIAR, - 'W' SERIE, - d.issued FECHA_EX, - d.operated FECHA_OP, - d.code FACTURAEX, - 1 NFACTICK, - 1 L340, - TRUE LDIFADUAN, - 1 TIPOCLAVE, - 1 TIPOEXENCI, - 1 TIPONOSUJE, - 5 TIPOFACT, - 1 TIPORECTIF, - IF(inv.countryFk IN (30, 1), 1, 4) TERIDNIF, - inv.nif TERNIF, - inv.name TERNOM, - d.companyFk, - IFNULL(d.bookEntried, d.booked) FECREGCON - FROM duaTax dt - JOIN dua d ON dt.duaFk = d.id - JOIN (SELECT account, rate - FROM - (SELECT rate, account - FROM invoiceInTaxBookingAccount ta - WHERE ta.effectived <= vBookDated - AND taxAreaFk = 'WORLD' - ORDER BY ta.effectived DESC - ) tba - GROUP BY rate - ) tr ON tr.rate = dt.rate - JOIN - (SELECT s.countryFk, s.account, ii.supplierRef, s.name, ii.id as serialNumber, s.nif, s.id - FROM duaEntry de - JOIN entry e ON e.id = de.entryFk - JOIN invoiceIn ii ON ii.id = e.invoiceInFk - JOIN supplier s ON s.id = ii.supplierFk - GROUP BY s.id - ) inv ON inv.id = dt.supplierFk - WHERE d.id = vDuaFk; -*/ SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte FROM vn2008.XDiario WHERE ASIEN = vBookNumber; @@ -38075,7 +38611,7 @@ BEGIN DECLARE vAvailableCalc INT; -- FIXME: Android app is always passing %TRUE for #vRefresh, this leads to DB performance issues - CALL cache.visible_refresh(vVisibleCalc, vRefresh, vWarehouse); + CALL cache.visible_refresh(vVisibleCalc, FALSE /*vRefresh*/, vWarehouse); CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/, vWarehouse, vDate); SELECT a.Id_Article, a.Article, a.Medida, a.Tallos, @@ -38137,11 +38673,12 @@ BEGIN UPDATE vn2008.intrastat_data id JOIN ( SELECT i.intrastatFk, - sum(r.cm3 * b.quantity) * i.density / 1000000 as neto + sum(r.cm3 * b.quantity) * IF(i.density, i.density, it.density) / 1000000 as neto FROM vn.entry e JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.buy b ON b.entryFk = e.id JOIN vn.item i ON i.id = b.itemFk + join vn.itemType it ON it.id = i.typeFk JOIN bi.rotacion r ON r.Id_Article = i.id AND tr.warehouseInFk = r.warehouse_id WHERE e.invoiceInFk = vinvoiceInFk GROUP BY i.intrastatFk) sub ON sub.intrastatFk = id.intrastat_id @@ -40322,7 +40859,7 @@ BEGIN AND vWarehouse = tr.warehouseInFk AND b.itemFk = vItemId AND e.isInventory = 0 - + AND e.isRaid = 0 UNION ALL SELECT tr.shipped as date, @@ -40354,7 +40891,7 @@ BEGIN AND b.itemFk = vItemId AND e.isInventory = 0 AND w.isFeedStock = 0 - + AND e.isRaid = 0 UNION ALL SELECT t.shipped as date, @@ -40415,14 +40952,17 @@ BEGIN sale.venta, IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, IFNULL(v.amount,0) - reserva + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as saldo - FROM cache.stock v + FROM vn.item i JOIN ( - SELECT itemFk, CAST(SUM(visible) AS DECIMAL(10,0)) AS reserva - FROM vn.itemShelving - WHERE shelvingFk = 'FUE' - GROUP BY itemFk - ) alt ON alt.itemFk = v.item_id - JOIN vn.item i ON i.id = alt.itemFk + SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva + FROM vn.itemShelving ish + LEFT JOIN vn.shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN vn.parking p ON p.id = sh.parkingFk + WHERE (ish.shelvingFk = 'FUE' + OR p.code = 'FUE-PI') + GROUP BY ish.itemFk + ) alt ON alt.itemFk = i.id + LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = 1 LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta FROM vn2008.item_out @@ -40446,7 +40986,7 @@ BEGIN GROUP BY item_id ) mov ON mov.item_id = alt.itemFk - WHERE v.warehouse_id = 1; + ; END ;; DELIMITER ; @@ -40470,11 +41010,84 @@ CREATE DEFINER=`root`@`%` PROCEDURE `itemGetVisibleAvailable`( vWarehouse TINYINT, vRefresh BOOL) BEGIN + + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; + + CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/, vWarehouse, vDate); + CALL cache.visible_refresh(vVisibleCalc, FALSE,vWarehouse); + + IF vRefresh THEN + + DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_item; + CREATE TEMPORARY TABLE vn2008.tmp_item + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT vItem item_id, 0 stock, 0 visible; + + SELECT i.id, i.longName, i.box, i.typeFk, + i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8, + ip.code, ip.reserve, + st.amount + vi.visible as visible, + av.available + FROM vn.item i + LEFT JOIN vn.itemPlacement ip + ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse + LEFT JOIN vn2008.tmp_item v + ON v.item_id = i.id + LEFT JOIN cache.available av + ON av.calc_id = vAvailableCalc AND av.item_id = i.id + LEFT JOIN cache.visible vi + ON vi.calc_id = vVisibleCalc AND vi.item_id = i.id + LEFT JOIN cache.stock st + ON st.warehouse_id = vWarehouse AND st.item_id = i.id + WHERE (vItem IS NULL OR i.id = vItem); + + ELSE + + SELECT i.id, i.longName, i.box, i.typeFk, + i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8, + ip.code, ip.reserve, + v.visible, + av.available + FROM vn.item i + LEFT JOIN vn.itemPlacement ip + ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse + LEFT JOIN cache.visible v + ON v.item_id = i.id AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av + ON av.item_id = i.id AND av.calc_id = vAvailableCalc + WHERE (vItem IS NULL OR i.id = vItem); + + 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 DROP PROCEDURE IF EXISTS `itemGetVisibleAvailable__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemGetVisibleAvailable__`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) +BEGIN DECLARE vVisibleCalc INT; DECLARE vAvailableCalc INT; -- FIXME: Android app is always passing %TRUE for #vRefresh, this leads to DB performance issues - CALL cache.visible_refresh(vVisibleCalc, vRefresh, vWarehouse); + CALL cache.visible_refresh(vVisibleCalc, FALSE /*vRefresh*/, vWarehouse); CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/, vWarehouse, vDate); SELECT i.id, i.longName, i.box, i.typeFk, @@ -40761,6 +41374,56 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT ) +BEGIN + + DECLARE vId INT; + DECLARE vLastParkingFk INT; + DECLARE vNextParkingFk INT; + + SELECT sh.parkingFk INTO vLastParkingFk + FROM vn.itemShelvingPlacementSupply isps + JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + WHERE isps.userFk = getUser() + ORDER BY isps.created DESC + LIMIT 1; + + SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk); + + SELECT ipsl.id INTO vId + FROM vn.itemPlacementSupplyList ipsl + JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk + WHERE ipsl.saldo > 0 + AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser()) + AND ipsl.sectorFk = vSector + ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created + LIMIT 1; + + UPDATE vn.itemPlacementSupply + SET repoUserFk = getUser() + WHERE id = vId; + + SELECT * FROM vn.itemPlacementSupplyList + WHERE id = vId + AND sectorFk = vSector; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyGetOrder__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyGetOrder__`(vSector INT ) BEGIN DECLARE vId INT; @@ -40778,7 +41441,8 @@ BEGIN WHERE id = vId; SELECT * FROM vn.itemPlacementSupplyList - WHERE id = vId; + WHERE id = vId + AND sectorFk = vSector; END ;; DELIMITER ; @@ -40802,13 +41466,27 @@ BEGIN SELECT shelving, parking, sum(stock) as stockTotal,created FROM ( - SELECT * - FROM vn.itemShelvingPlacementSupplyStock + SELECT `ispss`.`itemShelvingFk` AS `itemShelvingFk`, + `ispss`.`itemFk` AS `itemFk`, + `ispss`.`quantity` AS `quantity`, + `ispss`.`packing` AS `packing`, + `ispss`.`stock` AS `stock`, + `ispss`.`longName` AS `longName`, + `ispss`.`size` AS `size`, + `ispss`.`subName` AS `subName`, + `ispss`.`shelving` AS `shelving`, + `ispss`.`parking` AS `parking`, + `ispss`.`created` AS `created`, + `ispss`.`priority` AS `priority`, + `ispss`.`parkingFk` AS `parkingFk`, + `ispss`.`sectorFk` AS `sectorFk` + FROM vn.itemShelvingPlacementSupplyStock ispss LEFT JOIN vn.parking p ON p.code = parking - WHERE itemFk = vItemFk AND p.sectorFk = vSectorFk - ORDER BY priority DESC, created + WHERE itemFk = vItemFk AND p.sectorFk = vSectorFk AND stock > 0 + ORDER BY priority DESC ) sub - GROUP BY shelving; + GROUP BY shelving + ORDER BY parking ASC; END ;; DELIMITER ; @@ -41231,31 +41909,32 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingList`(IN `vShelvingFk` VARCHAR(8)) -BEGIN - - /*MODIFICADA POR QUIQUE: OBTENEMOS DEEP Y PARKING*/ - SELECT ish.itemFk as item, - IFNULL(i.longName, CONCAT(i.name, ' ',i.size)) as description, - ish.visible as visible, - ceil(ish.visible/ish.packing) as stickers, - ish.packing as packing, - p.`column` as col, - p.`row` as `row`, - ish.id, - s.priority - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - INNER JOIN vn.shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci - LEFT JOIN vn.parking p ON s.parkingFk = p.id - WHERE ish.shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci; - +BEGIN + + /*MODIFICADA POR QUIQUE: OBTENEMOS DEEP Y PARKING*/ + SELECT ish.itemFk as item, + IFNULL(i.longName, CONCAT(i.name, ' ',i.size)) as description, + ish.visible as visible, + ceil(ish.visible/ish.packing) as stickers, + ish.packing as packing, + p.`column` as col, + p.`row` as `row`, + p.`code` as `code`, + ish.id, + s.priority + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + INNER JOIN vn.shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci + LEFT JOIN vn.parking p ON s.parkingFk = p.id + WHERE ish.shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41571,7 +42250,7 @@ BEGIN FROM vn.sector WHERE id = vSectorFk; - CALL cache.visible_refresh(vCalcVisibleFk, FALSE, vWarehouseFk); + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; @@ -41593,7 +42272,8 @@ BEGIN i.minimum * b.packing itemPlacementSize, ips.onTheWay, iss.visible itemShelvingStock, - IFNULL(v.visible,0) visible + IFNULL(v.visible,0) visible, + b.isPickedOff FROM vn.itemShelvingStock iss JOIN vn.item i on i.id = iss.itemFk LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iss.itemFk AND ip.warehouseFk = vWarehouseFk @@ -41606,7 +42286,7 @@ BEGIN WHERE saldo > 0 GROUP BY itemFk ) ips ON ips.itemFk = i.id - WHERE iss.sectorFk =vSectorFk ; + WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) ; DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; CREATE TEMPORARY TABLE tmp.itemOutTime @@ -41930,6 +42610,38 @@ BEGIN WHERE calc_id = vCalc AND item_id = vItemFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemStockVisible_verify` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemStockVisible_verify`(vItemFk INT, vQuantity INT) +BEGIN + + INSERT INTO vn.itemShelving(itemFk, + shelvingFk, + quantity, + visible, + available, + packing) + VALUES( vItemFk, + 'FAL', + -vQuantity, + -vQuantity, + -vQuantity, + -vQuantity); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -43310,13 +44022,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `payRoll`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vFullDay BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `payRoll`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vPartTime BOOL) BEGIN SET @userFk := 0; @@ -43371,10 +44083,10 @@ BEGIN GROUP BY userFk ) se ON se.userFk = wj.userFk WHERE wj.dated BETWEEN vFromDated AND vToDated - AND IF(vFullDay,cl.hours_week <= 40,cl.hours_week < 40) + AND IF(vPartTime,cl.hours_week <= 40,cl.hours_week = 40) GROUP BY wj.userFk ORDER BY w.lastName, w.firstname; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -43536,11 +44248,12 @@ BEGIN CAST(isa.physicalVolume * 1000 AS DECIMAL(10,0)) as Litros FROM vn.itemShelvingAvailable isa JOIN vn.item i ON i.id = isa.itemFk - JOIN vn.sector s ON s.id = vSectorFk + JOIN vn.sector s ON s.id = isa.sectorFk WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) AND isa.isPreviousPreparable = TRUE AND isa.sectorFk = vSectorFk AND isa.quantity > 0 + AND isa.sectorFk = vSectorFk GROUP BY saleFk HAVING isa.quantity <= totalAvailable ) sub2 @@ -44419,9 +45132,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -44466,6 +45179,103 @@ BEGIN AND IFNULL(ts.alertLevel,0) = 0 LIMIT 1; +IF vNewTicket IS NULL + THEN + CALL vn.ticket_Clone(vAuxId, vNewTicket); + /*CALL vn2008.bionic_calc_ticket(vNewTicket);*/ + END IF; + + INSERT INTO ticketTracking(ticketFk, workerFk, stateFk) + SELECT vNewTicket, getWorker(), s.id + FROM state s + WHERE s.code = 'FIXING'; + + + /*parche para campapña, eliminar y modificar el front*/ +SELECT COUNT(id) INTO vNumLine + FROM sale s + WHERE s.ticketFk = vNewTicket AND s.itemFk = (SELECT itemFk FROM sale WHERE id = vSaleFk); + + IF vNumLine = 0 THEN + + INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount) + SELECT vNewTicket, itemFk, concept, vQuantity, price, discount + FROM sale s + WHERE s.id = vSaleFk; + + SELECT LAST_INSERT_ID() INTO vNewSale; + + INSERT INTO saleComponent(saleFk, componentFk, `value`) + SELECT vNewSale, componentFk, `value` + FROM saleComponent + WHERE saleFk = vSaleFk; + +ELSE IF vQuantity <> 0 THEN + + SELECT itemFk INTO vItemFk FROM sale WHERE id = vSaleFk; + UPDATE sale SET quantity = vQuantity + WHERE ticketFk = vNewTicket AND itemFk = vItemFk; + +END IF; +END IF; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `saleMove__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `saleMove__`(IN vSaleFk BIGINT, IN vQuantity BIGINT) +BEGIN + + DECLARE vclientFk INT; + DECLARE vShipped DATE; + DECLARE vWarehouseFk INT; + DECLARE vCompanyFk INT; + DECLARE vAddressFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vNewTicket BIGINT; + DECLARE vNewSale BIGINT; + DECLARE vLanded DATE; + DECLARE vDateStart DATETIME; + DECLARE vDateEnd DATETIME; + DECLARE vAuxId INT; + DECLARE vNumLine INT; + DECLARE vItemFk INT; + + SELECT clientFk,shipped,warehouseFk,companyFk,addressFk,agencyModeFk,landed,t.id + INTO vclientFk,vShipped,vWarehouseFk,vCompanyFk,vAddressFk,vAgencyModeFk,vLanded,vAuxId + FROM ticket t + JOIN sale s ON s.ticketFk=t.id + WHERE s.id = vSaleFk; + + SET vDateStart = TIMESTAMP(vShipped); + SET vDateEnd = TIMESTAMP(vShipped, '23:59:59'); + + SELECT t.id INTO vNewTicket + FROM ticket t + JOIN ticketState ts ON ts.ticketFk=t.id + WHERE t.addressFk = vAddressFk + AND t.warehouseFk = vWarehouseFk + AND t.agencyModeFk = vAgencyModeFk + AND t.landed <=> vLanded + AND t.shipped BETWEEN vDateStart AND vDateEnd + AND t.refFk IS NULL + AND t.clientFk <> 1118 + AND t.id <> vAuxId + AND IFNULL(ts.alertLevel,0) = 0 + LIMIT 1; + IF vNewTicket IS NULL THEN CALL ticketCreate(vclientFk , vShipped , vWarehouseFk , vCompanyFk , vAddressFk , vAgencyModeFk , NULL,vLanded , vNewTicket); @@ -44901,9 +45711,10 @@ BEGIN date(ish.created) as created, ish.visible, 0 as reserve, - '2019-10-31' as picked, + CAST('2019-10-31' AS DATE) as picked, ish.shelvingFk, - 0 as Litros + 0 as Litros, + p.code as parkingCode FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk @@ -45262,6 +46073,77 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sinComponentes` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sinComponentes`() +BEGIN + DECLARE v_done BOOL DEFAULT FALSE; + DECLARE vSaleFk INTEGER; + DECLARE vCur CURSOR FOR +SELECT s.id + FROM vn.ticket t + JOIN vn.client clt ON clt.id = t.clientFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = tp.categoryFk + LEFT JOIN tmp.coste c ON c.id = s.id + WHERE t.shipped >= '2019-10-01' + AND c.id IS NULL + AND ic.merchandise != 0 + AND clt.isActive != 0 + GROUP BY s.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET v_done = TRUE; + +DROP TEMPORARY TABLE IF EXISTS tmp.coste; + +CREATE TEMPORARY TABLE tmp.coste + (primary key (id)) ENGINE = MEMORY + SELECT s.id + FROM vn.ticket t + JOIN vn.client clt ON clt.id = t.clientFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = tp.categoryFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.id = 1 + WHERE t.shipped >= '2019-10-01' + AND ic.merchandise != 0 + ORDER BY s.id DESC; + + + OPEN vCur; + + l: LOOP + SET v_done = FALSE; + FETCH vCur INTO vSaleFk; + + IF v_done THEN + LEAVE l; + END IF; + + CALL vn.ticketCalculateSaleForcePrice2(vSaleFk); + END LOOP; + + CLOSE vCur; + END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `solunionRiskRequest` */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -46045,35 +46927,22 @@ proc: BEGIN DECLARE vTicketFree BOOLEAN DEFAULT TRUE; DECLARE vZoneFk INTEGER; - SELECT FALSE - INTO vTicketFree + SELECT NOT (t.refFk IS NOT NULL OR ts.alertLevel > 0) OR s.price = 0, s.ticketFk, s.itemFk , t.zoneFk + INTO vTicketFree, vTicket, vItem, vZoneFk FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id WHERE s.id = vSale - AND (t.refFk != "" OR (ts.alertLevel > 0 AND s.price != 0)) LIMIT 1; - - SELECT ticketFk, itemFk - INTO vTicket, vItem - FROM sale - WHERE id = vSale; SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.agencyModeFk, t.landed INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded FROM agencyMode a JOIN ticket t ON t.agencyModeFk = a.id WHERE t.id = vTicket; - - CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); - - SELECT id INTO vZoneFk - FROM tmp.zoneGetShipped - WHERE warehouseFk = vWarehouseFk - AND shipped = vShipped; IF IFNULL(vZoneFk,0) = 0 THEN - CALL util.throw('not zone with this parameters'); + CALL util.throw('ticket dont have zone'); END IF; CALL buyUltimate (vWarehouseFk, vShipped); @@ -46172,6 +47041,73 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateSaleForcePrice2` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateSaleForcePrice2`(IN vSale BIGINT) +proc: BEGIN + + DECLARE vShipped DATE; + DECLARE vWarehouseFk SMALLINT; + DECLARE vAddressFk INT; + DECLARE vTicket BIGINT; + DECLARE vItem BIGINT; + DECLARE vLanded DATE; + DECLARE vZoneFk INT; + DECLARE vHasZone BOOLEAN DEFAULT FALSE; + + + SELECT ticketFk, itemFk + INTO vTicket, vItem + FROM sale + WHERE id = vSale; + + SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.landed, t.zoneFk + INTO vWarehouseFk, vShipped, vAddressFk, vLanded, vZoneFk + FROM agencyMode a + JOIN ticket t ON t.agencyModeFk = a.id + WHERE t.id = vTicket; + + IF vZoneFk IS NULL THEN + CALL util.throw('ticket without zone'); + END IF; + + CALL buyUltimate (vWarehouseFk, vShipped); + + DELETE FROM tmp.buyUltimate WHERE itemFk != vItem; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot + SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk + FROM tmp.buyUltimate + WHERE itemFk = vItem; + + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) ENGINE = MEMORY + SELECT vSale saleFk,vWarehouseFk warehouseFk; + + CALL ticketComponentUpdateSale(6); + + INSERT INTO vn.ticketLog (originFk, userFk, `action`, description) + VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); + + DROP TEMPORARY TABLE tmp.buyUltimate; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateSaleForcePriceKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46326,6 +47262,89 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateSale__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateSale__`(IN vSale BIGINT) +proc: BEGIN + + DECLARE vShipped DATE; + DECLARE vWarehouseFk SMALLINT; + DECLARE vAgencyModeFk INT; + DECLARE vAddressFk INT; + DECLARE vTicket BIGINT; + DECLARE vItem BIGINT; + DECLARE vLanded DATE; + DECLARE vTicketFree BOOLEAN DEFAULT TRUE; + DECLARE vZoneFk INTEGER; + + SELECT FALSE + INTO vTicketFree + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + WHERE s.id = vSale + AND (t.refFk != "" OR (ts.alertLevel > 0 AND s.price != 0)) + LIMIT 1; + + SELECT ticketFk, itemFk + INTO vTicket, vItem + FROM sale + WHERE id = vSale; + + SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.agencyModeFk, t.landed + INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded + FROM agencyMode a + JOIN ticket t ON t.agencyModeFk = a.id + WHERE t.id = vTicket; + + CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); + + SELECT id INTO vZoneFk + FROM tmp.zoneGetShipped + WHERE warehouseFk = vWarehouseFk + AND shipped = vShipped; + + IF IFNULL(vZoneFk,0) = 0 THEN + CALL util.throw('not zone with this parameters'); + END IF; + + CALL buyUltimate (vWarehouseFk, vShipped); + + DELETE FROM tmp.buyUltimate WHERE itemFk != vItem; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot + SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk + FROM tmp.buyUltimate + WHERE itemFk = vItem; + + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) ENGINE = MEMORY + SELECT vSale saleFk,vWarehouseFk warehouseFk; + + CALL ticketComponentUpdateSale(IF(vTicketFree,1,6)); + + INSERT INTO vn.ticketLog (originFk, userFk, `action`, description) + VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); + + DROP TEMPORARY TABLE tmp.buyUltimate; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketClosure` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49103,12 +50122,18 @@ BEGIN AND s.code != 'PREVIOUS_PREPARATION' ORDER BY inter_id DESC LIMIT 1; - + /* INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor) SELECT state_id, Id_Ticket, vLastWorkerFk, vn.getWorker() FROM vncontrol.inter WHERE inter_id = vControlFk; - + */ + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor) + SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, vn.getWorker() + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE inter_id = vControlFk; + SELECT state_id INTO vStateId FROM vncontrol.inter WHERE inter_id = vControlFk; @@ -49330,15 +50355,19 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare`(IN vIdTicket INT, IN viewAll BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) BEGIN /* Tickets con estado 26 para preaprar en altillo */ IF viewAll IS true THEN - SELECT * + SELECT stpp.*,ispss.created FROM vn.salesToPrePrepare stpp - WHERE stpp.Id_Ticket = vIdTicket; + LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss + ON ispss.itemShelvingFk = (SELECT itemShelvingFk FROM vn.itemShelvingPlacementSupplyStock WHERE itemFk = stpp.Id_Article AND sectorFk = vSectorFk ORDER BY parking ASC LIMIT 1) + LEFT JOIN vn.parking p ON p.id = ispss.parkingFk + WHERE stpp.Id_Ticket = vIdTicket + ORDER BY p.column ASC; ELSE SELECT * FROM vn.ticketToPrepare ttp @@ -50837,139 +51866,9 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN /** - * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd - * - * @param vUserFk Identificador del trabajador - * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; - * En caso de tener algun problema retorna el primero que encuentra + * deprecated call workerTimeControl_check */ - DECLARE vLastIn DATETIME ; - DECLARE vLastOut DATETIME ; - DECLARE vDayWorkMax INT; - DECLARE vDayBreak INT; - DECLARE vWeekBreak INT ; - DECLARE vWeekScope INT; - DECLARE vDayStayMax INT; - DECLARE vProblem VARCHAR(20) DEFAULT NULL; - DECLARE vTimedWorked INT; - DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; - DECLARE vDepartmentFk INT; - - SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax - INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax - FROM vn.workerTimeControlParams; - - SELECT MAX(timed) INTO vLastIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction = 'in'; - - SELECT MAX(timed) INTO vLastOut - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction = 'out'; - - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVO DIA - - -- VERIFICAR DEPARTAMENTO - IF vTabletFk IS NOT NULL THEN - SELECT wtcu.departmentFk INTO vDepartmentFk - FROM vn.workerTimeControlUserInfo wtcu - WHERE wtcu.userFk = vUserFk; - IF (SELECT COUNT(td.tabletFk) - FROM vn.tabletDepartment td - WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk - ) = 0 THEN - SELECT "No perteneces a este departamento." AS problem; - LEAVE proc; - END IF; - END IF; - - -- VERIFICAR DESCANSO DIARIO - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN - SELECT "Descansos 12 h" AS problem; - LEAVE proc; - END IF; - - -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ - IF (SELECT MOD(COUNT(*),2)<>0 - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND timed >= vLastIn - ) THEN - SELECT "Dias con fichadas impares" AS problem; - LEAVE proc; - END IF; - - -- VERIFICAR VACACIONES - SELECT cs.type INTO vCalendarStateType - FROM postgresql.calendar_employee ce - JOIN postgresql.business b USING(business_id) - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN postgresql.person p ON p.person_id = pr.person_id - JOIN postgresql.calendar_state cs USING(calendar_state_id) - JOIN vn.worker w ON w.id = p.id_trabajador - WHERE ce.date = CURDATE() - AND cs.isAllowedToWork = FALSE - AND w.userFk = vUserFk - LIMIT 1; - - IF(LENGTH(vCalendarStateType)) THEN - SELECT vCalendarStateType AS problem; - LEAVE proc; - END IF; - - - -- VERIFICAR CNTRATO EN VIGOR - IF (SELECT COUNT(*) - FROM postgresql.business b - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN postgresql.person p ON p.person_id = pr.person_id - JOIN vn.worker w ON w.id = p.id_trabajador - WHERE w.userFk = vUserFk - AND b.date_start <= vDated - AND IFNULL(b.date_end,vDated) >= vDated - ) = 0 THEN - SELECT "Dia no laborable" AS problem; - LEAVE proc; - END IF; - - -- VERIFICAR DESCANSO SEMANAL - SET @vHasBreakWeek:= FALSE; - SET @gap:= unix_timestamp((NOW() - INTERVAL vWeekScope SECOND)); -- COLOCA EL TIEMPO DE OUT, EN EL CASO DE QUE LA PRIMERA FICHADA DEL PERIODO SEA IN, PARA TENER UN PUNTO DE PARTIDA - - DROP TEMPORARY TABLE IF EXISTS tmp.trash; - CREATE TEMPORARY TABLE tmp.trash - SELECT IF(direction='out', @gap:= -unix_timestamp(timed), @gap:= @gap + unix_timestamp(timed)) as alias1 , - IF(@gap - vWeekBreak >= 0 , @vHasBreakWeek := TRUE, @vHasBreakWeek := @vHasBreakWeek) as alias2 - FROM vn.workerTimeControl - WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) - AND userFk= vUserFk - AND direction IN ('in','out') - ORDER BY timed ASC; - - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA - SELECT "Descansos 36 h" AS problem; - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE tmp.trash; - - ELSE -- DIA ACTUAL - - -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO - SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked - FROM vn.workerTimeControl wtc - WHERE userFk = vUserFk - AND timed >= vLastIn - ORDER BY timed; - - IF vTimedWorked > vDayWorkMax THEN - SELECT "Jornadas" AS problem; - LEAVE proc; - END IF; - - END IF; +CALL vn.workerTimeControl_check(vUserFk,vDated,vTabletFk); END ;; DELIMITER ; @@ -51226,8 +52125,8 @@ BEGIN DECLARE vCacheVisibleOriginFk INT; DECLARE vCacheVisibleDestinyFk INT; - CALL cache.visible_refresh(vCacheVisibleOriginFk, TRUE, vWhOrigin); - CALL cache.visible_refresh(vCacheVisibleDestinyFk, TRUE, vWhDestiny); + CALL cache.visible_refresh(vCacheVisibleOriginFk, FALSE, vWhOrigin); + CALL cache.visible_refresh(vCacheVisibleDestinyFk, FALSE, vWhDestiny); SELECT i.id itemFk, i.longName, @@ -52055,6 +52954,70 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) +BEGIN + + DECLARE vDirection VARCHAR(6); + DECLARE vLastIn DATETIME; + DECLARE vDayStayMax INT; + DECLARE vHasDirectionOut INT; + + SELECT dayStayMax INTO vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT vn.timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; + + IF vDirection = 'out' THEN + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in' + AND timed < vTimed; + + UPDATE vn.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 vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + UPDATE vn.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); + + CALL vn.workerTimeControlSOWP(vUserFk, vTimed); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add__`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) BEGIN DECLARE vDirection VARCHAR(6); @@ -52089,6 +53052,221 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +proc: BEGIN +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekScope INT; + DECLARE vDayStayMax INT; + DECLARE vProblem VARCHAR(20) DEFAULT NULL; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vDepartmentFk INT; + /* + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'out'; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVO DIA + + -- VERIFICAR DESCANSO DIARIO + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + SELECT "Descansos 12 h" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2)<>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed >= vLastIn + ) THEN + SELECT "Dias con fichadas impares" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() + AND cs.isAllowedToWork = FALSE + AND w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + SELECT vCalendarStateType AS problem; + LEAVE proc; + END IF; + + + -- VERIFICAR CNTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk + AND b.date_start <= vDated + AND IFNULL(b.date_end,vDated) >= vDated + ) = 0 THEN + SELECT "Dia no laborable" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @gap:= unix_timestamp((NOW() - INTERVAL vWeekScope SECOND)); -- COLOCA EL TIEMPO DE OUT, EN EL CASO DE QUE LA PRIMERA FICHADA DEL PERIODO SEA IN, PARA TENER UN PUNTO DE PARTIDA + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(direction='out', @gap:= -unix_timestamp(timed), @gap:= @gap + unix_timestamp(timed)) as alias1 , + IF(@gap - vWeekBreak >= 0 , @vHasBreakWeek := TRUE, @vHasBreakWeek := @vHasBreakWeek) as alias2 + FROM vn.workerTimeControl + WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) + AND userFk= vUserFk + AND direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SELECT "Descansos 36 h" AS problem; + LEAVE proc; + END IF; + + DROP TEMPORARY TABLE tmp.trash; + + ELSE -- DIA ACTUAL + + -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO + SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= vLastIn + ORDER BY timed; + + IF vTimedWorked > vDayWorkMax THEN + SELECT "Jornadas" AS problem; + LEAVE proc; + END IF; + + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + SELECT wtcu.departmentFk INTO vDepartmentFk + FROM vn.workerTimeControlUserInfo wtcu + WHERE wtcu.userFk = vUserFk; + IF (SELECT COUNT(td.tabletFk) + FROM vn.tabletDepartment td + WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk + ) = 0 THEN + SELECT "No perteneces a este departamento." AS problem; + LEAVE proc; + END IF; + END IF;*/ + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_remove` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) +BEGIN + + DECLARE vDirectionRemove VARCHAR(6); + DECLARE vDirectionPrevious VARCHAR(6); + DECLARE vTimedPrevious DATETIME; + + SELECT direction INTO vDirectionRemove + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed = vTimed ; + + IF vDirectionRemove = 'out' THEN + + SELECT timed, direction INTO vTimedPrevious, vDirectionPrevious + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + IF vDirectionPrevious = "middle" THEN + UPDATE vn.workerTimeControl + SET direction = "out" + WHERE userFk = vUserFk + AND timed = vTimedPrevious; + END IF; + + ELSE IF vDirectionRemove = 'in' THEN + + UPDATE vn.workerTimeControl + SET direction = "in" + WHERE userFk = vUserFk + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + END IF; + + END IF; + + DELETE FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed = vTimed; + + CALL vn.workerTimeControlSOWP(vUserFk, vTimed); + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerWeekControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54301,7 +55479,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=21444 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21447 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54438,7 +55616,7 @@ CREATE TABLE `Cajas` ( KEY `warehouse_id` (`warehouse_id`), KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=730559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=736868 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54573,7 +55751,7 @@ CREATE TABLE `Clientes_cedidos` ( CONSTRAINT `cliente_cedido_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `new_trabajador_fk` FOREIGN KEY (`Id_Trabajador_new`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `trabajador_fk` FOREIGN KEY (`Id_Trabajador_old`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que se han cambiado de comercial, pero durante un tiempo comisionan a los dos, al anterior y al actual'; +) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que se han cambiado de comercial, pero durante un tiempo comisionan a los dos, al anterior y al actual'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54691,7 +55869,7 @@ CREATE TABLE `Colas` ( KEY `Id_Trabajador` (`Id_Trabajador`), CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `vn`.`queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=48490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22067 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54860,7 +56038,7 @@ CREATE TABLE `Consignatarios` ( CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON UPDATE CASCADE, CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=29260 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=29439 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54988,7 +56166,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2757 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55212,7 +56390,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3888286 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3942060 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -55230,7 +56408,7 @@ CREATE TABLE `Entradas_kop` ( PRIMARY KEY (`Id_Entradas_kop`), KEY `entradas_entradas_kop_idx` (`Id_Entrada`), CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=154 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56058,92 +57236,26 @@ CREATE TABLE `Proveedores_gestdoc` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Recibos` +-- Temporary table structure for view `Recibos` -- DROP TABLE IF EXISTS `Recibos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Recibos` ( - `Id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Factura` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Entregado` decimal(10,2) NOT NULL DEFAULT '0.00', - `Pendiente` decimal(10,2) NOT NULL DEFAULT '0.00', - `Fechacobro` datetime DEFAULT NULL, - `Id_Trabajador` int(11) DEFAULT '0', - `Id_Banco` int(11) DEFAULT '0', - `Id_Cliente` int(11) DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `conciliado` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', - PRIMARY KEY (`Id`), - KEY `Id_Banco` (`Id_Banco`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `empresa_id` (`empresa_id`), - KEY `clientDate` (`Id_Cliente`,`Fechacobro`), - KEY `id_factura` (`Id_Factura`), - CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, - CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=599651 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`RecibosAfterInsert` -AFTER INSERT ON `Recibos` -FOR EACH ROW - CALL bi.customer_risk_update (NEW.Id_Cliente, NEW.empresa_id, -NEW.Entregado) */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`RecibosBeforeUpdate` -BEFORE UPDATE ON `Recibos` -FOR EACH ROW -BEGIN - CALL bi.customer_risk_update (OLD.Id_Cliente, OLD.empresa_id, OLD.Entregado); - CALL bi.customer_risk_update (NEW.Id_Cliente, NEW.empresa_id, -NEW.Entregado); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`RecibosBeforeDelete` -BEFORE DELETE ON `Recibos` -FOR EACH ROW - CALL bi.customer_risk_update (OLD.Id_Cliente, OLD.empresa_id, OLD.Entregado) */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `Recibos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Recibos` AS SELECT + 1 AS `Id`, + 1 AS `Id_Factura`, + 1 AS `Entregado`, + 1 AS `Pendiente`, + 1 AS `Fechacobro`, + 1 AS `Id_Trabajador`, + 1 AS `Id_Banco`, + 1 AS `Id_Cliente`, + 1 AS `odbc_date`, + 1 AS `empresa_id`, + 1 AS `conciliado`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Recibos_recorded` @@ -56156,7 +57268,7 @@ CREATE TABLE `Recibos_recorded` ( `Id_Recibos` int(11) NOT NULL, `recorded` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Marcado si se ha contabilizado', PRIMARY KEY (`Id_Recibos`), - CONSTRAINT `Recibos_recorded_ibfk_1` FOREIGN KEY (`Id_Recibos`) REFERENCES `Recibos` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Recibos_recorded_ibfk_1` FOREIGN KEY (`Id_Recibos`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recibos (Contrareembolso) contabilizados'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -56176,7 +57288,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2757 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2761 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56196,7 +57308,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56221,7 +57333,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=983 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56333,13 +57445,13 @@ CREATE TABLE `Rutas_monitor` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Salarios` +-- Table structure for table `Salarios__` -- -DROP TABLE IF EXISTS `Salarios`; +DROP TABLE IF EXISTS `Salarios__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Salarios` ( +CREATE TABLE `Salarios__` ( `Id_Trabajador` int(11) NOT NULL, `Salario_Bruto` double DEFAULT '0', `Incentivo` double DEFAULT '0', @@ -56405,7 +57517,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Split_lines_ibfk_1` FOREIGN KEY (`Id_Split`) REFERENCES `Splits` (`Id_Split`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=367273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=369614 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56423,7 +57535,7 @@ CREATE TABLE `Splits` ( `Notas` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id_Split`), KEY `Id_Entrada` (`Id_Entrada`) -) ENGINE=InnoDB AUTO_INCREMENT=36950 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36974 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56517,7 +57629,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65096090 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65192051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56713,7 +57825,7 @@ CREATE TABLE `Trabajadores` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1448 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56801,29 +57913,24 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `Vehiculos` +-- Temporary table structure for view `Vehiculos` -- DROP TABLE IF EXISTS `Vehiculos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Vehiculos` ( - `Id_Vehiculo` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Matricula` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `Modelo` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `Marca` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `m3` double DEFAULT NULL, - `active` tinyint(4) NOT NULL DEFAULT '1', - `warehouseFk` smallint(6) unsigned DEFAULT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`Id_Vehiculo`), - KEY `empresa_id` (`empresa_id`), - KEY `provinceFk_idx` (`warehouseFk`), - CONSTRAINT `Vehiculos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=435 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Vehiculos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Vehiculos` AS SELECT + 1 AS `Id_Vehiculo`, + 1 AS `Matricula`, + 1 AS `Marca`, + 1 AS `Modelo`, + 1 AS `empresa_id`, + 1 AS `warehouseFk`, + 1 AS `description`, + 1 AS `m3`, + 1 AS `active`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Vehiculos_consumo` @@ -56851,10 +57958,10 @@ CREATE TABLE `Vehiculos_consumo` ( KEY `fk_Vehiculos_consumo_Vehiculos_idx` (`Id_Vehiculo`), KEY `fuelTypeFk_idx` (`fuelTypeFk`), KEY `proveedoresFk_idx` (`proveedoresFk`), - CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `Vehiculos` (`Id_Vehiculo`) ON UPDATE CASCADE, + CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `vn`.`vehicle` (`id`) ON UPDATE CASCADE, CONSTRAINT `fuelTypeFk` FOREIGN KEY (`fuelTypeFk`) REFERENCES `vn`.`fuelType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `proveedoresFk` FOREIGN KEY (`proveedoresFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=12530 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; +) ENGINE=InnoDB AUTO_INCREMENT=12724 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56966,7 +58073,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4001214 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4015142 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57052,7 +58159,7 @@ CREATE TABLE `account_conciliacion` ( KEY `fg_accconciliacion_key1_idx` (`Id_Proveedores_account`), KEY `index_id_calculated` (`id_calculated`), CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `vn`.`supplierAccount` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=35179 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36355 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57360,7 +58467,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3601 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3681 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57377,7 +58484,7 @@ CREATE TABLE `albaran_gestdoc` ( KEY `fk_albaran_gestdoc_gestdoc1_idx` (`gestdoc_id`), KEY `fk_albaran_gestdoc_albaran1_idx` (`albaran_id`), CONSTRAINT `fk_albaran_gestdoc_albaran1` FOREIGN KEY (`albaran_id`) REFERENCES `albaran` (`albaran_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_albaran_gestdoc_gestdoc1` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON UPDATE CASCADE + CONSTRAINT `fk_albaran_gestdoc_gestdoc1` FOREIGN KEY (`gestdoc_id`) REFERENCES `vn`.`dms` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -57439,7 +58546,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3515 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3570 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57605,7 +58712,7 @@ CREATE TABLE `awb_component` ( CONSTRAINT `awb_component_` FOREIGN KEY (`awb_component_type_id`) REFERENCES `awb_component_type` (`awb_component_type_id`) ON UPDATE CASCADE, CONSTRAINT `awb_role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=30582 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=31882 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57719,8 +58826,8 @@ CREATE TABLE `awb_gestdoc` ( KEY `awb_gestdoc_awb_fk` (`awb_id`), KEY `awb_gestdoc_gestdoc_fk` (`gestdoc_id`), CONSTRAINT `awb_gestdoc_awb_fk` FOREIGN KEY (`awb_id`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3098 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `vn`.`dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3151 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59092,21 +60199,20 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `escritos` +-- Temporary table structure for view `escritos` -- DROP TABLE IF EXISTS `escritos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `escritos` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `abrev` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `descripcion` varchar(105) COLLATE utf8_unicode_ci NOT NULL, - `visible` tinyint(4) NOT NULL DEFAULT '1', - `hasCompany` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `escritos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `escritos` AS SELECT + 1 AS `id`, + 1 AS `abrev`, + 1 AS `descripcion`, + 1 AS `visible`, + 1 AS `hasCompany`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `escritos_det` @@ -59279,96 +60385,27 @@ CREATE TABLE `gastos_resumen` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `gestdoc` +-- Temporary table structure for view `gestdoc` -- DROP TABLE IF EXISTS `gestdoc`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `gestdoc` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `gesttip_id` int(11) NOT NULL DEFAULT '1', - `sref` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `brief` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, - `emp_id` smallint(5) unsigned NOT NULL DEFAULT '791', - `orden` mediumint(8) unsigned DEFAULT NULL, - `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `original` tinyint(4) NOT NULL DEFAULT '0', - `trabajador_id` int(11) NOT NULL, - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `gestdoccol` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `warehouse_id` smallint(5) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `emp_id` (`emp_id`,`orden`,`warehouse_id`), - KEY `trabajador_id` (`trabajador_id`), - KEY `warehouse_id` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1347466 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`gestdoc_bi` -BEFORE INSERT ON `vn2008`.`gestdoc` -FOR EACH ROW -BEGIN - - DECLARE intORD int; - IF NEW.warehouse_id = 44 THEN - SET NEW.warehouse_id = 1; - END IF; - IF NEW.original THEN - SELECT 1 + MAX(orden) INTO intORD FROM gestdoc WHERE emp_id = NEW.emp_id AND warehouse_id = NEW.warehouse_id ; - - SET NEW.orden = IFNULL(intORD,1) ; - END IF; --- Marca Firmado a uno cada vez que se escanea un Ticket de forma que desaparezca del TNAC JGF 27/08/13 - IF NEW.gesttip_id = 14 THEN - UPDATE Tickets SET Firmado = 1 WHERE Id_Ticket = NEW.sref; - 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`gestdoc_bu` -BEFORE UPDATE ON `vn2008`.`gestdoc` -FOR EACH ROW -BEGIN - - DECLARE intORD int; - IF (NEW.original <> 0) AND (OLD.original = 0) AND (NEW.orden IS NULL) THEN - - SELECT 1 + MAX(orden) INTO intORD FROM gestdoc WHERE emp_id = NEW.emp_id AND warehouse_id = NEW.warehouse_id; - SET NEW.orden = IFNULL(intORD,1); - - END IF; -IF ((NEW.orden = 0) OR NEW.orden IS NULL) AND (OLD.orden <> 0) THEN - - SET NEW.original = 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 */ ; +/*!50001 DROP VIEW IF EXISTS `gestdoc`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `gestdoc` AS SELECT + 1 AS `id`, + 1 AS `gesttip_id`, + 1 AS `file`, + 1 AS `contentType`, + 1 AS `trabajador_id`, + 1 AS `warehouse_id`, + 1 AS `emp_id`, + 1 AS `orden`, + 1 AS `original`, + 1 AS `sref`, + 1 AS `brief`, + 1 AS `odbc_date`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `gesttip` @@ -59504,7 +60541,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `vn`.`intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=82076 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=83287 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59789,7 +60826,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1886467 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1912431 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -60021,7 +61058,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=51816 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52275 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60518,7 +61555,7 @@ CREATE TABLE `price_fixed` ( KEY `date_end` (`date_end`), KEY `warehouse_id` (`warehouse_id`), CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64485 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60698,7 +61735,7 @@ CREATE TABLE `recibida` ( CONSTRAINT `recibida_ibfk_5` FOREIGN KEY (`cplusInvoiceType472Fk`) REFERENCES `vn`.`cplusInvoiceType472` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_6` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_7` FOREIGN KEY (`cplusTrascendency472Fk`) REFERENCES `vn`.`cplusTrascendency472` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=87260 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=88247 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60936,7 +61973,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `vn`.`expence` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=156249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=162841 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -60959,7 +61996,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=154384 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=160931 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61197,13 +62234,13 @@ CREATE TABLE `ruta_location` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `salarioDits` +-- Table structure for table `salarioDits__` -- -DROP TABLE IF EXISTS `salarioDits`; +DROP TABLE IF EXISTS `salarioDits__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `salarioDits` ( +CREATE TABLE `salarioDits__` ( `idSalario_dits` int(11) NOT NULL AUTO_INCREMENT, `idaccion_dits` int(11) NOT NULL, `ODBC_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -61212,7 +62249,7 @@ CREATE TABLE `salarioDits` ( `value_old` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `value_new` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`idSalario_dits`) -) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61229,7 +62266,7 @@ CREATE TABLE `scan` ( `name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=108199 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=111094 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61271,7 +62308,7 @@ CREATE TABLE `scan_line` ( PRIMARY KEY (`scan_line_id`), KEY `id_scan_id_idx` (`scan_id`), CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1371651 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1415333 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61629,7 +62666,7 @@ DROP TABLE IF EXISTS `thermograph`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `thermograph` ( `thermograph_id` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `model` enum('TL30','SENSITECH','TREKVIEW1','TREKVIEW2','DISPOSABLE') COLLATE utf8_unicode_ci NOT NULL, + `model` enum('TL30','SENSITECH','TREKVIEW1','TREKVIEW2','DISPOSABLE','TEMPMATE') COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`thermograph_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -61681,43 +62718,17 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `tickets_gestdoc` +-- Temporary table structure for view `tickets_gestdoc` -- DROP TABLE IF EXISTS `tickets_gestdoc`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tickets_gestdoc` ( - `Id_Ticket` int(11) NOT NULL, - `gestdoc_id` int(11) NOT NULL, - PRIMARY KEY (`Id_Ticket`,`gestdoc_id`), - KEY `gestdoc_id` (`gestdoc_id`), - CONSTRAINT `dmsFk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketFk` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`tickets_gestdoc_BEFORE_DELETE` BEFORE DELETE ON `tickets_gestdoc` FOR EACH ROW -BEGIN - - UPDATE gestdoc - SET gesttip_id = (SELECT id FROM gesttip WHERE `code` = 'trash') - WHERE id = OLD.gestdoc_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 */ ; +/*!50001 DROP VIEW IF EXISTS `tickets_gestdoc`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `tickets_gestdoc` AS SELECT + 1 AS `Id_Ticket`, + 1 AS `gestdoc_id`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `time` @@ -61836,7 +62847,7 @@ CREATE TABLE `travel_dits` ( KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), CONSTRAINT `travel_dits_ibfk_1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=240308 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=243319 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61913,7 +62924,7 @@ CREATE TABLE `travel_thermograph` ( KEY `gestdoc_fk_idx` (`gestdoc_id`), KEY `travel_id` (`travel_id`), KEY `warehouse_id` (`warehouse_id`), - CONSTRAINT `gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON UPDATE CASCADE, + CONSTRAINT `gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `vn`.`dms` (`id`) ON UPDATE CASCADE, CONSTRAINT `thermograph_fk` FOREIGN KEY (`thermograph_id`) REFERENCES `thermograph` (`thermograph_id`) ON UPDATE CASCADE, CONSTRAINT `travel_fk` FOREIGN KEY (`travel_id`) REFERENCES `vn`.`travel` (`id`), CONSTRAINT `travel_thermograph_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE @@ -62899,9 +63910,11 @@ CREATE TABLE `warehouse` ( `isManaged` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT '0', `hasStowaway` tinyint(1) NOT NULL DEFAULT '0', + `hasDms` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`Id_Paises`), + KEY `isComparativeIdx` (`is_comparative`), CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `vn`.`country` (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -63099,19 +64112,18 @@ CREATE TABLE `wks` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `workcenter_holiday` +-- Temporary table structure for view `workcenter_holiday` -- DROP TABLE IF EXISTS `workcenter_holiday`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workcenter_holiday` ( - `workcenter_id` int(11) NOT NULL, - `day` double NOT NULL, - `year` smallint(6) NOT NULL, - PRIMARY KEY (`workcenter_id`,`year`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `workcenter_holiday`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `workcenter_holiday` AS SELECT + 1 AS `workcenter_id`, + 1 AS `day`, + 1 AS `year`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `workerDocument` @@ -64076,6 +65088,7 @@ CREATE DEFINER=`root`@`%` FUNCTION `getBouquetId`( vSize int, vColour VARCHAR(5) ) RETURNS int(11) + DETERMINISTIC BEGIN /** * De vuelve el ID del ramo. Si no existe uno parecido, lo crea. @@ -64086,13 +65099,10 @@ BEGIN * @param vColour Color del ramo * @return ID del ramo */ - DECLARE bouquetId INT(11); - + CALL vn2008.createBouquet(vName, vType, vSize, vColour, @vItem); - - SET bouquetId = (SELECT @vItem); - -RETURN bouquetId; + + RETURN @vItem; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64268,17 +65278,23 @@ DELIMITER ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `intrastat_neto`( intINSTRASTAT INTEGER,intUNIDADES INTEGER) RETURNS double + DETERMINISTIC BEGIN -DECLARE n DOUBLE; + DECLARE n DOUBLE; -select ROUND(intUNIDADES / (sum(MEDIA) / count(media)),2) into n from ( -select *, unidades / neto MEDIA FROM intrastat_data WHERE intrastat_id = intINSTRASTAT and neto and unidades > 0 ORDER BY odbc_date DESC limit 50) t; --- JGF 01/06 per a evitar Kg en negatiu -RETURN n/2; + SELECT ROUND(intUNIDADES / (SUM(MEDIA) / COUNT(media)), 2) INTO n FROM + (SELECT *, unidades / neto MEDIA + FROM intrastat_data + WHERE intrastat_id = intINSTRASTAT AND neto + AND unidades > 0 + ORDER BY odbc_date DESC + LIMIT 20) t; + -- JGF 01/06 per a evitar Kg en negatiu + RETURN n/2; END ;; DELIMITER ; @@ -66291,8 +67307,10 @@ BEGIN UPDATE article_inventory ai JOIN tmp t ON ai.article_id = t.itemFk - SET ai.buy_id = t.buyFk; - + SET ai.buy_id = t.buyFk; + + DROP TEMPORARY TABLE tmp; + DROP TEMPORARY TABLE tmp.buyUltimate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66505,7 +67523,7 @@ proc: BEGIN JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada JOIN travel tr ON tr.id = e.travel_id LEFT JOIN item_range_copy i ON t.item_id = i.item_id - WHERE t.warehouse_id = vWarehouseShipment + WHERE t.warehouse_id = vWarehouseShipment AND NOT e.Redada -- JGF 2019-10-21 ON DUPLICATE KEY UPDATE item_range.date_end = GREATEST(item_range.date_end,landing); DROP TEMPORARY TABLE item_range_copy; @@ -66595,7 +67613,8 @@ proc: BEGIN ) t GROUP BY t.item_id ) t GROUP BY t.item_id HAVING available != 0; - + + DROP TEMPORARY TABLE vn2008.tmp_item ,item_range @@ -66838,6 +67857,220 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `availableTraslate__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `availableTraslate__`(vWarehouseLanding INT, v_date DATE,vWarehouseShipment INT) +proc: BEGIN + DECLARE v_date_ini DATE; + DECLARE v_date_end DATETIME; + DECLARE v_reserve_date DATETIME; + DECLARE v_date_inv DATE; + + IF v_date < CURDATE() + THEN + LEAVE proc; + END IF; + + CALL vn2008.item_stock (vWarehouseLanding, v_date, NULL); + + -- Calcula algunos parámetros necesarios + + SET v_date_ini = TIMESTAMP(v_date, '00:00:00'); + SET v_date_end = TIMESTAMP(TIMESTAMPADD(DAY, 4, v_date), '23:59:59'); + + SELECT FechaInventario INTO v_date_inv FROM vn2008.tblContadores; + + SELECT SUBTIME(NOW(), reserveTime) INTO v_reserve_date + FROM hedera.orderConfig; + + -- Calcula el ultimo dia de vida para cada producto + + DROP TEMPORARY TABLE IF EXISTS item_range; + CREATE TEMPORARY TABLE item_range + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT c.Id_Article item_id, MAX(landing) date_end + FROM vn2008.Compres c + JOIN vn2008.Entradas e ON c.Id_Entrada = e.Id_Entrada + JOIN vn2008.travel t ON t.id = e.travel_id + JOIN vn2008.warehouse w ON w.id = t.warehouse_id + WHERE t.landing BETWEEN v_date_inv AND v_date_ini + AND t.warehouse_id = vWarehouseLanding + AND NOT e.Inventario + AND NOT e.Redada + GROUP BY Id_Article; +select * from item_range where item_id = 39073; + -- Tabla con el ultimo dia de last_buy para cada producto que hace un replace de la anterior + + CALL item_last_buy_(vWarehouseShipment,curdate()); + + DROP TEMPORARY TABLE IF EXISTS item_range_copy; + CREATE TEMPORARY TABLE item_range_copy LIKE item_range; + INSERT INTO item_range_copy + SELECT * FROM item_range; + + INSERT INTO item_range + SELECT t.item_id, tr.landing + FROM t_item_last_buy t + JOIN Compres c ON c.Id_Compra = t.buy_id + JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada + JOIN travel tr ON tr.id = e.travel_id + LEFT JOIN item_range_copy i ON t.item_id = i.item_id + WHERE t.warehouse_id = vWarehouseShipment + ON DUPLICATE KEY UPDATE item_range.date_end = GREATEST(item_range.date_end,landing); +select * from item_range where item_id = 39073; + DROP TEMPORARY TABLE item_range_copy; + + -- Replica la tabla item_range para poder usarla varias veces en la misma consulta + + DROP TEMPORARY TABLE IF EXISTS item_range_copy1; + CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range; + INSERT INTO item_range_copy1 + SELECT c.item_id, TIMESTAMP(TIMESTAMPADD(DAY, t.life, c.date_end), '23:59:59') date_end FROM item_range c + JOIN vn2008.Articles a ON a.Id_Article = c.item_id + JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id + HAVING date_end >= v_date_ini OR date_end IS NULL; + +SELECT 'copy1',c.item_id, t.life,date_end, v_date_ini,TIMESTAMP(TIMESTAMPADD(DAY, t.life, c.date_end), '23:59:59') date_end FROM item_range c +JOIN vn2008.Articles a ON a.Id_Article = c.item_id + JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id + where c.item_id = 39073; + + DROP TEMPORARY TABLE IF EXISTS item_range_copy2; + CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range_copy1; + INSERT INTO item_range_copy2 + SELECT * FROM item_range_copy1; + + DROP TEMPORARY TABLE IF EXISTS item_range_copy3; + CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range_copy1; + INSERT INTO item_range_copy3 + SELECT * FROM item_range_copy1; + + DROP TEMPORARY TABLE IF EXISTS item_range_copy4; + CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range_copy1; + INSERT INTO item_range_copy4 + SELECT * FROM item_range_copy1; + + DROP TEMPORARY TABLE IF EXISTS item_range_copy5; + CREATE TEMPORARY TABLE item_range_copy5 LIKE item_range_copy1; + INSERT INTO item_range_copy5 + SELECT * FROM item_range_copy1; + + -- Calcula el ATP + + DROP TEMPORARY TABLE IF EXISTS availableTraslate; + CREATE TEMPORARY TABLE availableTraslate + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT t.item_id, SUM(stock) available FROM ( + SELECT ti.item_id, stock + FROM vn2008.tmp_item ti + JOIN item_range ir ON ir.item_id = ti.item_id + UNION ALL + SELECT t.item_id, minacum(dt, amount, v_date) AS available FROM ( + SELECT item_id, DATE(dat) dt, SUM(amount) amount FROM ( + SELECT i.item_id, i.dat, i.amount + FROM vn2008.item_out i + JOIN item_range_copy1 ir ON ir.item_id = i.item_id + WHERE i.dat >= v_date_ini + AND (ir.date_end IS NULL OR i.dat <= ir.date_end) + AND i.warehouse_id = vWarehouseLanding + UNION ALL + SELECT m.Id_Article item_id, t.landing dat, m.Cantidad amount + FROM Compres m + JOIN Entradas e ON m.Id_Entrada = e.Id_Entrada + JOIN travel t ON e.travel_id = t.id + JOIN item_range_copy2 ir ON ir.item_id = m.Id_Article + WHERE + e.Inventario = 0 + AND m.Cantidad <> 0 + AND e.redada = 0 + AND t.warehouse_id = vWarehouseLanding + AND t.landing >= v_date_ini + AND (ir.date_end IS NULL OR t.landing <= ir.date_end) + + UNION ALL + SELECT i.item_id, i.dat, i.amount + FROM vn2008.item_entry_out i + JOIN item_range_copy3 ir ON ir.item_id = i.item_id + WHERE i.dat >= v_date_ini + AND (ir.date_end IS NULL OR i.dat <= ir.date_end) + AND i.warehouse_id = vWarehouseLanding + UNION ALL + SELECT r.item_id, r.shipment, -r.amount + FROM hedera.order_row r + JOIN hedera.`order` o ON o.id = r.order_id + JOIN item_range_copy4 ir ON ir.item_id = r.item_id + WHERE r.shipment >= v_date_ini + AND (ir.date_end IS NULL OR r.shipment <= ir.date_end) + AND r.warehouse_id = vWarehouseLanding + AND r.created >= v_reserve_date + AND NOT o.confirmed + ) t + GROUP BY item_id, dt + ) t + GROUP BY t.item_id + ) t GROUP BY t.item_id HAVING available != 0; + +SELECT ti.item_id, stock + FROM vn2008.tmp_item ti + JOIN item_range ir ON ir.item_id = ti.item_id + WHERE ti.item_id = 39073; + +SELECT i.item_id, i.dat, i.amount + FROM vn2008.item_out i + JOIN item_range_copy1 ir ON ir.item_id = i.item_id + WHERE i.dat >= v_date_ini + AND (ir.date_end IS NULL OR i.dat <= ir.date_end) + AND i.warehouse_id = vWarehouseLanding + and i.item_id = 39073; +select v_date_ini, vWarehouseLanding; +SELECT m.Id_Article item_id, t.landing dat, m.Cantidad amount + FROM Compres m + JOIN Entradas e ON m.Id_Entrada = e.Id_Entrada + JOIN travel t ON e.travel_id = t.id + JOIN item_range_copy2 ir ON ir.item_id = m.Id_Article + WHERE + /*e.Inventario = 0 + AND */m.Cantidad <> 0 + AND e.redada = 0 + AND t.warehouse_id = vWarehouseLanding + AND t.landing >= v_date_ini + AND (ir.date_end IS NULL OR t.landing <= ir.date_end) + and m.Id_Article = 39073; +SELECT r.item_id, r.shipment, -r.amount + FROM hedera.order_row r + JOIN hedera.`order` o ON o.id = r.order_id + JOIN item_range_copy4 ir ON ir.item_id = r.item_id + WHERE r.shipment >= v_date_ini + AND (ir.date_end IS NULL OR r.shipment <= ir.date_end) + AND r.warehouse_id = vWarehouseLanding + AND r.created >= v_reserve_date + AND NOT o.confirmed + and r.item_id = 39073; +select * from availableTraslate where item_id = 39073; + DROP TEMPORARY TABLE + vn2008.tmp_item + ,item_range + ,item_range_copy1 + ,item_range_copy2 + ,item_range_copy3 + ,item_range_copy4 + ,item_range_copy5; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `balance_create` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71033,22 +72266,37 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas_T3_pf`(IN vFixedPriceFk INT, IN vPrice DOUBLE) BEGIN - SELECT round(vPrice * (1 + ((t.t2 - t.t3)/100)),2) - FROM tarifas t - JOIN price_fixed p ON p.price_fixed_id = vFixedPriceFk - WHERE t.fecha <= p.date_start - AND p.warehouse_id = t.warehouse_id - ORDER BY fecha DESC - LIMIT 1; - + + DECLARE vWarehouse INT; + DECLARE vItem INT; + + SELECT p.itemFk, p.warehouseFk INTO vItem,vWarehouse + FROM vn.priceFixed p + WHERE p.id = vFixedPriceFk; + + IF vWarehouse = 0 THEN + SELECT warehouseFk INTO vWarehouse + FROM vn.itemType it + JOIN vn.item i ON i.typeFk = it.id + WHERE i.id = vItem; + END IF; + + SELECT round(vPrice * (1 + ((r.rate2 - r.rate3)/100)),2) + FROM vn.rate r + JOIN vn.priceFixed p ON p.id = vFixedPriceFk + WHERE r.dated <= p.started + AND r.warehouseFk = vWarehouse + ORDER BY r.dated DESC + LIMIT 1; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71129,6 +72377,32 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_tarifas_T3_pf__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas_T3_pf__`(IN vFixedPriceFk INT, IN vPrice DOUBLE) +BEGIN + SELECT round(vPrice * (1 + ((t.t2 - t.t3)/100)),2) + FROM tarifas t + JOIN price_fixed p ON p.price_fixed_id = vFixedPriceFk + WHERE t.fecha <= p.date_start + AND p.warehouse_id = t.warehouse_id + ORDER BY fecha DESC + LIMIT 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 DROP PROCEDURE IF EXISTS `buy_tarifas_table` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73285,6 +74559,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `comparative`( ,i_wh TINYINT ,i_tipo INT ,i_filtro INT + ,vAvailableSinced DATE ) BEGIN DECLARE date_cyear_ini DATETIME; @@ -73292,16 +74567,20 @@ BEGIN DECLARE week_count TINYINT DEFAULT 7; DECLARE w1, w2, w3, w4, w5, w6, w7 INT; DECLARE y1, y2, y3, y4, y5, y6, y7 INT; - DECLARE wperiod INT;-- DECLARE ws, ys INT; -- PAK 11/01/2016 + DECLARE wperiod INT; DECLARE i INT DEFAULT 0; DECLARE strFILTRO VARCHAR(255) DEFAULT 'TRUE'; IF i_filtro THEN SELECT `sql` INTO strFILTRO FROM filtros WHERE id = i_filtro; END IF; + + IF i_tipo THEN + SET strFILTRO = CONCAT(strFILTRO, ' AND tipo_id = ', i_tipo); + END IF; IF days < 0 OR days > 60 THEN - SET days = 15; + SET days = 21; END IF; IF i_wh = NULL THEN @@ -73318,13 +74597,22 @@ BEGIN `article_id` INT(11) NOT NULL PRIMARY KEY ) ENGINE = MEMORY; - - INSERT INTO article_inventory (article_id) - SELECT Id_Article FROM Articles a - JOIN Tipos t ON a.tipo_id = t.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = t.reino_id - WHERE (i_tipo = 0 OR a.tipo_id = i_tipo) - AND r.display <> 0; + + SET strFILTRO = REPLACE(strFILTRO, 'Id_Article','A.Id_Article'); + SET strFILTRO = REPLACE(strFILTRO, 'tipo_id','tp.tipo_id'); + + CALL util.exec (sql_printf + ( + 'INSERT INTO vn2008.article_inventory (article_id) + SELECT Id_Article + FROM vn2008.Articles A + LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id + JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id + JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador + WHERE r.display <> 0 AND %s;' + ,strFILTRO + )); IF v_date < CURDATE() THEN @@ -73338,7 +74626,7 @@ BEGIN ELSE - CALL inventario_multiple_2 (v_date, i_wh, days); + CALL inventario_multiple_2 (vAvailableSinced, i_wh, days); CALL article_multiple_buy (v_date, i_wh); @@ -73349,21 +74637,23 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS wtable; CREATE TEMPORARY TABLE wtable ( - cy INT(6), + cy INT(6) PRIMARY KEY, ly INT(6) ); REPEAT SET i = i + 1; - SET wperiod = vnperiod(TIMESTAMPADD(DAY, 7*(i - 1), date_cyear_ini)); -- PAK 11/01/2016 + SET wperiod = vnperiod(TIMESTAMPADD(DAY, 7 * (i - 1), date_cyear_ini)); -- PAK 11/01/2016 INSERT INTO wtable(cy, ly) VALUES(wperiod, wperiod - 100); -- VALUES( ys * 100 + ws, (ys -1) * 100 + ws); -- PAK 11/01/2016 UNTIL i = 7 END REPEAT; - + + SELECT cy, ly INTO w1, y1 FROM wtable limit 1; SELECT cy, ly INTO w2, y2 FROM wtable WHERE cy > w1 limit 1; SELECT cy, ly INTO w3, y3 FROM wtable WHERE cy > w2 limit 1; SELECT cy, ly INTO w4, y4 FROM wtable WHERE cy > w3 limit 1; + SELECT cy, ly INTO w5, y5 FROM wtable WHERE cy > w4 limit 1; SELECT cy, ly INTO w6, y6 FROM wtable WHERE cy > w5 limit 1; SELECT cy, ly INTO w7, y7 FROM wtable WHERE cy > w6 limit 1; @@ -73393,15 +74683,16 @@ BEGIN ,CAST(SUM(IF(Periodo = y6, price, 0)) AS DECIMAL(10,0)) AS lprice6 ,CAST(SUM(IF(Periodo = y7, price, 0)) AS DECIMAL(10,0)) AS lprice7 - FROM Comparativa + FROM article_inventory ai + JOIN Comparativa c ON c.Id_Article = ai.article_id JOIN warehouse W on W.id = warehouse_id - WHERE (Periodo BETWEEN y1 and y7) + WHERE (Periodo BETWEEN y1 and y7) AND IF(i_wh = 0, W.is_comparative, i_wh = warehouse_id) - GROUP BY Id_Article; - + GROUP BY Id_Article; + -- Genera una tabla con los datos de este año. - DROP TEMPORARY TABLE IF EXISTS cur_year; + CREATE TEMPORARY TABLE cur_year (KEY (Id_Article)) ENGINE = MEMORY @@ -73425,39 +74716,34 @@ BEGIN FROM ( SELECT A.Id_Article - ,CTS.period week - ,SUM(Cantidad) AS Total - ,TRUNCATE(SUM(Cantidad * IF(T.Fecha >= '2015-10-01',M.CostFixat,Preu * (100 - Descuento) / 100)),0) AS price - FROM Movimientos M - LEFT JOIN Tickets T ON T.Id_Ticket = M.Id_Ticket - INNER JOIN `time` CTS ON CTS.`date` = DATE(T.Fecha) - INNER JOIN Articles A USING (Id_Article) - INNER JOIN Tipos tp ON tp.tipo_id = A.tipo_id - LEFT JOIN reinos r ON r.id = tp.reino_id - JOIN warehouse W ON W.id = T.warehouse_id - WHERE Fecha BETWEEN date_cyear_ini AND date_cyear_end - AND T.Id_Cliente NOT IN(400,200) - AND IF(i_wh = 0, W.is_comparative, i_wh = T.warehouse_id) - AND r.display <> 0 - - GROUP BY A.Id_Article, week + ,CTS.period week + ,SUM(Cantidad) AS Total + ,TRUNCATE(SUM(Cantidad * M.CostFixat),0) AS price + FROM Tickets T + straight_JOIN Movimientos M ON T.Id_Ticket = M.Id_Ticket + JOIN article_inventory ai ON M.Id_Article = ai.article_id + JOIN `time` CTS ON CTS.`date` = DATE(T.Fecha) + JOIN Articles A USING (Id_Article) + JOIN Tipos tp ON tp.tipo_id = A.tipo_id + JOIN reinos r ON r.id = tp.reino_id + JOIN warehouse W ON W.id = T.warehouse_id + JOIN vn.`client` c ON c.id = T.Id_Cliente + WHERE Fecha BETWEEN date_cyear_ini AND date_cyear_end + AND c.typeFk IN ('Normal','handMaking') + AND IF(i_wh = 0, W.is_comparative, i_wh = T.warehouse_id) + AND r.display <> 0 + GROUP BY A.Id_Article, week ) t GROUP BY Id_Article; -- Genera la tabla con la comparativa. - DROP TEMPORARY TABLE IF EXISTS remcom; - - SET strFILTRO = REPLACE(strFILTRO, 'Id_Article','A.Id_Article'); - SET strFILTRO = REPLACE(strFILTRO, 'tipo_id','tp.tipo_id'); - -- select * from article_inventory; - DROP TEMPORARY TABLE IF EXISTS tmp.comparative; CALL util.exec (sql_printf ( 'CREATE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY SELECT - an.nicho, p.name Productor, C.Packing, C.Costefijo, C.caja + p.name Productor, C.Packing, C.Costefijo, C.caja ,A.Color, Id_Tipo as Tipo,A.tipo_id, o.Abreviatura as Origen, A.Categoria ,A.Tallos, A.Medida, A.Article, TR.CodigoTrabajador @@ -73472,17 +74758,12 @@ BEGIN ,E.Id_Proveedor AS provider_id ,A.offer, A.bargain, A.comments, A.relevancy, A.description itemDescription ,IF(cy.Id_Article IS NULL AND i.visible = 0 AND i.avalaible = 0 AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) AS filtret - ,(IFNULL(it.itemFk,0) != 0) isTagged - ,A.tag5, A.value5, A.tag6, A.value6, A.tag7, A.value7, A.tag8, A.value8 - ,A.tag9, A.value9, A.tag10, A.value10, A.description,A.isActive, A.density + ,A.tag9, A.value9, A.tag10, A.value10, A.description, A.isActive, A.density FROM vn2008.article_inventory i - JOIN vn2008.Articles A ON A.Id_Article = i.article_id - LEFT JOIN vn.itemTagged it ON it.itemFk = i.article_id - LEFT JOIN vn2008.Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = %s + JOIN vn2008.Articles A ON A.Id_Article = i.article_id LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id LEFT JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador LEFT JOIN vn2008.Compres C ON i.buy_id = C.Id_Compra LEFT JOIN vn2008.Entradas E USING(Id_Entrada) @@ -73490,10 +74771,252 @@ BEGIN LEFT JOIN vn2008.last_year ly ON ly.Id_Article = A.Id_Article LEFT JOIN vn2008.cur_year cy ON cy.Id_Article = A.Id_Article AND (i.avalaible <> 0 OR i.visible <> 0 OR cweek1 OR cweek2 OR cweek3 OR cweek4 OR cweek5 OR cweek6 OR cweek7 OR lweek1 OR lweek2 OR lweek3 OR lweek4 OR lweek5 - OR lweek6 OR lweek7) - WHERE r.display <> 0 AND %s ' - - ,i_wh,strFILTRO + OR lweek6 OR lweek7)' + )); + + -- Destruye las tablas temporales creadas. + + DROP TEMPORARY TABLE last_year; + DROP TEMPORARY TABLE cur_year; + DROP TEMPORARY TABLE article_inventory; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `comparative2` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `comparative2`( + v_date DATETIME + ,days TINYINT + ,i_wh TINYINT + ,i_tipo INT + ,i_filtro INT + ,vAvailableSinced DATE +) +BEGIN + DECLARE date_cyear_ini DATETIME; + DECLARE date_cyear_end DATETIME; + DECLARE week_count TINYINT DEFAULT 7; + DECLARE w1, w2, w3, w4, w5, w6, w7 INT; + DECLARE y1, y2, y3, y4, y5, y6, y7 INT; + DECLARE wperiod INT; + DECLARE i INT DEFAULT 0; + DECLARE strFILTRO VARCHAR(255) DEFAULT 'TRUE'; + + IF i_filtro THEN + SELECT `sql` INTO strFILTRO FROM filtros WHERE id = i_filtro; + END IF; + + IF i_tipo THEN + SET strFILTRO = CONCAT(strFILTRO, ' AND tipo_id = ', i_tipo); + END IF; + + IF days < 0 OR days > 60 THEN + SET days = 15; + END IF; + + IF i_wh = NULL THEN + SET i_wh = 0; + END IF; + -- JGF 2015-04-16 cambio -21 por -22 para que la semana cuente de domingo a sabado + SET date_cyear_ini = TIMESTAMP(DATE(TIMESTAMPADD(DAY, -22 - WEEKDAY(v_date), v_date)), '00:00:00'); + SET date_cyear_end = TIMESTAMP(DATE(TIMESTAMPADD(DAY, (7 * week_count) -1, date_cyear_ini)), '23:59:59'); + -- Eliminamos el calculo del inventario para fechas en el pasado + + DROP TEMPORARY TABLE IF EXISTS `article_inventory`; + CREATE TEMPORARY TABLE `article_inventory` + ( + `article_id` INT(11) NOT NULL PRIMARY KEY + ) + ENGINE = MEMORY; + + SET strFILTRO = REPLACE(strFILTRO, 'Id_Article','A.Id_Article'); + SET strFILTRO = REPLACE(strFILTRO, 'tipo_id','tp.tipo_id'); + + CALL util.exec (sql_printf + ( + 'INSERT INTO vn2008.article_inventory (article_id) + SELECT Id_Article + FROM vn2008.Articles A + LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id + JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id + JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador + WHERE r.display <> 0 AND %s;' + ,strFILTRO + )); + + IF v_date < CURDATE() + THEN + ALTER TABLE `article_inventory` + ADD `buy_id` INT NOT NULL DEFAULT 0, + ADD `buy_date` DATE DEFAULT '2000-01-01', + ADD `life` INT DEFAULT 0, + ADD `sd` INT DEFAULT 0, + ADD `avalaible` INT DEFAULT 0, + ADD `visible` INT DEFAULT 0; + + ELSE + + CALL inventario_multiple_2 (vAvailableSinced, i_wh, days); + + CALL article_multiple_buy (v_date, i_wh); + + CALL article_multiple_buy_date (v_date, i_wh); + + END IF; + + DROP TEMPORARY TABLE IF EXISTS wtable; + + CREATE TEMPORARY TABLE wtable ( + cy INT(6), + ly INT(6) + ); + + REPEAT + SET i = i + 1; + SET wperiod = vnperiod(TIMESTAMPADD(DAY, 7 * (i - 1), date_cyear_ini)); -- PAK 11/01/2016 + INSERT INTO wtable(cy, ly) VALUES(wperiod, wperiod - 100); -- VALUES( ys * 100 + ws, (ys -1) * 100 + ws); -- PAK 11/01/2016 + + UNTIL i = 7 END REPEAT; + + + SELECT cy, ly INTO w1, y1 FROM wtable limit 1; + SELECT cy, ly INTO w2, y2 FROM wtable WHERE cy > w1 limit 1; + SELECT cy, ly INTO w3, y3 FROM wtable WHERE cy > w2 limit 1; + SELECT cy, ly INTO w4, y4 FROM wtable WHERE cy > w3 limit 1; + + SELECT cy, ly INTO w5, y5 FROM wtable WHERE cy > w4 limit 1; + SELECT cy, ly INTO w6, y6 FROM wtable WHERE cy > w5 limit 1; + SELECT cy, ly INTO w7, y7 FROM wtable WHERE cy > w6 limit 1; + DROP TEMPORARY TABLE wtable; + + -- Genera una tabla con los datos del año pasado. + + DROP TEMPORARY TABLE IF EXISTS last_year; + CREATE TEMPORARY TABLE last_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(Periodo = y1, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek1 + ,CAST(SUM(IF(Periodo = y2, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek2 + ,CAST(SUM(IF(Periodo = y3, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek3 + ,CAST(SUM(IF(Periodo = y4, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek4 + ,CAST(SUM(IF(Periodo = y5, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek5 + ,CAST(SUM(IF(Periodo = y6, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek6 + ,CAST(SUM(IF(Periodo = y7, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek7 + + ,CAST(SUM(IF(Periodo = y1, price, 0)) AS DECIMAL(10,0)) AS lprice1 + ,CAST(SUM(IF(Periodo = y2, price, 0)) AS DECIMAL(10,0)) AS lprice2 + ,CAST(SUM(IF(Periodo = y3, price, 0)) AS DECIMAL(10,0)) AS lprice3 + ,CAST(SUM(IF(Periodo = y4, price, 0)) AS DECIMAL(10,0)) AS lprice4 + ,CAST(SUM(IF(Periodo = y5, price, 0)) AS DECIMAL(10,0)) AS lprice5 + ,CAST(SUM(IF(Periodo = y6, price, 0)) AS DECIMAL(10,0)) AS lprice6 + ,CAST(SUM(IF(Periodo = y7, price, 0)) AS DECIMAL(10,0)) AS lprice7 + + FROM article_inventory ai + JOIN Comparativa c ON c.Id_Article = ai.article_id + JOIN warehouse W on W.id = warehouse_id + WHERE (Periodo BETWEEN y1 and y7) + AND IF(i_wh = 0, W.is_comparative, i_wh = warehouse_id) + GROUP BY Id_Article; + + -- Genera una tabla con los datos de este año. + DROP TEMPORARY TABLE IF EXISTS cur_year; + + CREATE TEMPORARY TABLE cur_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(week = w1, Total, 0)) AS DECIMAL(10,0)) AS cweek1 + ,CAST(SUM(IF(week = w2, Total, 0)) AS DECIMAL(10,0)) AS cweek2 + ,CAST(SUM(IF(week = w3, Total, 0)) AS DECIMAL(10,0)) AS cweek3 + ,CAST(SUM(IF(week = w4, Total, 0)) AS DECIMAL(10,0)) AS cweek4 + ,CAST(SUM(IF(week = w5, Total, 0)) AS DECIMAL(10,0)) AS cweek5 + ,CAST(SUM(IF(week = w6, Total, 0)) AS DECIMAL(10,0)) AS cweek6 + ,CAST(SUM(IF(week = w7, Total, 0)) AS DECIMAL(10,0)) AS cweek7 + + ,CAST(SUM(IF(week = w1, price, 0)) AS DECIMAL(10,0)) AS cprice1 + ,CAST(SUM(IF(week = w2, price, 0)) AS DECIMAL(10,0)) AS cprice2 + ,CAST(SUM(IF(week = w3, price, 0)) AS DECIMAL(10,0)) AS cprice3 + ,CAST(SUM(IF(week = w4, price, 0)) AS DECIMAL(10,0)) AS cprice4 + ,CAST(SUM(IF(week = w5, price, 0)) AS DECIMAL(10,0)) AS cprice5 + ,CAST(SUM(IF(week = w6, price, 0)) AS DECIMAL(10,0)) AS cprice6 + ,CAST(SUM(IF(week = w7, price, 0)) AS DECIMAL(10,0)) AS cprice7 + + FROM ( + SELECT A.Id_Article + ,CTS.period week + ,SUM(Cantidad) AS Total + ,TRUNCATE(SUM(Cantidad * M.CostFixat),0) AS price + FROM Tickets T + straight_JOIN Movimientos M ON T.Id_Ticket = M.Id_Ticket + JOIN article_inventory ai ON M.Id_Article = ai.article_id + JOIN `time` CTS ON CTS.`date` = DATE(T.Fecha) + JOIN Articles A USING (Id_Article) + JOIN Tipos tp ON tp.tipo_id = A.tipo_id + JOIN reinos r ON r.id = tp.reino_id + JOIN warehouse W ON W.id = T.warehouse_id + JOIN vn.`client` c ON c.id = T.Id_Cliente + WHERE Fecha BETWEEN date_cyear_ini AND date_cyear_end + AND c.typeFk IN ('Normal','handMaking') + AND IF(i_wh = 0, W.is_comparative, i_wh = T.warehouse_id) + AND r.display <> 0 + GROUP BY A.Id_Article, week + ) t + GROUP BY Id_Article; + -- Genera la tabla con la comparativa. + + DROP TEMPORARY TABLE IF EXISTS remcom; + + DROP TEMPORARY TABLE IF EXISTS tmp.comparative; + + CALL util.exec (sql_printf + ( + 'CREATE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY + SELECT + p.name Productor, C.Packing, C.Costefijo, C.caja + ,A.Color, Id_Tipo as Tipo,A.tipo_id, o.Abreviatura as Origen, A.Categoria + ,A.Tallos, A.Medida, A.Article, TR.CodigoTrabajador + + ,cweek1, cweek2, cweek3, cweek4, cweek5, cweek6, cweek7 + ,lweek1, lweek2, lweek3, lweek4, lweek5, lweek6, lweek7 + + ,cprice1, cprice2, cprice3, cprice4, cprice5, cprice6, cprice7 + ,lprice1, lprice2, lprice3, lprice4, lprice5, lprice6, lprice7 + + ,A.Id_Article, i.buy_id , tp.life , CAST(IFNULL(i.sd,0) AS SIGNED) as sd + ,CAST(i.avalaible AS SIGNED) avalaible, CAST(i.visible AS SIGNED) visible, i.buy_date + ,E.Id_Proveedor AS provider_id + ,A.offer, A.bargain, A.comments, A.relevancy, A.description itemDescription + ,IF(cy.Id_Article IS NULL AND i.visible = 0 AND i.avalaible = 0 AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) AS filtret + ,A.tag5, A.value5, A.tag6, A.value6, A.tag7, A.value7, A.tag8, A.value8 + ,A.tag9, A.value9, A.tag10, A.value10, A.description, A.isActive, A.density + FROM vn2008.article_inventory i + JOIN vn2008.Articles A ON A.Id_Article = i.article_id + LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id + LEFT JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id + LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador + LEFT JOIN vn2008.Compres C ON i.buy_id = C.Id_Compra + LEFT JOIN vn2008.Entradas E USING(Id_Entrada) + LEFT JOIN vn2008.Origen o ON o.id = A.id_origen + LEFT JOIN vn2008.last_year ly ON ly.Id_Article = A.Id_Article + LEFT JOIN vn2008.cur_year cy ON cy.Id_Article = A.Id_Article AND (i.avalaible <> 0 OR i.visible <> 0 OR cweek1 OR cweek2 OR cweek3 OR cweek4 + OR cweek5 OR cweek6 OR cweek7 OR lweek1 OR lweek2 OR lweek3 OR lweek4 OR lweek5 + OR lweek6 OR lweek7)' )); -- Destruye las tablas temporales creadas. @@ -73501,7 +75024,6 @@ BEGIN DROP TEMPORARY TABLE last_year; DROP TEMPORARY TABLE cur_year; DROP TEMPORARY TABLE article_inventory; - DROP TEMPORARY TABLE wtable; END ;; DELIMITER ; @@ -74048,34 +75570,27 @@ CREATE DEFINER=`root`@`%` PROCEDURE `createBouquet`( vSize int, vColour VARCHAR(5), OUT vItem INT(11) - ) BEGIN - DECLARE vDate DATE; - DECLARE vCodintrastat INT(11); -- COMPROBAMOS SI EXISTE UN ARTÍCULO IGUAL. - SELECT - Id_Article - INTO vItem FROM - Articles - WHERE - (Id_Article BETWEEN 161000 AND 169000) + 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; + LIMIT 1; - -- SI NO EXISTE CREAMOS UNO NUEVO - IF vItem IS NULL THEN - + -- 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; - -- 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 Articles(Id_Article, Article, tipo_id, Medida, color, id_origen) + -- INSERTAR EL ARTÍCULO + INSERT INTO vn.item (id, `name`, typeFk, size, inkFk, originFk) VALUES ( vItem, vName, @@ -74084,7 +75599,7 @@ BEGIN vColour, 1 ); - END IF; + END IF; END ;; DELIMITER ; @@ -76475,10 +77990,10 @@ FROM LEFT JOIN Tipos ti ON ti.Id_Tipo = a.tipo_id LEFT JOIN Trabajadores tra ON tra.Id_Trabajador = ti.Id_Trabajador WHERE TR.landing >= datFEC - AND wh IN (TR.warehouse_id , 0) - AND C.Id_Article = idART - AND E.Inventario = 0 - + AND wh IN (TR.warehouse_id , 0) + AND C.Id_Article = idART + AND E.Inventario = 0 + AND E.Redada = 0 UNION ALL SELECT TR.shipment as Fecha, @@ -76500,23 +78015,23 @@ FROM LEFT JOIN Tipos ti ON ti.Id_Tipo = a.tipo_id LEFT JOIN Trabajadores tra ON tra.Id_Trabajador = ti.Id_Trabajador WHERE TR.shipment >= datFEC - AND wh IN (TR.warehouse_id_out,0) - AND Id_Proveedor <> 4 - AND C.Id_Article = idART - AND E.Inventario = 0 - AND fuente = 0 - + AND wh IN (TR.warehouse_id_out,0) + AND Id_Proveedor <> 4 + AND C.Id_Article = idART + AND E.Inventario = 0 + AND fuente = 0 + AND E.Redada = 0 UNION ALL SELECT T.Fecha as Fecha, - NULL as Entrada, - M.Cantidad as Salida, - (IFNULL(ts.alertLevel,0) > 1 OR ok ) as OK, - T.Alias as Alias, - T.Localizacion as Referencia, - T.Id_Ticket as id, - FALSE EtiquetasEmitidas, - C.Calidad, tr.CodigoTrabajador + NULL as Entrada, + M.Cantidad as Salida, + (IFNULL(ts.alertLevel,0) > 1 OR ok ) as OK, + T.Alias as Alias, + T.Localizacion as Referencia, + T.Id_Ticket as id, + FALSE EtiquetasEmitidas, + C.Calidad, tr.CodigoTrabajador FROM Movimientos M JOIN Tickets T USING (Id_Ticket) @@ -76526,7 +78041,6 @@ FROM WHERE T.Fecha >= datFEC AND M.Id_Article = idART AND wh IN (T.warehouse_id , 0) - ) AS Historico ORDER BY Fecha, OK DESC, Entrada DESC; @@ -76537,7 +78051,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `historicoprecio` */; +/*!50003 DROP PROCEDURE IF EXISTS `historicoprecio2__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -76547,60 +78061,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `historicoprecio`( id_art INT, id_wh INT,id_datestart DATE,id_dateend DATE) -BEGIN - - - SET @@max_sp_recursion_depth = 100 ; - DROP TEMPORARY TABLE IF EXISTS historicoprecio; - - CREATE TEMPORARY TABLE historicoprecio - ( - date_start DATE, - rate_0 DOUBLE, - rate_1 DOUBLE, - rate_2 DOUBLE, - rate_3 DOUBLE, - PRIMARY KEY (date_start) - ) - ENGINE = MEMORY; - - - CALL historicoprecio2 (id_art,id_wh,id_datestart,id_dateend); - - - SET @a:= @b:= @c:= @d:= @e:= @f := @g:= @h:=0.0; - SELECT * FROM - (SELECT d.`date` landing,if(rate_0 IS NULL,@a,@a:=rate_0) Costefijo,if(rate_1 IS NULL,@b,@b:=rate_1) rate_1, - if(rate_2 IS NULL,@c,@c:=rate_2) rate_2,if(rate_3 IS NULL,@d,@d:=rate_3) rate_3,'PF' tipo FROM `time` d - LEFT JOIN historicoprecio hp ON d.`date` = hp.date_start WHERE d.`date` BETWEEN id_datestart AND id_dateend - UNION ALL - SELECT DISTINCT d.`date` ,if(Costefijo IS NULL,@e,@e:=Costefijo) Costefijo,if(Tarifa1 IS NULL,@f,@f:=Tarifa1), - if(Tarifa2 IS NULL,@g,@g:=Tarifa2),if(Tarifa3 IS NULL,@h,@h:=Tarifa3),'C' - FROM `time` d - LEFT JOIN travel t ON t.landing = d.`date` - LEFT JOIN Entradas e ON e.travel_id = t.id - LEFT JOIN Compres c ON c.Id_Entrada = e.Id_Entrada AND id_wh IN (0,warehouse_id) AND c.Id_Article = id_art AND NoVincular = FALSE - WHERE d.`date` BETWEEN id_datestart AND id_dateend - ) - t ORDER BY landing DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `historicoprecio2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `historicoprecio2`( id_art INT, id_wh INT,id_datestart DATE,id_dateend DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `historicoprecio2__`( id_art INT, id_wh INT,id_datestart DATE,id_dateend DATE) BEGIN DECLARE done BIT DEFAULT 0; DECLARE datini,datfin,datiniaux,datfinaux DATE; @@ -76668,6 +78129,59 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `historicoprecio__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `historicoprecio__`( id_art INT, id_wh INT,id_datestart DATE,id_dateend DATE) +BEGIN + + + SET @@max_sp_recursion_depth = 100 ; + DROP TEMPORARY TABLE IF EXISTS historicoprecio; + + CREATE TEMPORARY TABLE historicoprecio + ( + date_start DATE, + rate_0 DOUBLE, + rate_1 DOUBLE, + rate_2 DOUBLE, + rate_3 DOUBLE, + PRIMARY KEY (date_start) + ) + ENGINE = MEMORY; + + + CALL historicoprecio2 (id_art,id_wh,id_datestart,id_dateend); + + + SET @a:= @b:= @c:= @d:= @e:= @f := @g:= @h:=0.0; + SELECT * FROM + (SELECT d.`date` landing,if(rate_0 IS NULL,@a,@a:=rate_0) Costefijo,if(rate_1 IS NULL,@b,@b:=rate_1) rate_1, + if(rate_2 IS NULL,@c,@c:=rate_2) rate_2,if(rate_3 IS NULL,@d,@d:=rate_3) rate_3,'PF' tipo FROM `time` d + LEFT JOIN historicoprecio hp ON d.`date` = hp.date_start WHERE d.`date` BETWEEN id_datestart AND id_dateend + UNION ALL + SELECT DISTINCT d.`date` ,if(Costefijo IS NULL,@e,@e:=Costefijo) Costefijo,if(Tarifa1 IS NULL,@f,@f:=Tarifa1), + if(Tarifa2 IS NULL,@g,@g:=Tarifa2),if(Tarifa3 IS NULL,@h,@h:=Tarifa3),'C' + FROM `time` d + LEFT JOIN travel t ON t.landing = d.`date` + LEFT JOIN Entradas e ON e.travel_id = t.id + LEFT JOIN Compres c ON c.Id_Entrada = e.Id_Entrada AND id_wh IN (0,warehouse_id) AND c.Id_Article = id_art AND NoVincular = FALSE + WHERE d.`date` BETWEEN id_datestart AND id_dateend + ) + t ORDER BY landing DESC; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `historico_absoluto` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76688,82 +78202,78 @@ DECLARE fecha_inv DATETIME; SET today = curdate(); DROP TEMPORARY TABLE IF EXISTS historico_pasado; - CREATE TEMPORARY TABLE historico_pasado - SELECT * - FROM ( - SELECT TR.landing as Fecha, - C.Cantidad as Entrada, - NULL as Salida, - (TR.received != FALSE) as OK, - P.Proveedor as Alias, - E.Referencia as Referencia, - E.Id_Entrada as id, - TR.delivered as F5, 0 as Calidad - FROM Compres C -- mirar perque no entra en received - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) - WHERE TR.landing >= '2001-01-01' - AND Id_proveedor <> 4 - AND wh IN (TR.warehouse_id , 0) - AND C.Id_Article = idART - AND E.Inventario = 0 + CREATE TEMPORARY TABLE historico_pasado + SELECT * + FROM ( + SELECT TR.landing as Fecha, + C.Cantidad as Entrada, + NULL as Salida, + (TR.received != FALSE) as OK, + P.Proveedor as Alias, + E.Referencia as Referencia, + E.Id_Entrada as id, + TR.delivered as F5, 0 as Calidad + FROM Compres C -- mirar perque no entra en received + INNER JOIN Entradas E USING (Id_Entrada) + INNER JOIN travel TR ON TR.id = E.travel_id + INNER JOIN Proveedores P USING (Id_Proveedor) + WHERE TR.landing >= '2001-01-01' + AND Id_proveedor <> 4 + AND wh IN (TR.warehouse_id , 0) + AND C.Id_Article = idART + AND E.Inventario = 0 + AND E.Redada = 0 + UNION ALL - UNION ALL + SELECT TR.shipment as Fecha, + NULL as Entrada, + C.Cantidad as Salida, + TR.delivered as OK, + P.Proveedor as Alias, + E.Referencia as Referencia, + E.Id_Entrada as id, + TR.delivered as F5, 0 as Calidad + FROM Compres C + INNER JOIN Entradas E USING (Id_Entrada) + INNER JOIN travel TR ON TR.id = E.travel_id + INNER JOIN Proveedores P USING (Id_Proveedor) - SELECT TR.shipment as Fecha, - NULL as Entrada, - C.Cantidad as Salida, - TR.delivered as OK, - P.Proveedor as Alias, - E.Referencia as Referencia, - E.Id_Entrada as id, - TR.delivered as F5, 0 as Calidad - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) + WHERE TR.shipment >= '2001-01-01' + AND wh = TR.warehouse_id_out + AND Id_Proveedor <> 4 + AND C.Id_Article = idART + AND E.Inventario = 0 + AND E.Redada = 0 + UNION ALL - WHERE TR.shipment >= '2001-01-01' - AND wh = TR.warehouse_id_out - AND Id_Proveedor <> 4 - AND C.Id_Article = idART - AND E.Inventario = 0 + SELECT T.Fecha as Fecha, + NULL as Entrada, + M.Cantidad as Salida, + (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, + T.Alias as Alias, + T.Factura as Referencia, + T.Id_Ticket,T.PedidoImpreso, + C.Calidad + FROM Movimientos M + INNER JOIN Tickets T USING (Id_Ticket) + JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente + WHERE T.Fecha >= '2001-01-01' + AND M.Id_Article = idART + AND wh IN (T.warehouse_id , 0) + ) as t1 ORDER BY Fecha, Entrada DESC, OK DESC; - UNION ALL + SELECT sum(Entrada) - sum(Salida) INTO inv_calculado + FROM historico_pasado + WHERE Fecha < datfecha; - SELECT T.Fecha as Fecha, - NULL as Entrada, - M.Cantidad as Salida, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, - T.Alias as Alias, - T.Factura as Referencia, - T.Id_Ticket,T.PedidoImpreso, - C.Calidad - FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' - AND M.Id_Article = idART - AND wh IN (T.warehouse_id , 0) - ) as t1 ORDER BY Fecha, Entrada DESC, OK DESC; - - SELECT sum(Entrada) - sum(Salida) INTO inv_calculado - FROM historico_pasado - WHERE Fecha < datfecha; - - -- WHERE historico_pasado.Fecha < fecha_inv ; - - -SELECT p1.*, NULL as v_virtual FROM( - SELECT datfecha as Fecha,inv_calculado as Entrada, NULL as Salida,1 as OK, - 'Inventario calculado' as Alias, '' as Referencia, 0 as id, 1 as F5, 0 as Calidad - UNION ALL - SELECT * FROM historico_pasado WHERE Fecha >= datfecha - )as p1; - - -DROP TEMPORARY TABLE historico_pasado; + SELECT p1.*, NULL as v_virtual FROM( + SELECT datfecha as Fecha,inv_calculado as Entrada, NULL as Salida,1 as OK, + 'Inventario calculado' as Alias, '' as Referencia, 0 as id, 1 as F5, 0 as Calidad + UNION ALL + SELECT * FROM historico_pasado WHERE Fecha >= datfecha + )as p1; + + DROP TEMPORARY TABLE historico_pasado; END ;; DELIMITER ; @@ -76779,7 +78289,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `historico_joined`(IN idART INT, IN wh_joined INT, IN v_virtual INT) BEGIN @@ -76818,10 +78328,10 @@ FROM 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 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 as Fecha, @@ -76843,11 +78353,11 @@ FROM 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 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 as Fecha, @@ -77823,221 +79333,6 @@ WHERE Unidades != 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 DROP PROCEDURE IF EXISTS `inventario_multiple` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple`(IN wh TINYINT(2), IN date_ticket DATETIME) -BEGIN --- DEPRECATED USAR cache.available_refresh - DECLARE date_order DATETIME; - DECLARE date_end DATETIME DEFAULT CURDATE(); - DECLARE date_aux DATE; - DECLARE date_start DATETIME; - DECLARE date_yesterday DATETIME; - DECLARE date_tomorrow DATETIME; - DECLARE strWH VARCHAR(2); - - SET strWH = IF(wh,wh,'%'); - SET date_end = TIMESTAMPADD(DAY, 7, date_ticket); - - CALL article (); - - ALTER TABLE `article_inventory` - ADD `available` FLOAT(7,2) NOT NULL, - ADD `inventory` FLOAT(7,2) NOT NULL, - ADD `visible` FLOAT(7,2) NOT NULL; - - -- JGF 2015-02-19 Falla, el valor @camp es cero y falla Campanya - /* - SELECT - IF(@camp := DATEDIFF(campaign, date_ticket) BETWEEN 0 AND campaign_life, - TIMESTAMPADD(DAY, -campaign_life, campaign), - FechaInventario), - IF(@camp BETWEEN 0 AND campaign_life, - TIMESTAMP(campaign, '23:59:59'), - TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59')) - INTO date_start, date_end - FROM tblContadores;*/ - - SELECT - FechaInventario,TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59') - INTO date_start, date_end - FROM tblContadores; - - - SET date_order = TIMESTAMP(DATE(date_ticket), '00:00:00'); - SET date_tomorrow = TIMESTAMPADD(DAY, 1, date_order); - --- Inventario hasta dia antes del ticket - CALL item_stock(wh,date_ticket,NULL); - - INSERT INTO article_inventory (article_id,inventory,visible,available) - SELECT item_id, stock, visible, available - FROM tmp_item; - - DROP TEMPORARY TABLE IF EXISTS tmp_item; - --- Inventario ventas durante el dia del ticket - INSERT INTO article_inventory(article_id,visible) - - SELECT Id_Article, SUM(amount) AS Subtotal - - FROM ( - - SELECT Id_Article, -Cantidad AS amount - - FROM Movimientos M INNER JOIN Tickets T USING (Id_Ticket) - - WHERE Fecha >= date_order - - AND Fecha < date_tomorrow - - AND (M.OK != FALSE - - OR T.Etiquetasemitidas != FALSE - - OR T.Factura IS NOT NULL) - - AND T.warehouse_id = wh - - UNION ALL - - SELECT Id_Article, Cantidad - - FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) - - LEFT JOIN travel TR ON E.travel_id = TR.id - - WHERE TR.landing >= date_order - - AND TR.landing < date_tomorrow - - AND TR.received != FALSE - - AND TR.warehouse_id = wh - - AND E.Inventario = FALSE - - AND E.Redada = FALSE - - UNION ALL - - SELECT Id_Article, -Cantidad - - FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) - - LEFT JOIN travel TR ON E.travel_id = TR.id - - WHERE TR.shipment >= date_order - - AND TR.shipment < date_tomorrow - - AND TR.delivered != FALSE - - AND TR.warehouse_id_out = wh - - AND E.Inventario = FALSE - - AND E.Redada = FALSE - - ) AS T1 - - GROUP BY Id_Article - - ON DUPLICATE KEY UPDATE - - visible = inventory + VALUES(visible); - - - -- Disponible en el futuro - CALL item_travel (wh, date_order); - - SET date_aux = DATE(date_order); - - INSERT INTO article_inventory(article_id,available) - - SELECT Tic3.Id_Article, minacum(dat, amount, date_aux) AS sd - - FROM ( - - SELECT Tic2.Id_Article, DATE(Fecha) AS dat, SUM(amount) AS amount - - FROM ( - - SELECT Id_Article, Fecha, -Cantidad AS amount - - FROM Movimientos M - - INNER JOIN Tickets T USING (Id_Ticket) - - WHERE Fecha BETWEEN date_order AND date_end - - AND T.warehouse_id = wh - - UNION ALL - - SELECT Id_Article, TR.landing, Cantidad - - FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) - - LEFT JOIN travel TR ON E.travel_id = TR.id - - WHERE TR.landing BETWEEN date_order AND date_end - - AND TR.warehouse_id = wh - - AND E.Inventario = FALSE - - AND E.Redada = FALSE - - UNION ALL - - SELECT Id_Article, TR.shipment, -Cantidad - - FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) - - LEFT JOIN travel TR ON E.travel_id = TR.id - - WHERE TR.shipment BETWEEN date_order AND date_end - - AND TR.warehouse_id_out = wh - - AND E.Inventario = FALSE - - AND E.Redada = FALSE - - ) AS Tic2 - - GROUP BY Tic2.Id_Article, dat - - ) Tic3 - - LEFT JOIN Articles A ON Tic3.Id_Article = A.Id_Article - - LEFT JOIN Origen O ON O.id = A.id_origen - - LEFT JOIN item_travel t ON t.wh = O.warehouse_id - - WHERE dat < IFNULL(t.landing, date_end) - - GROUP BY Tic3.Id_Article - - ON DUPLICATE KEY UPDATE - - available = IFNULL(inventory,0) + VALUES(available); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78055,7 +79350,7 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_2`( - date_ticket DATETIME + date_ticket DATE ,wh TINYINT ,days_max TINYINT ) @@ -78063,9 +79358,8 @@ proc: BEGIN DECLARE date_end DATETIME DEFAULT CURDATE(); DECLARE date_start DATETIME; DECLARE date_top DATETIME; - DECLARE date_tomorrow DATETIME; - - SET date_ticket = DATE(date_ticket); -- PAK + DECLARE date_tomorrow DATE; + DECLARE vTicketDayEnd DATETIME; ALTER TABLE `article_inventory` ADD `avalaible` INT NOT NULL, @@ -78082,10 +79376,11 @@ proc: BEGIN END IF; SET date_tomorrow = TIMESTAMPADD(DAY, 1,date_ticket); - SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, IFNULL(days_max,15), date_ticket),'23:59:59'); + SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, IFNULL(days_max,21), date_ticket),'23:59:59'); SET date_top = TIMESTAMPADD(DAY, 1,date_end); - - IF date_ticket <= CURDATE() THEN + SET vTicketDayEnd = util.dayEnd(date_ticket); + + IF date_ticket = CURDATE() THEN SELECT FechaInventario INTO date_start FROM tblContadores; ELSE SET date_start = date_ticket; @@ -78106,7 +79401,7 @@ proc: BEGIN FROM Movimientos M JOIN Tickets T USING (Id_Ticket) JOIN warehouse W ON W.id = T.warehouse_id - WHERE DATE(Fecha) BETWEEN date_start AND date_ticket + WHERE Fecha BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =T.warehouse_id) UNION ALL @@ -78115,7 +79410,7 @@ proc: BEGIN FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) LEFT JOIN travel TR ON E.travel_id = TR.id JOIN warehouse W ON W.id = TR.warehouse_id -- PAK - WHERE TR.landing BETWEEN date_start AND date_ticket + WHERE TR.landing BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id) AND E.Inventario = 0 AND E.Redada = 0 @@ -78127,7 +79422,7 @@ proc: BEGIN JOIN Entradas E USING (Id_Entrada) JOIN travel TR ON E.travel_id = TR.id JOIN warehouse W ON W.id = TR.warehouse_id_out - WHERE TR.shipment BETWEEN date_start AND date_ticket + WHERE TR.shipment BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id_out) AND E.Inventario = 0 AND E.Redada = 0 @@ -78244,9 +79539,9 @@ proc: BEGIN GROUP BY Tic2.Id_Article, Fecha ) Tic3 - LEFT JOIN Articles A ON Tic3.Id_Article = A.Id_Article - LEFT JOIN Origen O ON O.id = A.id_origen - LEFT JOIN item_travel t ON t.wh = O.warehouse_id + LEFT JOIN Articles A ON Tic3.Id_Article = A.Id_Article + LEFT JOIN Origen O ON O.id = A.id_origen + LEFT JOIN item_travel t ON t.wh = O.warehouse_id WHERE Fecha < IF(days_max < 0 AND t.landing IS NOT NULL, t.landing, @@ -78260,6 +79555,8 @@ proc: BEGIN ON Tic5.Id_Article = AI.article_id SET AI.avalaible = IF(Tic5.smd > 0, AI.avalaible, AI.avalaible + Tic5.smd), AI.sd = AI.inventory + Tic5.sd; + + DROP TEMPORARY TABLE IF EXISTS item_travel; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78277,7 +79574,7 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_2__`( - date_ticket DATETIME + date_ticket DATE ,wh TINYINT ,days_max TINYINT ) @@ -78285,9 +79582,8 @@ proc: BEGIN DECLARE date_end DATETIME DEFAULT CURDATE(); DECLARE date_start DATETIME; DECLARE date_top DATETIME; - DECLARE date_tomorrow DATETIME; - - SET date_ticket = DATE(date_ticket); -- PAK + DECLARE date_tomorrow DATE; + DECLARE vTicketDayEnd DATETIME; ALTER TABLE `article_inventory` ADD `avalaible` INT NOT NULL, @@ -78303,14 +79599,19 @@ proc: BEGIN LEAVE proc; END IF; - SELECT FechaInventario INTO date_start FROM tblContadores; - - SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, IF(days_max >= 0, days_max,15), date_ticket),'23:59:59'); SET date_tomorrow = TIMESTAMPADD(DAY, 1,date_ticket); - SET date_top = TIMESTAMPADD(DAY, 1,date_end); - + SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, IFNULL(days_max,15), date_ticket),'23:59:59'); + SET date_top = TIMESTAMPADD(DAY, 1,date_end); + SET vTicketDayEnd = util.dayEnd(date_ticket); + + IF date_ticket = CURDATE() THEN + SELECT FechaInventario INTO date_start FROM tblContadores; + ELSE + SET date_start = date_ticket; + END IF; + -- Calculo del inventario dia D a las 24:00 zulu - +CALL util.debugAdd('inventario','inventario'); UPDATE article_inventory AI INNER JOIN ( @@ -78324,7 +79625,7 @@ proc: BEGIN FROM Movimientos M JOIN Tickets T USING (Id_Ticket) JOIN warehouse W ON W.id = T.warehouse_id - WHERE DATE(Fecha) BETWEEN date_start AND date_ticket + WHERE Fecha BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =T.warehouse_id) UNION ALL @@ -78333,7 +79634,7 @@ proc: BEGIN FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) LEFT JOIN travel TR ON E.travel_id = TR.id JOIN warehouse W ON W.id = TR.warehouse_id -- PAK - WHERE TR.landing BETWEEN date_start AND date_ticket + WHERE TR.landing BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id) AND E.Inventario = 0 AND E.Redada = 0 @@ -78345,7 +79646,7 @@ proc: BEGIN JOIN Entradas E USING (Id_Entrada) JOIN travel TR ON E.travel_id = TR.id JOIN warehouse W ON W.id = TR.warehouse_id_out - WHERE TR.shipment BETWEEN date_start AND date_ticket + WHERE TR.shipment BETWEEN date_start AND vTicketDayEnd AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id_out) AND E.Inventario = 0 AND E.Redada = 0 @@ -78367,7 +79668,7 @@ proc: BEGIN AI.sd = T2.Subtotal; -- Calculo del visible - +CALL util.debugAdd('visible','visible'); UPDATE article_inventory AI INNER JOIN ( SELECT Id_Article, SUM(amount) as Subtotal FROM @@ -78418,7 +79719,7 @@ proc: BEGIN -- Calculo del disponible CALL item_travel (wh, date_ticket); - +CALL util.debugAdd('disponible','disponible'); UPDATE article_inventory AI INNER JOIN ( SELECT Tic3.Id_Article, SUM(amount) AS sd, minacum(Fecha, amount, date_ticket) as smd FROM @@ -78478,6 +79779,7 @@ proc: BEGIN ON Tic5.Id_Article = AI.article_id SET AI.avalaible = IF(Tic5.smd > 0, AI.avalaible, AI.avalaible + Tic5.smd), AI.sd = AI.inventory + Tic5.sd; +CALL util.debugAdd('fin','fin'); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78933,6 +80235,221 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `inventario_multiple__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple__`(IN wh TINYINT(2), IN date_ticket DATETIME) +BEGIN +-- DEPRECATED USAR cache.available_refresh + DECLARE date_order DATETIME; + DECLARE date_end DATETIME DEFAULT CURDATE(); + DECLARE date_aux DATE; + DECLARE date_start DATETIME; + DECLARE date_yesterday DATETIME; + DECLARE date_tomorrow DATETIME; + DECLARE strWH VARCHAR(2); + + SET strWH = IF(wh,wh,'%'); + SET date_end = TIMESTAMPADD(DAY, 7, date_ticket); + + CALL article (); + + ALTER TABLE `article_inventory` + ADD `available` FLOAT(7,2) NOT NULL, + ADD `inventory` FLOAT(7,2) NOT NULL, + ADD `visible` FLOAT(7,2) NOT NULL; + + -- JGF 2015-02-19 Falla, el valor @camp es cero y falla Campanya + /* + SELECT + IF(@camp := DATEDIFF(campaign, date_ticket) BETWEEN 0 AND campaign_life, + TIMESTAMPADD(DAY, -campaign_life, campaign), + FechaInventario), + IF(@camp BETWEEN 0 AND campaign_life, + TIMESTAMP(campaign, '23:59:59'), + TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59')) + INTO date_start, date_end + FROM tblContadores;*/ + + SELECT + FechaInventario,TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59') + INTO date_start, date_end + FROM tblContadores; + + + SET date_order = TIMESTAMP(DATE(date_ticket), '00:00:00'); + SET date_tomorrow = TIMESTAMPADD(DAY, 1, date_order); + +-- Inventario hasta dia antes del ticket + CALL item_stock(wh,date_ticket,NULL); + + INSERT INTO article_inventory (article_id,inventory,visible,available) + SELECT item_id, stock, visible, available + FROM tmp_item; + + DROP TEMPORARY TABLE IF EXISTS tmp_item; + +-- Inventario ventas durante el dia del ticket + INSERT INTO article_inventory(article_id,visible) + + SELECT Id_Article, SUM(amount) AS Subtotal + + FROM ( + + SELECT Id_Article, -Cantidad AS amount + + FROM Movimientos M INNER JOIN Tickets T USING (Id_Ticket) + + WHERE Fecha >= date_order + + AND Fecha < date_tomorrow + + AND (M.OK != FALSE + + OR T.Etiquetasemitidas != FALSE + + OR T.Factura IS NOT NULL) + + AND T.warehouse_id = wh + + UNION ALL + + SELECT Id_Article, Cantidad + + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + + LEFT JOIN travel TR ON E.travel_id = TR.id + + WHERE TR.landing >= date_order + + AND TR.landing < date_tomorrow + + AND TR.received != FALSE + + AND TR.warehouse_id = wh + + AND E.Inventario = FALSE + + AND E.Redada = FALSE + + UNION ALL + + SELECT Id_Article, -Cantidad + + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + + LEFT JOIN travel TR ON E.travel_id = TR.id + + WHERE TR.shipment >= date_order + + AND TR.shipment < date_tomorrow + + AND TR.delivered != FALSE + + AND TR.warehouse_id_out = wh + + AND E.Inventario = FALSE + + AND E.Redada = FALSE + + ) AS T1 + + GROUP BY Id_Article + + ON DUPLICATE KEY UPDATE + + visible = inventory + VALUES(visible); + + + -- Disponible en el futuro + CALL item_travel (wh, date_order); + + SET date_aux = DATE(date_order); + + INSERT INTO article_inventory(article_id,available) + + SELECT Tic3.Id_Article, minacum(dat, amount, date_aux) AS sd + + FROM ( + + SELECT Tic2.Id_Article, DATE(Fecha) AS dat, SUM(amount) AS amount + + FROM ( + + SELECT Id_Article, Fecha, -Cantidad AS amount + + FROM Movimientos M + + INNER JOIN Tickets T USING (Id_Ticket) + + WHERE Fecha BETWEEN date_order AND date_end + + AND T.warehouse_id = wh + + UNION ALL + + SELECT Id_Article, TR.landing, Cantidad + + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + + LEFT JOIN travel TR ON E.travel_id = TR.id + + WHERE TR.landing BETWEEN date_order AND date_end + + AND TR.warehouse_id = wh + + AND E.Inventario = FALSE + + AND E.Redada = FALSE + + UNION ALL + + SELECT Id_Article, TR.shipment, -Cantidad + + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + + LEFT JOIN travel TR ON E.travel_id = TR.id + + WHERE TR.shipment BETWEEN date_order AND date_end + + AND TR.warehouse_id_out = wh + + AND E.Inventario = FALSE + + AND E.Redada = FALSE + + ) AS Tic2 + + GROUP BY Tic2.Id_Article, dat + + ) Tic3 + + LEFT JOIN Articles A ON Tic3.Id_Article = A.Id_Article + + LEFT JOIN Origen O ON O.id = A.id_origen + + LEFT JOIN item_travel t ON t.wh = O.warehouse_id + + WHERE dat < IFNULL(t.landing, date_end) + + GROUP BY Tic3.Id_Article + + ON DUPLICATE KEY UPDATE + + available = IFNULL(inventory,0) + VALUES(available); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventario_valorado` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -79680,7 +81197,8 @@ BEGIN AND (s.isPicked OR st.isChecked) ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk WHERE warehouse_id = v_wh - AND (s.order > 6 OR i.Reservado OR stPrevious.saleFk ) + AND (v_item IS NULL OR i.item_id = v_item) + AND (s.isPicked OR i.Reservado OR stPrevious.saleFk ) AND i.dat >= CURDATE() AND i.dat < v_tomorrow UNION ALL SELECT item_id, amount @@ -82236,6 +83754,206 @@ BEGIN */ -- DROP TEMPORARY TABLE tmp.visible; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `production_buffer_problems_beta` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `production_buffer_problems_beta`() +BEGIN +/** + * @deprecated Use vn.ticketGetProblems + * Necesita la tabla tmp.ticket_list + */ + DECLARE vToday DATETIME; + DECLARE vTomorrowMidnight DATETIME ; + DECLARE vWarehouse INT; + DECLARE vDate DATE; + DECLARE vAvailableCache INT; + DECLARE vVisibleCache INT; + DECLARE vDone BOOL; + + DECLARE vCursor CURSOR FOR + SELECT warehouse_id, DATE(Fecha) + FROM tmp.ticket_list tt + JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket + AND DATE(t.Fecha) BETWEEN CURDATE() AND TIMESTAMPADD(DAY,1.9,CURDATE()) + LIMIT 1; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; +TRUNCATE tmp.log; + INSERT INTO tmp.log(text) VALUES('start'); -- DELETE ME + + DROP TEMPORARY TABLE IF EXISTS tmp.buffer_problems; + CREATE TEMPORARY TABLE tmp.buffer_problems ( + Id_Ticket INT(11), + problem VARCHAR(255), + `order` INT(11) DEFAULT 10, + INDEX (Id_Ticket) + ) + ENGINE = MEMORY; + + SET vToday = CURDATE(); + SET vTomorrowMidnight = TIMESTAMP(TIMESTAMPADD(DAY, 1, CURDATE()), '23:59:59'); + + -- Riesgo + + + CALL risk_vs_client_list(CURDATE()); + + + + INSERT INTO tmp.log(text) VALUES('risk'); -- DELETE ME + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'RIESGO', 1 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + JOIN Agencias a on t.Id_Agencia = a.Id_Agencia + JOIN tmp.risk r on r.Id_Cliente = t.Id_Cliente + JOIN Clientes c on c.Id_Cliente = t.Id_Cliente + WHERE r.risk > c.Credito + 10 + AND (Vista != 3 OR t.Id_Agencia = 687); -- para que las recogidas se preparen, salvo las de Madrid + + INSERT INTO tmp.log(text) VALUES('RIESGO'); -- DELETE ME + -- Congelado + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'CONGELADO', 2 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + JOIN Clientes c on c.Id_Cliente = t.Id_Cliente + WHERE c.Congelado; + INSERT INTO tmp.log(text) VALUES('CONGELADO'); -- DELETE ME + -- Datos del cliente sin confirmar + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'FICHA INCOMPLETA', 3 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + JOIN Clientes c on c.Id_Cliente = t.Id_Cliente + WHERE c.contabilizado = FALSE; + INSERT INTO tmp.log(text) VALUES('FICHA INCOMPLETA'); -- DELETE ME + OPEN vCursor; + + l: LOOP + SET vDone = FALSE; + FETCH vCursor INTO vWarehouse, vDate; + + IF vDone THEN + LEAVE l; + END IF; + + CALL cache.visible_refresh (vVisibleCache, FALSE, vWarehouse); + + INSERT INTO tmp.log(text) VALUES('VISIBLE'); -- DELETE ME + + CALL cache.available_refresh (vAvailableCache, FALSE, vWarehouse, vDate); + + INSERT INTO tmp.log(text) VALUES('AVAILABLE'); -- DELETE ME + + -- El disponible es menor que 0 + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, Article, 4 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + LEFT JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket + JOIN vn2008.Articles A ON A.Id_Article = M.Id_Article + JOIN vn2008.Tipos tp on tp.tipo_id = A.tipo_id + LEFT JOIN cache.visible v ON A.Id_Article = v.item_id AND v.calc_id = vVisibleCache + LEFT JOIN cache.available av ON av.item_id = A.Id_Article AND av.calc_id = vAvailableCache + WHERE date(t.Fecha) = vDate + AND reino_id NOT IN (8,6) + AND M.Cantidad > IFNULL(v.visible,0) + AND M.Cantidad > 0 + AND IFNULL(av.available,0) < 0 + AND M.OK = FALSE + AND NOT generic + AND vWarehouse = t.warehouse_id; + INSERT INTO tmp.log(text) VALUES('MENOR QUE 0'); -- DELETE ME + -- El disponible es mayor que cero y la cantidad supera el visible, estando aun sin preparar + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, CONCAT('RETRASO (', A.Id_Article, ') ', Article), 5 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + LEFT JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket + LEFT JOIN `vn`.`saleTracking` `stPrevious` + ON `stPrevious`.`saleFk` = M.Id_Movimiento + LEFT JOIN vn.state st ON st.id = `stPrevious`.`stateFk` + JOIN vn2008.Articles A ON A.Id_Article = M.Id_Article + JOIN vn2008.Tipos tp on tp.tipo_id = A.tipo_id + LEFT JOIN cache.visible v ON A.Id_Article = v.item_id AND v.calc_id = vVisibleCache + LEFT JOIN ( + SELECT Id_Article FROM Articles_nicho + WHERE DATE(modificationDate) = CURDATE() AND warehouse_id = vWarehouse + ) nicho ON nicho.Id_Article = A.Id_Article + LEFT JOIN cache.available av ON av.item_id = A.Id_Article AND av.calc_id = vAvailableCache + WHERE IFNULL(av.available,0) >= 0 + -- AND st.code = 'PREVIOUS_PREPARATION' + AND M.Cantidad > IFNULL(v.visible,0) + AND M.OK = FALSE + AND stPrevious.saleFk IS NULL + AND M.Reservado = FALSE + AND reino_id NOT IN (8,6) + AND date(t.Fecha) = vDate + AND NOT generic + AND CURDATE() = vDate + AND t.warehouse_id = vWarehouse + AND nicho.Id_Article IS NULL; + + INSERT INTO tmp.log(text) VALUES('RETRASO'); -- DELETE ME + + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, CONCAT('ALT (', CAST(M.Cantidad AS DECIMAL(10,0)), ') ',M.Id_Article, ' ', Concepte),6 + FROM tmp.ticket_list tt + JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket + JOIN vn.ticketStateToday tst ON tst.ticket = t.Id_Ticket + JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket + LEFT JOIN `vn`.`saleTracking` `stPrevious` + ON `stPrevious`.`saleFk` = M.Id_Movimiento AND stPrevious.isChecked = TRUE + LEFT JOIN vn.state st ON st.id = `stPrevious`.`stateFk` AND st.code = 'PREVIOUS_PREPARATION' + JOIN cache.visible v ON M.Id_Article = v.item_id AND v.calc_id = vVisibleCache + -- JOIN tmp.visible visible ON visible.itemFk = v.item_id AND visible.warehouseFk = vWarehouse + JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + -- WHERE v.visible - visible.visible < M.Cantidad + WHERE (v.visible - iss.visible) < M.Cantidad + AND M.OK = FALSE + AND stPrevious.saleFk IS NULL + AND M.Reservado = FALSE + AND CURDATE() = vDate + AND tst.productionOrder < 6 + AND t.warehouse_id = vWarehouse; + + INSERT INTO tmp.log(text) VALUES('ALTILLO'); -- DELETE ME + + END LOOP; + + CLOSE vCursor; + + -- Código 100 + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'COD 100', 7 + FROM tmp.ticket_list tt + JOIN vn.ticketRequest tr on tr.ticketFk = tt.Id_Ticket + WHERE tr.isOK IS NULL; + INSERT INTO tmp.log(text) VALUES('COD 100'); -- DELETE ME + + SELECT * FROM tmp.log; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -85274,6 +86992,9 @@ CREATE DEFINER=`root`@`%` PROCEDURE `sale_comparative`( ,vAvailableSinced DATE ) BEGIN + -- OBSOLETA NO USAR, el optimizado es vn2008.comparative + -- en la version de comparativa 618 hace referencia a este procedimiento por si fallase + -- JGF 2019-10-23 DECLARE date_cyear_ini DATETIME; DECLARE date_cyear_end DATETIME; DECLARE week_count TINYINT DEFAULT 7; @@ -88636,10 +90357,10 @@ BEGIN DECLARE intWarehouse INT; DECLARE datTicket DATE; - SELECT warehouse_id, Fecha INTO intWarehouse,datTicket FROM Tickets WHERE Id_Ticket = i_ticket; + SELECT warehouse_id, Fecha INTO intWarehouse, datTicket FROM Tickets WHERE Id_Ticket = i_ticket; CALL buy_tarifas_table(i_entrada); - CALL item_last_buy_(intWarehouse,datTicket); + CALL item_last_buy_(intWarehouse, datTicket); INSERT INTO Compres( Id_Article, Cantidad, @@ -90679,7 +92400,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20325798 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20864584 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -92878,24 +94599,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `dms` --- - -/*!50001 DROP VIEW IF EXISTS `dms`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `dms` AS select `g`.`id` AS `id`,`g`.`gesttip_id` AS `dmsTypeFk`,`g`.`file` AS `file`,`g`.`contentType` AS `contentType`,`g`.`trabajador_id` AS `workerFk`,`g`.`warehouse_id` AS `warehouseFk`,`g`.`emp_id` AS `companyFk`,`g`.`orden` AS `hardCopyNumber`,`g`.`original` AS `hasFile`,`g`.`sref` AS `reference`,`g`.`brief` AS `description`,`g`.`odbc_date` AS `created` from `vn2008`.`gestdoc` `g` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `dmsType__` -- @@ -92914,6 +94617,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `dms__` +-- + +/*!50001 DROP VIEW IF EXISTS `dms__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `dms__` AS select `g`.`id` AS `id`,`g`.`gesttip_id` AS `dmsTypeFk`,`g`.`file` AS `file`,`g`.`contentType` AS `contentType`,`g`.`trabajador_id` AS `workerFk`,`g`.`warehouse_id` AS `warehouseFk`,`g`.`emp_id` AS `companyFk`,`g`.`orden` AS `hardCopyNumber`,`g`.`original` AS `hasFile`,`g`.`sref` AS `reference`,`g`.`brief` AS `description`,`g`.`odbc_date` AS `created` from `vn2008`.`gestdoc` `g` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `doc` -- @@ -93311,19 +95032,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayLegend` +-- Final view structure for view `holidayLegend__` -- -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayLegend` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 VIEW `holidayLegend__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93665,7 +95386,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,max(`p`.`code`) AS `parking`,max(`p`.`sectorFk`) AS `sectorFk` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,max(`p`.`code`) AS `parking`,`ips`.`sectorFk` AS `sectorFk` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`itemShelving` `ish` on((`ish`.`id` = `isps`.`itemShelvingFk`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`p`.`sectorFk` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `itemPlacementSupplyList__` +-- + +/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `itemPlacementSupplyList__` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,max(`p`.`code`) AS `parking`,max(`p`.`sectorFk`) AS `sectorFk` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`p`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93701,7 +95440,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and (`stock`.`shelvingFk` <> 'FUE') and `st`.`sectorProdPriority`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`sectorProdPriority`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93737,7 +95476,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `itemShelvingPlacementSupplyStock__` +-- + +/*!50001 DROP VIEW IF EXISTS `itemShelvingPlacementSupplyStock__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `itemShelvingPlacementSupplyStock__` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93773,7 +95530,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `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`,sum(`issr`.`removed`) 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` 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 `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`itemFk` */; +/*!50001 VIEW `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`,sum(`issr`.`removed`) 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` 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 `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94427,10 +96184,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `receipt` +-- Final view structure for view `receipt__` -- -/*!50001 DROP VIEW IF EXISTS `receipt`*/; +/*!50001 DROP VIEW IF EXISTS `receipt__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -94439,7 +96196,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `receipt` AS select `t`.`Id` AS `id`,`t`.`Id_Factura` AS `invoiceFk`,`t`.`Entregado` AS `amountPaid`,`t`.`Pendiente` AS `amountUnpaid`,`t`.`Fechacobro` AS `payed`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`Id_Banco` AS `bankFk`,`t`.`Id_Cliente` AS `clientFk`,`t`.`odbc_date` AS `created`,`t`.`empresa_id` AS `companyFk`,`t`.`conciliado` AS `isConciliate` from `vn2008`.`Recibos` `t` */; +/*!50001 VIEW `receipt__` AS select `t`.`Id` AS `id`,`t`.`Id_Factura` AS `invoiceFk`,`t`.`Entregado` AS `amountPaid`,`t`.`Pendiente` AS `amountUnpaid`,`t`.`Fechacobro` AS `payed`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`Id_Banco` AS `bankFk`,`t`.`Id_Cliente` AS `clientFk`,`t`.`odbc_date` AS `created`,`t`.`empresa_id` AS `companyFk`,`t`.`conciliado` AS `isConciliate` from `vn2008`.`Recibos` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94661,10 +96418,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `sample` +-- Final view structure for view `sample__` -- -/*!50001 DROP VIEW IF EXISTS `sample`*/; +/*!50001 DROP VIEW IF EXISTS `sample__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -94673,7 +96430,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sample` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible`,`e`.`hasCompany` AS `hasCompany` from `vn2008`.`escritos` `e` */; +/*!50001 VIEW `sample__` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible`,`e`.`hasCompany` AS `hasCompany` from `vn2008`.`escritos` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94859,10 +96616,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `ticketDms` +-- Final view structure for view `ticketDms__` -- -/*!50001 DROP VIEW IF EXISTS `ticketDms`*/; +/*!50001 DROP VIEW IF EXISTS `ticketDms__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -94871,7 +96628,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketDms` AS select `g`.`Id_Ticket` AS `ticketFk`,`g`.`gestdoc_id` AS `dmsFk` from `vn2008`.`tickets_gestdoc` `g` */; +/*!50001 VIEW `ticketDms__` AS select `g`.`Id_Ticket` AS `ticketFk`,`g`.`gestdoc_id` AS `dmsFk` from `vn2008`.`tickets_gestdoc` `g` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94961,7 +96718,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPreviousPreparingList` AS select `t`.`id` AS `ticketFk`,`w`.`code` AS `code`,count(`st`.`id`) AS `saleLines`,sum((`st`.`isChecked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`st`.`isChecked` <> 0)) / count(`st`.`id`)) AS `madeRate`,`st`.`created` AS `created`,`i`.`sectorFk` AS `sectorFk`,`p`.`code` AS `parking` from (((((((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`saleTracking` `st` on((`st`.`saleFk` = `s`.`id`))) join `vn`.`state` on((`vn`.`state`.`id` = `st`.`stateFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) left join `vn`.`ticketParking` `tp` on((`tp`.`ticketFk` = `t`.`id`))) left join `vn`.`parking` `p` on((`p`.`id` = `tp`.`parkingFk`))) where (`vn`.`state`.`code` = 'PREVIOUS_PREPARATION') group by `s`.`ticketFk`,`i`.`sectorFk` */; +/*!50001 VIEW `ticketPreviousPreparingList` AS select `t`.`id` AS `ticketFk`,`w`.`code` AS `code`,count(`st`.`id`) AS `saleLines`,sum((`st`.`isChecked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`st`.`isChecked` <> 0)) / count(`st`.`id`)) AS `madeRate`,`st`.`created` AS `created`,`i`.`sectorFk` AS `sectorFk`,`p`.`code` AS `parking` from (((((((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`saleTracking` `st` on((`st`.`saleFk` = `s`.`id`))) join `vn`.`state` on((`vn`.`state`.`id` = `st`.`stateFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) left join `vn`.`ticketParking` `tp` on((`tp`.`ticketFk` = `t`.`id`))) left join `vn`.`parking` `p` on((`p`.`id` = `tp`.`parkingFk`))) where ((`vn`.`state`.`code` = 'PREVIOUS_PREPARATION') and (`t`.`shipped` >= (curdate() + interval -(1) day))) group by `s`.`ticketFk`,`i`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -95291,10 +97048,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `vehicle` +-- Final view structure for view `vehicle__` -- -/*!50001 DROP VIEW IF EXISTS `vehicle`*/; +/*!50001 DROP VIEW IF EXISTS `vehicle__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -95303,7 +97060,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `vehicle` AS select `v`.`Id_Vehiculo` AS `id`,`v`.`Matricula` AS `numberPlate`,`v`.`Marca` AS `tradeMark`,`v`.`Modelo` AS `model`,`v`.`empresa_id` AS `companyFk`,`v`.`warehouseFk` AS `warehouseFk`,`v`.`description` AS `description`,`v`.`m3` AS `m3`,`v`.`active` AS `isActive` from `vn2008`.`Vehiculos` `v` */; +/*!50001 VIEW `vehicle__` AS select `v`.`Id_Vehiculo` AS `id`,`v`.`Matricula` AS `numberPlate`,`v`.`Marca` AS `tradeMark`,`v`.`Modelo` AS `model`,`v`.`empresa_id` AS `companyFk`,`v`.`warehouseFk` AS `warehouseFk`,`v`.`description` AS `description`,`v`.`m3` AS `m3`,`v`.`active` AS `isActive` from `vn2008`.`Vehiculos` `v` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -95316,12 +97073,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`inventario` AS `isInventory`,`t`.`fuente` AS `isFeedStock`,`t`.`is_comparative` AS `isComparative`,`t`.`comisionantes` AS `hasComission`,`t`.`reserve` AS `hasAvailable`,`t`.`isManaged` AS `isManaged`,`t`.`tpv` AS `isForTicket`,`t`.`hasStowaway` AS `hasStowaway` from `vn2008`.`warehouse` `t` */; +/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`inventario` AS `isInventory`,`t`.`fuente` AS `isFeedStock`,`t`.`is_comparative` AS `isComparative`,`t`.`comisionantes` AS `hasComission`,`t`.`reserve` AS `hasAvailable`,`t`.`isManaged` AS `isManaged`,`t`.`tpv` AS `isForTicket`,`t`.`hasStowaway` AS `hasStowaway`,`t`.`hasDms` AS `hasDms` from `vn2008`.`warehouse` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -95345,10 +97102,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `workCenterHoliday` +-- Final view structure for view `workCenterHoliday__` -- -/*!50001 DROP VIEW IF EXISTS `workCenterHoliday`*/; +/*!50001 DROP VIEW IF EXISTS `workCenterHoliday__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -95357,7 +97114,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workCenterHoliday` AS select `wh`.`workcenter_id` AS `workCenterFk`,`wh`.`day` AS `days`,`wh`.`year` AS `year` from `vn2008`.`workcenter_holiday` `wh` */; +/*!50001 VIEW `workCenterHoliday__` AS select `wh`.`workcenter_id` AS `workCenterFk`,`wh`.`day` AS `days`,`wh`.`year` AS `year` from `vn2008`.`workcenter_holiday` `wh` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -96034,6 +97791,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Recibos` +-- + +/*!50001 DROP VIEW IF EXISTS `Recibos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Recibos` AS select `r`.`Id` AS `Id`,`r`.`invoiceFk` AS `Id_Factura`,`r`.`amountPaid` AS `Entregado`,`r`.`amountUnpaid` AS `Pendiente`,`r`.`payed` AS `Fechacobro`,`r`.`workerFk` AS `Id_Trabajador`,`r`.`bankFk` AS `Id_Banco`,`r`.`clientFk` AS `Id_Cliente`,`r`.`created` AS `odbc_date`,`r`.`companyFk` AS `empresa_id`,`r`.`isConciliate` AS `conciliado` from `vn`.`receipt` `r` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `Rutas` -- @@ -96142,6 +97917,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Vehiculos` +-- + +/*!50001 DROP VIEW IF EXISTS `Vehiculos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Vehiculos` AS select `v`.`id` AS `Id_Vehiculo`,`v`.`numberPlate` AS `Matricula`,`v`.`tradeMark` AS `Marca`,`v`.`model` AS `Modelo`,`v`.`companyFk` AS `empresa_id`,`v`.`warehouseFk` AS `warehouseFk`,`v`.`description` AS `description`,`v`.`m3` AS `m3`,`v`.`isActive` AS `active` from `vn`.`vehicle` `v` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `VerEspionaje` -- @@ -96898,6 +98691,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `escritos` +-- + +/*!50001 DROP VIEW IF EXISTS `escritos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `escritos` AS select `s`.`id` AS `id`,`s`.`code` AS `abrev`,`s`.`description` AS `descripcion`,`s`.`isVisible` AS `visible`,`s`.`hasCompany` AS `hasCompany` from `vn`.`sample` `s` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `escritos_det` -- @@ -96934,6 +98745,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `gestdoc` +-- + +/*!50001 DROP VIEW IF EXISTS `gestdoc`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `gestdoc` AS select `d`.`id` AS `id`,`d`.`dmsTypeFk` AS `gesttip_id`,`d`.`file` AS `file`,`d`.`contentType` AS `contentType`,`d`.`workerFk` AS `trabajador_id`,`d`.`warehouseFk` AS `warehouse_id`,`d`.`companyFk` AS `emp_id`,`d`.`hardCopyNumber` AS `orden`,`d`.`hasFile` AS `original`,`d`.`reference` AS `sref`,`d`.`description` AS `brief`,`d`.`created` AS `odbc_date` from `vn`.`dms` `d` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `gesttip` -- @@ -97546,6 +99375,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `tickets_gestdoc` +-- + +/*!50001 DROP VIEW IF EXISTS `tickets_gestdoc`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `tickets_gestdoc` AS select `td`.`ticketFk` AS `Id_Ticket`,`td`.`dmsFk` AS `gestdoc_id` from `vn`.`ticketDms` `td` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `travel` -- @@ -98243,7 +100090,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_xsubclien` AS select distinct `Facturas`.`Id_Cliente` AS `Id_Cliente`,`Facturas`.`empresa_id` AS `empresa_id` from `vn2008`.`Facturas` where (`Facturas`.`Fecha` > (curdate() + interval -(2) month)) union select `vn2008`.`Recibos`.`Id_Cliente` AS `Id_Cliente`,`vn2008`.`Recibos`.`empresa_id` AS `empresa_id` from `vn2008`.`Recibos` where (`vn2008`.`Recibos`.`Fechacobro` > (curdate() + interval -(2) month)) */; +/*!50001 VIEW `v_xsubclien` AS select distinct `Facturas`.`Id_Cliente` AS `Id_Cliente`,`Facturas`.`empresa_id` AS `empresa_id` from `vn2008`.`Facturas` where (`Facturas`.`Fecha` > (curdate() + interval -(2) month)) union select `Recibos`.`Id_Cliente` AS `Id_Cliente`,`Recibos`.`empresa_id` AS `empresa_id` from `vn2008`.`Recibos` where (`Recibos`.`Fechacobro` > (curdate() + interval -(2) month)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -98338,6 +100185,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `workcenter_holiday` +-- + +/*!50001 DROP VIEW IF EXISTS `workcenter_holiday`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `workcenter_holiday` AS select `wh`.`workCenterFk` AS `workcenter_id`,`wh`.`days` AS `day`,`wh`.`year` AS `year` from `vn`.`workCenterHoliday` `wh` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `workerDocument` -- @@ -98407,4 +100272,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-10-14 10:37:03 +-- Dump completed on 2019-10-29 8:18:50 diff --git a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js index a00d6387d..f170b87b0 100644 --- a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js +++ b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js @@ -3,7 +3,6 @@ import createNightmare from '../../helpers/nightmare'; describe('InvoiceOut descriptor path', () => { const nightmare = createNightmare(); - let bookedDate; describe('as Administrative', () => { beforeAll(() => { @@ -123,10 +122,9 @@ describe('InvoiceOut descriptor path', () => { it(`should check the invoiceOut is booked in the summary data`, async() => { const result = await nightmare + .waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/') .waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); - bookedDate = result; - expect(result.length).toBeGreaterThan(1); }); @@ -141,10 +139,13 @@ describe('InvoiceOut descriptor path', () => { }); it(`should check the invoiceOut booked in the summary data`, async() => { + let today = new Date(); + let expectedDate = `${today.getDate()}/${(today.getMonth() + 1)}/${today.getFullYear()}`; + const result = await nightmare .waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); - expect(result).not.toEqual(bookedDate); + expect(result).toEqual(expectedDate); }); });