merge from test to dev - no structure

This commit is contained in:
Joan Sanchez 2019-06-07 13:06:54 +02:00
commit 4545d1f649
72 changed files with 5397 additions and 549 deletions

View File

@ -0,0 +1,15 @@
CREATE TABLE `vn`.`device` (
`id` INT NOT NULL,
`sn` VARCHAR(50) NULL,
`model` VARCHAR(50) NULL,
`userFk` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
INDEX `device_fk1_idx` (`userFk` ASC),
CONSTRAINT `device_fk1`
FOREIGN KEY (`userFk`)
REFERENCES `account`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
ALTER TABLE `vn`.`device`
CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ;

View File

@ -0,0 +1,74 @@
USE `nst`;
DROP procedure IF EXISTS `nodeAdd`;
DELIMITER $$
USE `nst`$$
CREATE DEFINER=`root`@`%` PROCEDURE `nodeAdd`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100))
BEGIN
DECLARE vSql TEXT;
DECLARE vTableClone VARCHAR(45);
SET vTableClone = CONCAT(vTable, 'Clone');
CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone));
CALL util.exec(CONCAT(
'CREATE TEMPORARY TABLE tmp.', vTableClone,
' ENGINE = MEMORY',
' SELECT * FROM ', vScheme, '.', vTable
));
CALL util.exec(CONCAT(
'SELECT COUNT(c.id) INTO @childs',
' FROM ', vScheme, '.', vTable, ' p',
' LEFT JOIN tmp.', vTableClone, ' c ON c.lft',
' BETWEEN p.lft AND p.rgt AND c.id != ', vParentFk,
' WHERE p.id = ', vParentFk
));
IF @childs = 0 THEN
CALL util.exec(CONCAT(
'SELECT lft INTO @vLeft',
' FROM ', vScheme, '.', vTable,
' WHERE id = ', vParentFk
));
ELSE
CALL util.exec(CONCAT(
'SELECT c.rgt INTO @vLeft',
' FROM ', vScheme, '.', vTable, ' p',
' JOIN tmp.', vTableClone, ' c ON c.depth = p.depth + 1'
' AND c.lft BETWEEN p.lft AND p.rgt',
' WHERE p.id = ', vParentFk,
' ORDER BY c.lft',
' DESC LIMIT 1'
));
END IF;
CALL util.exec(CONCAT(
'UPDATE ', vScheme, '.', vTable, ' SET rgt = rgt + 2',
' WHERE rgt > @vLeft',
' ORDER BY rgt DESC'
));
CALL util.exec(CONCAT(
'UPDATE ', vScheme, '.', vTable, ' SET lft = lft + 2',
' WHERE lft > @vLeft',
' ORDER BY lft DESC'
));
SET vChild = REPLACE(vChild, "'", "\\'");
CALL util.exec(CONCAT(
'INSERT INTO ', vScheme, '.', vTable, ' (name, lft, rgt)',
' VALUES ("', vChild, '", @vLeft + 1, @vLeft + 2)'
));
-- CALL util.exec(CONCAT(
-- 'SELECT id, name, lft, rgt, depth, sons',
-- ' FROM ', vScheme, '.', vTable,
-- ' WHERE id = LAST_INSERT_ID()'
-- ));
CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone));
END$$
DELIMITER ;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
DROP procedure IF EXISTS `vn`.`zoneNest`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNest`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGeo;
CREATE TEMPORARY TABLE tmp.zoneGeo
(id INT AUTO_INCREMENT PRIMARY KEY)
ENGINE = MEMORY
SELECT * FROM vn.zoneGeo;
DROP TEMPORARY TABLE IF EXISTS tmp.country;
CREATE TEMPORARY TABLE tmp.country
SELECT id FROM country
WHERE country IN('España exento');
CALL vn.zoneNestCountry();
CALL vn.zoneNestProvince();
CALL vn.zoneNestTown();
CALL vn.zoneNestPostcode();
CALL vn.nestTree('tmp', 'zoneGeo', 'vn', 'zoneGeo');
DROP TEMPORARY TABLE
tmp.zoneGeo,
tmp.country;
END$$
DELIMITER ;

View File

@ -0,0 +1,55 @@
DROP procedure IF EXISTS `vn`.`zoneNestCountry`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestCountry`()
BEGIN
DECLARE vDone BOOL;
DECLARE vParent INT DEFAULT 1;
DECLARE vGeoFk INT;
DECLARE vChildFk INT;
DECLARE vChildName VARCHAR(100);
DECLARE countryCur CURSOR FOR
SELECT 1, c.id, c.`country`
FROM vn.country c
JOIN tmp.country tc ON tc.id = c.id
ORDER BY c.`country`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Remove existing countries
DELETE zg FROM vn.country c
JOIN tmp.country tc ON tc.id = c.id
JOIN tmp.zoneGeo zg ON zg.id = c.geoFk;
-- Reset country geoFk
UPDATE vn.country c
JOIN tmp.country tc ON tc.id = c.id
SET c.geoFk = NULL
WHERE c.geoFk IS NOT NULL;
-- > Country cursor start
OPEN countryCur;
countryLoop: LOOP
SET vDone = FALSE;
FETCH countryCur INTO vParent, vChildFk, vChildName;
IF vDone THEN
LEAVE countryLoop;
END IF;
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
END LOOP;
CLOSE countryCur;
-- < Country cursor end
UPDATE country c
JOIN tmp.zoneGeo z ON z.name = c.country
SET c.geoFk = z.id
WHERE c.geoFk IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,61 @@
DROP procedure IF EXISTS `vn`.`zoneNestPostcode`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestPostcode`()
BEGIN
DECLARE vDone BOOL;
DECLARE vParent INT DEFAULT 1;
DECLARE vGeoFk INT;
DECLARE vChildFk INT;
DECLARE vChildName VARCHAR(100);
DECLARE postcodeCur CURSOR FOR
SELECT t.geoFk, pc.`code`, pc.`code`
FROM vn.postCode pc
JOIN vn.town t ON t.id = pc.townFk
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
ORDER BY t.geoFk, pc.`code`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Remove existing postCodes from zoneGeo
DELETE zg FROM vn.postCode pc
JOIN vn.town t ON t.id = pc.townFk
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
JOIN tmp.zoneGeo zg ON zg.id = pc.geoFk;
-- Reset town geoFk
UPDATE vn.postCode pc
JOIN vn.town t ON t.id = pc.townFk
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
SET pc.geoFk = NULL
WHERE pc.geoFk IS NOT NULL;
-- > Postcode cursor start
OPEN postcodeCur;
postcodeLoop: LOOP
SET vDone = FALSE;
FETCH postcodeCur INTO vParent, vChildFk, vChildName;
IF vDone THEN
LEAVE postcodeLoop;
END IF;
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
END LOOP;
CLOSE postcodeCur;
-- < Postcode cursor end
UPDATE postCode p
JOIN tmp.zoneGeo z ON z.name = p.code
SET p.geoFk = z.id
WHERE p.geoFk IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,56 @@
DROP procedure IF EXISTS `vn`.`zoneNestProvince`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestProvince`()
BEGIN
DECLARE vDone BOOL;
DECLARE vParent INT DEFAULT 1;
DECLARE vGeoFk INT;
DECLARE vChildFk INT;
DECLARE vChildName VARCHAR(100);
DECLARE provinceCur CURSOR FOR
SELECT c.geoFk, p.id, p.`name`
FROM province p
JOIN tmp.country tc ON tc.id = p.countryFk
JOIN vn.country c ON c.id = tc.id
ORDER BY c.geoFk, p.`name`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Remove existing provinces from zoneGeo
DELETE zg FROM vn.province p
JOIN tmp.country tc ON tc.id = p.countryFk
JOIN tmp.zoneGeo zg ON zg.id = p.geoFk;
-- Reset country geoFk
UPDATE vn.province p
JOIN tmp.country tc ON tc.id = p.countryFk
SET p.geoFk = NULL
WHERE p.geoFk IS NOT NULL;
-- > Province cursor start
OPEN provinceCur;
provinceLoop: LOOP
SET vDone = FALSE;
FETCH provinceCur INTO vParent, vChildFk, vChildName;
IF vDone THEN
LEAVE provinceLoop;
END IF;
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
END LOOP;
CLOSE provinceCur;
-- < Province cursor end
UPDATE province p
JOIN tmp.zoneGeo z ON z.name = p.name
SET p.geoFk = z.id
WHERE p.geoFk IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,59 @@
DROP procedure IF EXISTS `vn`.`zoneNestTown`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestTown`()
BEGIN
DECLARE vDone BOOL;
DECLARE vParent INT DEFAULT 1;
DECLARE vGeoFk INT;
DECLARE vChildFk INT;
DECLARE vChildName VARCHAR(100);
DECLARE townCur CURSOR FOR
SELECT p.geoFk, t.id, t.`name`
FROM vn.town t
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
ORDER BY p.geoFk, t.`name`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Remove existing towns from zoneGeo
DELETE zg FROM vn.town t
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
JOIN tmp.zoneGeo zg ON zg.id = t.geoFk;
-- Reset town geoFk
UPDATE vn.town t
JOIN vn.province p ON p.id = t.provinceFk
JOIN tmp.country tc ON tc.id = p.countryFk
SET t.geoFk = NULL
WHERE t.geoFk IS NOT NULL;
-- > Town cursor start
OPEN townCur;
townLoop: LOOP
SET vDone = FALSE;
FETCH townCur INTO vParent, vChildFk, vChildName;
IF vDone THEN
LEAVE townLoop;
END IF;
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
END LOOP;
CLOSE townCur;
-- < Town cursor end
UPDATE town t
JOIN tmp.zoneGeo z ON z.name = t.name
LEFT JOIN province p ON p.geoFk = z.id
SET t.geoFk = z.id
WHERE p.geoFk IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,19 @@
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`ticketGetVolume` AS
SELECT
`s`.`ticketFk` AS `ticketFk`,
`t`.`routeFk` AS `routeFk`,
`s`.`id` AS `saleFk`,
`t`.`shipped` AS `Fecha`,
(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`
FROM
(((`vn`.`sale` `s`
JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`)
AND (`r`.`warehouse_id` = `t`.`warehouseFk`))));

View File

@ -0,0 +1,30 @@
DROP function IF EXISTS `vn`.`ticketTotalVolume`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3)
READS SQL DATA
BEGIN
-- Devuelte el volumen total del ticket sumado
-- DECLARE vWarehouseId INTEGER;
-- DECLARE vShippedDate DATE;
DECLARE vVolume DECIMAL(10,3);
/*
SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId;
SELECT IFNULL(SUM(s.quantity * i.compression * r.cm3)/1000000,0) INTO vVolume
FROM sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN bi.rotacion r on r.Id_Article = s.itemFk AND r.warehouse_id = vWarehouseId
WHERE s.ticketFk = vTicketId;
*/
SELECT sum(volume) INTO vVolume
FROM ticketGetVolume
WHERE ticketFk = vTicketId;
RETURN vVolume;
END$$
DELIMITER ;

View File

@ -0,0 +1,61 @@
DROP procedure IF EXISTS `vn`.`available_calc`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`available_calc`(
vDate DATE,
vAddress INT,
vAgencyMode INT)
BEGIN
/**
* Calculates the available for all available stores
* according to the given parameters.
*
* @param vDate The delivery date
* @param vAddress The delivery address id
* @param vAgencyMode The shipping agency
* @return tmp.availableCalc(calcFk) The available cache ids
*/
DECLARE vCalcFk INT;
DECLARE vShipment DATE;
DECLARE vWarehouse INT;
DECLARE vDone BOOL;
DECLARE cWarehouses CURSOR FOR
SELECT warehouseFk, shipped FROM tmp.zoneGetShipped;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
-- Establecemos los almacenes y las fechas que van a entrar al disponible
CALL vn.zoneGetShippedWarehouse(vDate, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc;
CREATE TEMPORARY TABLE tmp.availableCalc(
calcFk INT UNSIGNED,
PRIMARY KEY (calcFk)
)
ENGINE = MEMORY;
OPEN cWarehouses;
l: LOOP
SET vDone = FALSE;
FETCH cWarehouses INTO vWarehouse, vShipment;
IF vDone THEN
LEAVE l;
END IF;
CALL `cache`.available_refresh(vCalcFk, FALSE, vWarehouse, vShipment);
INSERT IGNORE INTO tmp.availableCalc
SET calcFk = vCalcFk;
END LOOP;
CLOSE cWarehouses;
DROP TEMPORARY TABLE tmp.zoneGetShipped;
END$$
DELIMITER ;

View File

@ -0,0 +1,28 @@
DROP procedure IF EXISTS `vn`.`catalog_calcFromItem`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_calcFromItem`(
vLanded DATE,
vAddressFk INT,
vAgencyModeFk INT,
vItemFk INT)
BEGIN
/**
* Calculates available and price for a single item.
*
* @param vItemFk The item id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
ENGINE = MEMORY
SELECT vItemFk itemFk;
CALL ticketCalculate(vLanded, vAddressFk, vAgencyModeFk);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -0,0 +1,41 @@
DROP procedure IF EXISTS `hedera`.`catalog_calcFromMyAddress`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
*
* @param vDelivery Delivery date
* @param vAddress Address id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk
INTO vAgencyMode
FROM myClient c
JOIN vn.address a ON a.clientFk = c.id
WHERE a.id = vAddress;
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM `cache`.available c
JOIN tmp.availableCalc a ON a.calcFk = c.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -0,0 +1,398 @@
USE `vn2008`;
DROP procedure IF EXISTS `vn2008`.`bionic_available_`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_available_`(
vDate DATE,
vAddress INT,
vAgency INT)
BEGIN
/**
* Calcula el disponible para un conjunto de almacenes y fechas
* devueltos por el procedimiento agencyHourGetShipped()
*
* @deprecated Use vn.available_calc()
* @table t_bionic_available Tabla con los ids de cache
*/
DECLARE vAvailableCalc INT;
DECLARE vShipment DATE;
DECLARE vAgencyId INT;
DECLARE vWh INT;
DECLARE vDone BOOL;
DECLARE cTravelTree CURSOR FOR
SELECT warehouseFk, shipped FROM tmp.agencyHourGetShipped;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Establecemos los almacenes y las fechas que van a entrar al disponible
SELECT agency_id INTO vAgencyId
FROM Agencias WHERE Id_Agencia = vAgency;
CALL vn.agencyHourGetShipped (vDate, vAddress, vAgencyId);
DROP TEMPORARY TABLE IF EXISTS t_bionic_available;
CREATE TEMPORARY TABLE t_bionic_available(
calc_id INT UNSIGNED,
PRIMARY KEY (calc_id)
)
ENGINE = MEMORY;
OPEN cTravelTree;
l: LOOP
SET vDone = FALSE;
FETCH cTravelTree INTO vWh, vShipment;
IF vDone THEN
LEAVE l;
END IF;
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWh, vShipment);
INSERT IGNORE INTO t_bionic_available
SET calc_id = vAvailableCalc;
END LOOP;
CLOSE cTravelTree;
DROP TEMPORARY TABLE tmp.agencyHourGetShipped;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionic_from_item`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_item`(vItem INT)
BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT sent, addressFk, agencyModeFk
INTO vDate, vAddress, vAgencyMode
FROM myBasket;
CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
END$$
DELIMITER ;
;
USE `vn2008`;
DROP procedure IF EXISTS `vn2008`.`bionic_from_order`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_order`(
v_date DATE, -- fecha de recepcion de mercancia
v_consigna INT,
v_agencia INT,
v_order INT)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.bionic_calc;
CREATE TEMPORARY TABLE tmp.bionic_calc
(PRIMARY KEY (item_id))
ENGINE = MEMORY
SELECT item_id FROM order_row
WHERE order_id = v_order GROUP BY item_id;
CALL bionic_calc (v_date, v_consigna, v_agencia);
DROP TEMPORARY TABLE tmp.bionic_calc;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionicCalcWithDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionicCalcWithDate`(vDate DATE)
BEGIN
DECLARE vMyAddressFk INTEGER;
DECLARE vMyAgencyModeFk INTEGER;
SELECT id, agencyModeFk INTO vMyAddressFk, vMyAgencyModeFk
FROM myAddress
WHERE isDefaultAddress;
CALL vn2008.bionic_calc(vDate, vMyAddressFk, vMyAgencyModeFk);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionic_calc`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_calc`()
BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT sent, addressFk, agencyModeFk
INTO vDate, vAddress, vAgencyMode
FROM myBasket;
CALL vn2008.bionic_calc(vDate, vAddress, vAgencyMode);
IF account.myUserGetName() = 'visitor'
THEN
DROP TEMPORARY TABLE tmp.bionic_component;
UPDATE tmp.bionic_item SET price = NULL;
END IF;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`itemGetAvailableOrder`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailableOrder`(vOrder INT)
BEGIN
/**
* Gets the available items list with an order params.
*
* @table tmp.itemAvailable
*/
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vAgency INT;
SELECT landed, addressFk, agencyModeFk
INTO vDelivery, vAddress, vAgency
FROM myOrder
WHERE id = vOrder;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
CREATE TEMPORARY TABLE tmp.itemAvailable
(INDEX (id))
ENGINE = MEMORY
SELECT c.item_id id
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`itemGetAvailable`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailable`()
BEGIN
/**
* Gets the available items list.
*
* @table tmp.itemAvailable
*/
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vAgency INT;
SELECT sent, addressFk, agencyModeFk
INTO vDelivery, vAddress, vAgency
FROM myBasket;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
CREATE TEMPORARY TABLE tmp.itemAvailable
(INDEX (id))
ENGINE = MEMORY
SELECT c.item_id id
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myItemGetAvailableFromDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailableFromDate`(vDelivery DATE)
BEGIN
/**
* Gets the available items list.
*
* @deprecated Use item_calcCatalogFromMyAddress()
* @param vDelivery Delivery date
*/
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk, a.id
INTO vAgencyMode, vAddress
FROM myClient c
JOIN vn.address a ON a.id = c.defaultAddressFk;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
-- -------------------
/*SELECT b.itemFk, b.item, b.available, b.price
FROM tmp.ticketCalculateItem b
JOIN vn.item i ON i.id = b.itemFk
WHERE b.available > 0
ORDER BY i.relevancy DESC, i.name, i.size;
select * from tmp.ticketComponentPrice;*/
-- -------------------
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myItemGetAvailable`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailable`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
*
* @deprecated Use item_calcCatalogFromMyAddress()
* @param vDelivery Delivery date
* @param vAddress Id Address
*/
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk
INTO vAgencyMode
FROM myClient c
JOIN vn.address a ON a.clientFk = c.id
WHERE a.id = vAddress;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
-- -------------------
/*SELECT b.itemFk, b.item, b.available, b.price
FROM tmp.ticketCalculateItem b
JOIN vn.item i ON i.id = b.itemFk
WHERE b.available > 0
ORDER BY i.relevancy DESC, i.name, i.size;
select * from tmp.ticketComponentPrice;*/
-- -------------------
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderAddItem`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderAddItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
vAmount INT)
BEGIN
/**
* @deprecated Use myOrder_addItem()
*/
CALL myOrder_addItem(vSelf, vWarehouse, vItem, vAmount);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderConfirm`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderConfirm`(vSelf INT)
BEGIN
/**
* @deprecated Use myOrder_confirm()
*/
CALL myOrder_confirm(vSelf);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderNewFromDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderNewFromDate`(
OUT vSelf INT,
vLandingDate DATE)
BEGIN
/**
* @deprecated Use myOrder_newWithDate()
*/
CALL myOrder_newWithDate(vSelf, vLandingDate);
END$$
DELIMITER ;
;

View File

@ -0,0 +1,19 @@
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFromItem`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFromItem`(vItem INT)
BEGIN
/**
* Gets the availability and prices for the given item
* using current user basket parameters.
*
* @table tmp.item(itemFk)
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
CALL order_calcCatalogFromItem(myBasket_getId(), vItem);
END$$
DELIMITER ;

View File

@ -0,0 +1,19 @@
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFull`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFull`()
BEGIN
/**
* Gets the availability and prices for the given items
* using current user basket parameters.
*
* @table tmp.item(itemFk)
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
CALL order_calcCatalogFull(myBasket_getId());
END$$
DELIMITER ;

View File

@ -0,0 +1,14 @@
DROP procedure IF EXISTS `hedera`.`myBasket_getAvailable`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_getAvailable`()
BEGIN
/**
* Gets the available items list.
*
* @table tmp.itemAvailable
*/
CALL order_getAvailable(myBasket_getId());
END$$
DELIMITER ;

View File

@ -0,0 +1,22 @@
DROP procedure IF EXISTS `hedera`.`myOrder_getAvailable`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myOrder_getAvailable`(vSelf INT)
BEGIN
/**
* Gets the available items list.
*
* @param vSelf The order id
* @table tmp.itemAvailable
*/
DECLARE isMine BOOL;
SELECT COUNT(*) INTO isMine
FROM myOrder
WHERE id = vSelf;
IF isMine THEN
CALL order_getAvailable(vSelf);
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,105 @@
DROP procedure IF EXISTS `hedera`.`order_addItem`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_addItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
vAmount INT)
BEGIN
/**
* Adds an item to the order, checking availability and grouping.
*
* @param vSelf The order id
* @param vWarehouse The warehouse id
* @param vItem The item id
* @param vAmount The amount to add
*/
DECLARE vRow INT;
DECLARE vAdd INT;
DECLARE vAvailable INT;
DECLARE vDone BOOL;
DECLARE vGrouping INT;
DECLARE vRate INT;
DECLARE vShipment DATE;
DECLARE vPrice DECIMAL(10,2);
DECLARE cur CURSOR FOR
SELECT `grouping`, price, rate
FROM tmp.ticketComponentPrice
WHERE warehouseFk = vWarehouse
AND itemFk = vItem
ORDER BY `grouping` DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
CALL order_calcCatalogFromItem(vSelf, vItem);
START TRANSACTION;
SELECT shipped INTO vShipment
FROM tmp.zoneGetShipped
WHERE warehouseFk = vWarehouse;
SELECT available INTO vAvailable
FROM tmp.ticketLot
WHERE warehouseFk = vWarehouse
AND itemFk = vItem;
IF vAmount > IFNULL(vAvailable, 0) THEN
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
END IF;
OPEN cur;
l: LOOP
SET vDone = FALSE;
FETCH cur INTO vGrouping, vPrice, vRate;
IF vDone THEN
LEAVE l;
END IF;
SET vAdd = vAmount - MOD(vAmount, vGrouping);
SET vAmount = vAmount - vAdd;
IF vAdd = 0 THEN
ITERATE l;
END IF;
INSERT INTO orderRow SET
orderFk = vSelf,
itemFk = vItem,
warehouseFk = vWarehouse,
shipment = vShipment,
rate = vRate,
amount = vAdd,
price = vPrice;
SET vRow = LAST_INSERT_ID();
INSERT INTO orderRowComponent (rowFk, componentFk, price)
SELECT vRow, c.componentFk, c.cost
FROM tmp.ticketComponent c
JOIN vn.component t
ON t.id = c.componentFk
AND (t.classRate IS NULL OR t.classRate = vRate)
WHERE c.warehouseFk = vWarehouse
AND c.itemFk = vItem;
END LOOP;
CLOSE cur;
IF vAmount > 0 THEN
CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING');
END IF;
COMMIT;
CALL vn.ticketCalculatePurge;
END$$
DELIMITER ;

View File

@ -0,0 +1,36 @@
DROP procedure IF EXISTS `hedera`.`order_calcCatalog`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for order items.
*
* @param vSelf The order id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
*/
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
FROM `order`
WHERE id = vSelf;
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk FROM orderRow
WHERE orderFk = vSelf
GROUP BY itemFk;
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -0,0 +1,30 @@
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFromItem`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFromItem`(vSelf INT, vItem INT)
BEGIN
/**
* Gets the availability and prices for the given item
* using the order parameters.
*
* @param vSelf The order id
* @table tmp.item(itemFk)
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
FROM `order`
WHERE id = vSelf;
CALL vn.catalog_calcFromItem(vDate, vAddress, vAgencyMode, vItem);
END$$
DELIMITER ;

View File

@ -0,0 +1,35 @@
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFull`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for the given items
* using the order parameters.
*
* @param vSelf The order id
* @table tmp.item(itemFk)
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
FROM `order`
WHERE id = vSelf;
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
IF account.myUserGetName() = 'visitor'
THEN
DROP TEMPORARY TABLE tmp.ticketComponent;
UPDATE tmp.ticketCalculateItem SET price = NULL;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,34 @@
DROP procedure IF EXISTS `hedera`.`order_getAvailable`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_getAvailable`(vSelf INT)
BEGIN
/**
* Gets the available items list.
*
* @param vSelf The order id
* @table tmp.itemAvailable
*/
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT date_send, address_id, agency_id
INTO vDelivery, vAddress, vAgencyMode
FROM `order`
WHERE id = vSelf;
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
CREATE TEMPORARY TABLE tmp.itemAvailable
(INDEX (id))
ENGINE = MEMORY
SELECT DISTINCT a.item_id id
FROM `cache`.available a
JOIN tmp.availableCalc c ON c.calcFk = a.calc_id
WHERE a.available > 0;
DROP TEMPORARY TABLE tmp.availableCalc;
END$$
DELIMITER ;

View File

@ -0,0 +1,71 @@
DROP procedure IF EXISTS `hedera`.`order_update`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_update`(vSelf INT)
proc: BEGIN
/**
* Actualiza las líneas de un pedido.
*
* @param vSelf Id del pedido
*/
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
DECLARE vNRows INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
SELECT COUNT(*) INTO vNRows
FROM orderRow WHERE orderFk = vSelf;
IF vNRows > 0
THEN
CALL order_calcCatalog(vSelf);
DELETE c
FROM orderRow r
JOIN orderRowComponent c ON c.rowFk = r.id
WHERE r.orderFk = vSelf;
UPDATE orderRow r
LEFT JOIN tmp.ticketComponentPrice p
ON p.warehouseFk = r.warehouseFk
AND p.itemFk = r.itemFk
AND p.rate = r.rate
LEFT JOIN tmp.zoneGetShipped t
ON t.warehouseFk = r.warehouseFk
SET
r.price = p.price,
r.amount = IF(p.itemFk IS NOT NULL,
r.amount + IF(@m := MOD(r.amount, p.`grouping`), p.`grouping` - @m, 0), 0),
r.shipment = t.shipped
WHERE r.orderFk = vSelf;
INSERT INTO orderRowComponent(rowFk, componentFk, price)
SELECT r.id, c.componentFk, c.cost
FROM orderRow r
JOIN tmp.ticketComponent c
ON c.warehouseFk = r.warehouseFk
AND c.itemFk = r.itemFk
JOIN vn.component t
ON t.id = c.componentFk
AND (t.classRate IS NULL OR t.classRate = r.rate)
WHERE r.orderFk = vSelf;
CALL vn.ticketCalculatePurge;
END IF;
UPDATE `order` SET date_make = NOW()
WHERE id = vSelf;
COMMIT;
END$$
DELIMITER ;

View File

@ -0,0 +1 @@
RENAME TABLE hedera.myOrderMyTicket TO hedera.myOrderTicket;

View File

@ -0,0 +1,10 @@
GRANT EXECUTE ON PROCEDURE vn.zoneGetAgency TO `account`@`%`;
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFromItem TO `guest`@`%`;
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFull TO `guest`@`%`;
GRANT EXECUTE ON PROCEDURE hedera.myBasket_getAvailable TO `guest`@`%`;
GRANT EXECUTE ON PROCEDURE hedera.myOrder_getAvailable TO `guest`@`%`;
GRANT EXECUTE ON PROCEDURE hedera.catalog_calcFromMyAddress TO account@'%';
REVOKE SELECT ON TABLE hedera.myOrderMyTicket FROM account@'%';
GRANT SELECT ON TABLE hedera.myOrderTicket TO account@'%';
CALL account.privSync;

View File

@ -0,0 +1,5 @@
ALTER TABLE `vn`.`zone`
DROP PRIMARY KEY,
ADD PRIMARY KEY (`id`),
ADD INDEX `zone_name_idx` (`name` ASC);

File diff suppressed because one or more lines are too long

View File

@ -146,33 +146,6 @@ INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `warehouseFk`, `zoneFk`)
(4, 'Province four', 1, NULL, 2),
(5, 'Province five', 1, NULL, 1);
INSERT INTO `vn`.`agencyHour`(`id`, `agencyFk`, `weekDay`, `warehouseFk`, `provinceFk`, `maxHour`)
VALUES
(1 , 1, 0, 1, 1, 22),
(2 , 1, 1, 1, 1, 22),
(3 , 1, 2, 1, 1, 22),
(4 , 1, 3, 1, 1, 22),
(5 , 1, 4, 1, 1, 22),
(6 , 2, 0, 1, 1, 22),
(7 , 2, 1, 1, 1, 22),
(8 , 2, 2, 1, 1, 22),
(9 , 2, 3, 1, 1, 22),
(10, 2, 4, 1, 1, 22),
(11, 7, 0, 1, 1, 22),
(12, 7, 1, 1, 1, 22),
(13, 7, 2, 1, 1, 22),
(14, 7, 3, 1, 1, 22),
(15, 7, 4, 1, 1, 22),
(16, 7, 5, 1, 1, 22),
(17, 7, 6, 1, 1, 22),
(18, 8, 0, 1, 1, 22),
(19, 8, 1, 1, 1, 22),
(20, 8, 2, 1, 1, 22),
(21, 8, 3, 1, 1, 22),
(22, 8, 4, 1, 1, 22),
(23, 8, 5, 1, 1, 22),
(24, 8, 6, 1, 1, 22);
INSERT INTO `vn`.`clientType`(`id`, `code`, `type`)
VALUES
(1, 'normal', 'Normal'),
@ -235,8 +208,8 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 1),
(9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 1),
(10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 1),
(11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 1),
(12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 1),
(11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 1),
(12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 1),
(101, 'address 01', 'Somewhere in Thailand', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0),
(102, 'address 02', 'Somewhere in Poland', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0),
(103, 'address 03', 'Somewhere in Japan', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0),
@ -267,8 +240,8 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(128, 'address 28', 'Cerebro', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 0),
(129, 'address 29', 'Luke Cages Bar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 0),
(130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0, 0),
(131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 0),
(132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 0);
(131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 0),
(132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 0);
INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`)
SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1
@ -288,10 +261,16 @@ UPDATE `vn`.`client` SET defaultAddressFk = 10 WHERE id = 110;
UPDATE `vn`.`client` SET defaultAddressFk = 11 WHERE id = 200;
UPDATE `vn`.`client` SET defaultAddressFk = 12 WHERE id = 400;
CREATE TEMPORARY TABLE `tmp`.`clientAddress`
select `c`.`id` `clientFk`,`c`.`name`,`a`.`id` `addressFk` FROM `vn`.`client` `c`
JOIN `vn`.`address` `a` ON `a`.`clientFk` = `c`.`id`
WHERE `defaultAddressFk` IS NULL;
DROP TEMPORARY TABLE IF EXISTS tmp.address;
CREATE TEMPORARY TABLE tmp.address
SELECT * FROM `vn`.`address`;
UPDATE `vn`.`client` `c`
JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id`
SET `c`.`defaultAddressFk` = `a`.`id`
WHERE `defaultAddressFk` IS NULL;
DROP TEMPORARY TABLE tmp.address;
UPDATE `vn`.`client` `c`
JOIN `tmp`.`clientAddress` `a` ON `a`.`clientFk` = `c`.`id`
@ -435,28 +414,28 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF
INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `created`)
VALUES
(1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL -15 DAY), 101, 'address 21', 121, 'T1111111', 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(2, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -10 DAY), 101, 'address 21', 121, 'T2222222', 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
(3, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL -5 DAY), 102, 'address 22', 122, 'T2222222', 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)),
(4, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL -4 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY), 102, 'address 22', 122, 'T3333333', 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY)),
(5, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -3 DAY), DATE_ADD(CURDATE(), INTERVAL -3 DAY), 103, 'address 23', 123, 'T3333333', 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)),
(6, 3, 3, 4, DATE_ADD(CURDATE(), INTERVAL -2 DAY), DATE_ADD(CURDATE(), INTERVAL -2 DAY), 103, 'address 23', 123, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)),
(7, 4, 4, 4, DATE_ADD(CURDATE(), INTERVAL -1 DAY), DATE_ADD(CURDATE(), INTERVAL -1 DAY), 104, 'address 24', 124, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)),
(8, 1, 1, 4, CURDATE(), CURDATE(), 104, 'address 24', 124, NULL, 0, CURDATE()),
(9, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
(10, 6, 5, 5, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
(11, 7, 1, 1, CURDATE() , CURDATE() , 101, 'address 21', 121, NULL, 0, CURDATE()),
(12, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
(13, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +2 MONTH)),
(14, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +3 MONTH)),
(15, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +4 MONTH)),
(16, 1, 1, 1, CURDATE(), CURDATE(), 101, 'address 21', 121, NULL, 0, CURDATE()),
(17, 4, 4, 4, CURDATE(), CURDATE(), 106, 'address 26', 126, NULL, 0, CURDATE()),
(18, 4, 4, 4, CURDATE(), CURDATE(), 107, 'address 27', 127, NULL, 0, CURDATE()),
(19, 5, 5, 4, DATE_ADD(DATE_ADD(CURDATE(), INTERVAL +1 DAY),INTERVAL +2 HOUR), DATE_ADD(DATE_ADD(CURDATE(), INTERVAL +1 DAY),INTERVAL +2 HOUR), 108, 'address 28', 128, NULL, 0, DATE_ADD(DATE_ADD(CURDATE(), INTERVAL +1 DAY),INTERVAL +2 HOUR)),
(20, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), 108, 'address 28', 128, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(21, 5, 5, 4, CURDATE(), CURDATE(), 110, 'address 29', 129, NULL, 1, CURDATE()),
(22, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), 108, 'address 28', 128, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 DAY));
(1 , 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY) , DATE_ADD(CURDATE(), INTERVAL -15 DAY) , 101, 'address 21', 121, 'T1111111', 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY) ),
(2 , 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY) , DATE_ADD(CURDATE(), INTERVAL -10 DAY) , 101, 'address 21', 121, 'T2222222', 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY) ),
(3 , 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL -5 DAY) , DATE_ADD(CURDATE(), INTERVAL -5 DAY) , 102, 'address 22', 122, 'T2222222', 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY) ),
(4 , 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL -4 DAY) , DATE_ADD(CURDATE(), INTERVAL -4 DAY) , 102, 'address 22', 122, 'T3333333', 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY) ),
(5 , 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -3 DAY) , DATE_ADD(CURDATE(), INTERVAL -3 DAY) , 103, 'address 23', 123, 'T3333333', 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY) ),
(6 , 3, 3, 4, DATE_ADD(CURDATE(), INTERVAL -2 DAY) , DATE_ADD(CURDATE(), INTERVAL -2 DAY) , 103, 'address 23', 123, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY) ),
(7 , 4, 4, 4, DATE_ADD(CURDATE(), INTERVAL -1 DAY) , DATE_ADD(CURDATE(), INTERVAL -1 DAY) , 104, 'address 24', 124, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY) ),
(8 , 1, 1, 4, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 104, 'address 24', 124, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH) ),
(9 , 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH) ),
(10, 6, 5, 5, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH) ),
(11, 7, 1, 1, CURDATE() , DATE_ADD(CURDATE(), INTERVAL +1 DAY) , 101, 'address 21', 121, NULL, 0, CURDATE() ),
(12, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH) ),
(13, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +2 MONTH) ),
(14, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +3 MONTH) ),
(15, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +4 MONTH) ),
(16, 1, 1, 1, CURDATE(), CURDATE(), 101, 'address 21', 121, NULL, 0, CURDATE() ),
(17, 4, 4, 4, CURDATE(), CURDATE(), 106, 'address 26', 126, NULL, 0, CURDATE() ),
(18, 4, 4, 4, CURDATE(), CURDATE(), 107, 'address 27', 127, NULL, 0, CURDATE() ),
(19, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), 108, 'address 28', 128, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY) ),
(20, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), 108, 'address 28', 128, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY) ),
(21, 5, 5, 4, CURDATE(), CURDATE(), 110, 'address 29', 129, NULL, 1, CURDATE() ),
(22, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), 108, 'address 28', 128, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 DAY) );
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
@ -647,8 +626,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(5, 1, 2, 'Ranged weapon longbow 2m', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
(6, 1, 3, 'Ranged weapon longbow 2m', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)),
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 1.46, 0, 0, 0, CURDATE()),
(8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.04, 0, 0, 0, CURDATE()),
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 1.02, 0, 0, 0, CURDATE()),
(8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.01, 0, 0, 0, CURDATE()),
(9, 1, 16, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, CURDATE()),
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 1.07, 0, 0, 0, CURDATE()),
(11, 1, 16, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, CURDATE()),
@ -673,125 +652,123 @@ INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
VALUES
(1, 15, 0.58),
(1, 23, 6.5),
(1, 28, 20.72),
(1, 29, -18.72),
(1, 39, 0.02),
(2, 15, 0.058),
(2, 21, 0.002),
(2, 28, 5.6),
(2, 29, -4.6),
(2, 39, 0.01),
(3, 15, 0.58),
(3, 23, 6.5),
(3, 28, 20.72),
(3, 29, -18.72),
(3, 39, 0.02),
(4, 15, 0.051),
(4, 21, -0.001),
(4, 28, 20.72),
(4, 29, -19.72),
(4, 37, 2),
(4, 39, 0.01),
(5, 15, 0.58),
(5, 23, 6.5),
(5, 28, 20.72),
(5, 29, -18.72),
(5, 39, 0.02),
(6, 23, 6.5),
(7, 15, 0.2839),
(7, 21, 0.166),
(7, 28, 5.6),
(7, 29, -4.6),
(7, 39, 0.01),
(8, 15, 0.039),
(8, 21, -0.009),
(8, 28, 20.72),
(8, 29, -19.72),
(8, 37, 2),
(8, 39, 0.01),
(9, 15, 0.58),
(9, 23, 6.5),
(9, 28, 20.72),
(9, 29, -18.72),
(9, 39, 0.02),
(10, 15, 0.058),
(10, 21, 0.002),
(10, 28, 5.6),
(10, 29, -4.6),
(10, 39, 0.01),
(11, 15, 0.58),
(11, 23, 6.5),
(11, 28, 20.72),
(11, 29, -18.72),
(11, 39, 0.02),
(12, 15, 0.051),
(12, 22, -0.001),
(12, 28, 20.72),
(12, 29, -19.72),
(12, 37, 2),
(12, 39, 0.01),
(13, 15, 0.2899),
(13, 28, 5.6),
(13, 29, -4.6),
(13, 39, 0.01),
(14, 15, 0.58),
(14, 23, 6.5),
(14, 28, 20.72),
(14, 29, -18.72),
(14, 39, 0.02),
(15, 15, 0.58),
(15, 23, 6.5),
(15, 28, 20.72),
(15, 29, -18.72),
(15, 39, 0.02),
(16, 15, 0.058),
(16, 21, 0.002),
(16, 28, 5.6),
(16, 29, -4.6),
(16, 39, 0.01),
(17, 15, 0.058),
(17, 21, 0.002),
(17, 28, 5.6),
(17, 29, -4.6),
(17, 39, 0.01),
(18, 15, 0.051),
(18, 22, -0.001),
(18, 28, 20.72),
(18, 29, -19.72),
(18, 37, 2),
(18, 39, 0.01),
(19, 15, 0.58),
(19, 23, 6.5),
(19, 28, 20.72),
(19, 29, -18.72),
(19, 39, 0.02),
(20, 15, 0.58),
(20, 23, 6.5),
(20, 28, 20.72),
(20, 29, -18.72),
(20, 39, 0.02),
(21, 15, 0.58),
(21, 23, 6.5),
(21, 28, 20.72),
(21, 29, -18.72),
(21, 39, 0.02),
(22, 15, 0.58),
(22, 23, 6.5),
(22, 28, 20.72),
(22, 29, -18.72),
(22, 39, 0.02),
(23, 15, 0.58),
(23, 23, 6.5),
(23, 28, 20.72),
(23, 29, -18.72),
(23, 39, 0.02),
(24, 15, 0.58),
(24, 23, 6.5),
(24, 28, 20.72),
(24, 29, -18.72),
(24, 39, 0.02);
(1, 15, 0.58),
(1, 23, 6.5),
(1, 28, 20.72),
(1, 29, -18.72),
(1, 39, 0.02),
(2, 15, 0.058),
(2, 21, 0.002),
(2, 28, 5.6),
(2, 29, -4.6),
(2, 39, 0.01),
(3, 15, 0.58),
(3, 23, 6.5),
(3, 28, 20.72),
(3, 29, -18.72),
(3, 39, 0.02),
(4, 15, 0.051),
(4, 21, -0.001),
(4, 28, 20.72),
(4, 29, -19.72),
(4, 37, 2),
(4, 39, 0.01),
(5, 15, 0.58),
(5, 23, 6.5),
(5, 28, 20.72),
(5, 29, -18.72),
(5, 39, 0.02),
(6, 23, 6.5),
(7, 15, 0.0114),
(7, 28, 5.6),
(7, 29, -4.6),
(7, 39, 0.01),
(8, 15, 0.0016),
(8, 28, 20.72),
(8, 29, -19.72),
(8, 37, 2),
(8, 39, 0.01),
(9, 15, 0.58),
(9, 23, 6.5),
(9, 28, 20.72),
(9, 29, -18.72),
(9, 39, 0.02),
(10, 15, 0.058),
(10, 21, 0.002),
(10, 28, 5.6),
(10, 29, -4.6),
(10, 39, 0.01),
(11, 15, 0.58),
(11, 23, 6.5),
(11, 28, 20.72),
(11, 29, -18.72),
(11, 39, 0.02),
(12, 15, 0.051),
(12, 22, -0.001),
(12, 28, 20.72),
(12, 29, -19.72),
(12, 37, 2),
(12, 39, 0.01),
(13, 15, 0.2899),
(13, 28, 5.6),
(13, 29, -4.6),
(13, 39, 0.01),
(14, 15, 0.58),
(14, 23, 6.5),
(14, 28, 20.72),
(14, 29, -18.72),
(14, 39, 0.02),
(15, 15, 0.58),
(15, 23, 6.5),
(15, 28, 20.72),
(15, 29, -18.72),
(15, 39, 0.02),
(16, 15, 0.058),
(16, 21, 0.002),
(16, 28, 5.6),
(16, 29, -4.6),
(16, 39, 0.01),
(17, 15, 0.058),
(17, 21, 0.002),
(17, 28, 5.6),
(17, 29, -4.6),
(17, 39, 0.01),
(18, 15, 0.051),
(18, 22, -0.001),
(18, 28, 20.72),
(18, 29, -19.72),
(18, 37, 2),
(18, 39, 0.01),
(19, 15, 0.58),
(19, 23, 6.5),
(19, 28, 20.72),
(19, 29, -18.72),
(19, 39, 0.02),
(20, 15, 0.58),
(20, 23, 6.5),
(20, 28, 20.72),
(20, 29, -18.72),
(20, 39, 0.02),
(21, 15, 0.58),
(21, 23, 6.5),
(21, 28, 20.72),
(21, 29, -18.72),
(21, 39, 0.02),
(22, 15, 0.58),
(22, 23, 6.5),
(22, 28, 20.72),
(22, 29, -18.72),
(22, 39, 0.02),
(23, 15, 0.58),
(23, 23, 6.5),
(23, 28, 20.72),
(23, 29, -18.72),
(23, 39, 0.02),
(24, 15, 0.58),
(24, 23, 6.5),
(24, 28, 20.72),
(24, 29, -18.72),
(24, 39, 0.02);
INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`)
VALUES
@ -1004,34 +981,6 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`,
(3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movimiento 3'),
(4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 69, 'Movimiento 4');
INSERT INTO `vn`.`agencyProvince`(`provinceFk`, `agencyFk`, `zone`, `warehouseFk`)
VALUES
(1, 1, 1, 1),
(1, 1, 1, 2),
(1, 1, 1, 3),
(1, 2, 2, 2),
(1, 2, 2, 3),
(1, 7, 2, 1),
(1, 8, 2, 1);
INSERT INTO `vn`.`agencyModeZone`(`agencyModeFk`, `zone`, `price`, `itemFk`, `warehouseFk`, `minimCost`, `inflation`)
VALUES
(1, 1, 10 , 71, 1, 1, 1.00),
(2, 1, 20 , 71, 1, 1, 1.00),
(3, 1, 10 , 71, 1, 1, 1.00),
(4, 1, 20 , 71, 1, 1, 2.00),
(5, 2, 10 , 71, 1, 0, 2.00),
(6, 2, 10 , 71, 1, 0, 2.00),
(7, 2, 50 , 71, 1, 1, 1.00),
(8, 2, 100, 71, 1, 1, 2.00);
INSERT INTO `vn`.`agencyWeekDayBonus`(`id`, `warehouseFk`, `agencyFk`, `weekDay`, `zone`, `bonus`)
VALUES
(1, 1, 1, 0, 1, -1.00),
(2, 1, 1, 1, 1, -1.00),
(3, 1, 1, 0, 2, -1.00),
(4, 1, 1, 1, 2, -1.00),
(5, 2, 2, 2, 3, 0);
INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio`, `recobro`, `inflacion`)
VALUES
@ -1310,37 +1259,6 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC
(4, 'Documentos', 1, 2.00, 1, 9),
(5, 'Documentos', 1, 2.00, 1, 8);
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
VALUES
(1, 'Zone 1 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2.3', '2.3'),
(2, 'Zone 1 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2.3', '2.3'),
(3, 'Zone 2 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '1', '2', '1.2', '1.2'),
(4, 'Zone 2 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '1', '2', '1.2', '1.2'),
(5, 'Zone 3 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2', '2'),
(6, 'Zone 3 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2', '2');
INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
VALUES
(1, 3, 0),
(1, 4, 1),
(1, 5, 1),
(2, 3, 1),
(2, 4, 0),
(2, 5, 1),
(3, 2, 1),
(3, 3, 0),
(3, 4, 0),
(3, 5, 1),
(4, 2, 0),
(4, 3, 1),
(4, 4, 1),
(4, 5, 0),
(5, 2, 1),
(5, 3, 1),
(5, 4, 1),
(5, 5, 1);
INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
VALUES
(1, 1010),
@ -1426,6 +1344,267 @@ INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubs
VALUES
(1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY));
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
VALUES
(1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 1, 0, '0', '0'),
(2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 1, 0, '0', '0'),
(3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 7, 1, '2', '0'),
(4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 7, 1, '2', '0'),
(5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 8, 1, '5', '-1'),
(6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 8, 1, '5', '-1'),
(7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 10, 0, 0, 0),
(8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 23, 0, 0, 0);
INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
VALUES
(1, 3, 0),
(1, 4, 0),
(1, 5, 0),
(1, 2, 1),
(2, 3, 0),
(2, 4, 0),
(2, 5, 0),
(2, 2, 1),
(3, 3, 0),
(3, 4, 0),
(3, 5, 0),
(3, 2, 1),
(4, 3, 0),
(4, 4, 0),
(4, 5, 0),
(4, 2, 1),
(5, 3, 1),
(5, 4, 0),
(5, 5, 1),
(5, 2, 1),
(6, 3, 1),
(6, 4, 0),
(6, 5, 1),
(6, 2, 1),
(7, 3, 0),
(7, 4, 0),
(7, 5, 0),
(7, 2, 1),
(8, 3, 0),
(8, 4, 0),
(8, 5, 0),
(8, 2, 1);
INSERT INTO `vn`.`zoneCalendar`(`zoneFk`, `delivered`)
VALUES
(1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)),
(1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)),
(1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)),
(1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)),
(1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)),
(2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)),
(2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)),
(2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)),
(2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)),
(2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)),
(3, CURDATE()),
(3, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
(3, DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
(4, CURDATE()),
(4, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
(4, DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
(5, CURDATE()),
(5, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
(5, DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
(6, CURDATE()),
(6, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
(6, DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
(7, CURDATE()),
(7, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(7, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(7, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(7, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(7, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(7, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
(8, CURDATE()),
(8, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
(8, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
(8, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
(8, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
(8, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
(8, DATE_ADD(CURDATE(), INTERVAL +6 DAY));
INSERT INTO `vn`.`workerTimeControl`(`userFk`,`timed`,`manual`)
VALUES
(106, CONCAT(CURDATE(), ' 07:00'), TRUE),

View File

@ -83,6 +83,7 @@ dump_tables ${TABLES[@]}
TABLES=(
hedera
imageCollection
tpvConfig
tpvError
tpvResponse

View File

@ -97,7 +97,7 @@ for DIR_PATH in "$DIR/changes/"*; do
for FILE in "$DIR_PATH/"*; do
FILE_NAME=$(basename "$FILE")
if [[ ! "$FILE_NAME" =~ ^[0-9]{2}-[a-zA-Z0-9]+\.sql$ ]]; then
if [[ ! "$FILE_NAME" =~ ^[0-9]{2}-[a-zA-Z0-9_]+\.sql$ ]]; then
echo "[WARN] Ignoring wrong file name: $FILE_NAME"
continue
fi

View File

@ -0,0 +1,559 @@
-- ticketCalculateClon-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `ticketCalculateClon`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
BEGIN
/*
* @vTicketNew id del nuevo ticket clonado
* @vTicketOld id ticket original, a partir del qual se clonara el nuevo
* Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo
*/
DECLARE vShipped DATE;
DECLARE vClient INT;
DECLARE vWarehouse SMALLINT;
DECLARE vAgencyMode INT;
DECLARE vAddress INT;
DECLARE vLanded DATE;
DECLARE vAgency INT;
REPLACE INTO orderTicket(orderFk,ticketFk)
SELECT orderFk, vTicketNew
FROM orderTicket
WHERE ticketFk = vTicketOld;
SELECT t.clientFk , t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk
INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency
FROM vn.agencyMode a
JOIN vn.ticket t ON t.agencyModeFk = a.id
WHERE t.id = vTicketNew;
DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped;
CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ENGINE = MEMORY
SELECT vWarehouse warehouseFk, vShipped shipped, vLanded landed;
CALL buyUltimate(vWarehouse, vShipped); -- rellena la tabla tmp.buyUltimate con la ultima compra
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot
SELECT vWarehouse warehouseFk,NULL available,s.itemFk, bu.buyFk
FROM sale s
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk;
CALL ticketComponentCalculate(vAddress,vAgencyMode);
-- Bionizamos lineas con Preu = 0
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouse warehouseFk
FROM sale s
JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price = 0;
CALL ticketComponentUpdateSale(1);
-- Bionizamos lineas con Preu > 0
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouse warehouseFk
FROM sale s
JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew
AND s.price > 0;
CALL ticketComponentUpdateSale(6);
IF vLanded IS NULL THEN
CALL zoneGetLanded(vShipped, vAddress, vAgency,vWarehouse);
UPDATE ticket t
JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk
SET t.landed = zgl.landed
WHERE t.id = vTicketNew;
END IF;
-- Log
CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket');
-- Limpieza
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
END$$
DELIMITER ;
DROP VIEW IF EXISTS `vn`.`agencyWeekDayBonus` ;
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`agencyWeekDayBonusKk` AS
SELECT
`a`.`id` AS `id`,
`a`.`warehouse_id` AS `warehouseFk`,
`a`.`agency_id` AS `agencyFk`,
`a`.`weekDay` AS `weekDay`,
`a`.`zona` AS `zone`,
`a`.`bonus` AS `bonus`
FROM
`vn2008`.`agency_weekday_bonus` `a`;
ALTER TABLE `vn2008`.`agency_weekday_bonus`
RENAME TO `vn2008`.`agency_weekday_bonusKk` ;
ALTER TABLE `vn2008`.`preparation_percentage`
RENAME TO `vn2008`.`preparation_percentageKk` ;
DROP VIEW IF EXISTS `vn`.`preparationPercentage` ;
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`preparationPercentageKk` AS
SELECT
`p`.`week_day` AS `weekDay`,
`p`.`warehouse_id` AS `warehouseFk`,
`p`.`percentage` AS `percentage`
FROM
`vn2008`.`preparation_percentage` `p`;
-- clonWeeklyTickets-----------------------------------------------------------------------
USE `vn2008`;
DROP procedure IF EXISTS `clonWeeklyTickets`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `clonWeeklyTickets`(IN vWeek INT)
BEGIN
DECLARE done BIT DEFAULT 0;
DECLARE vLanding DATE;
DECLARE vShipment DATE;
DECLARE vWarehouse INT;
DECLARE vTicket INT;
DECLARE vWeekDay INT;
DECLARE vClient INT;
DECLARE vEmpresa INT;
DECLARE vConsignatario INT;
DECLARE vAgencia INT;
DECLARE vNewTicket INT;
DECLARE vYear INT;
DECLARE rsTicket CURSOR FOR
SELECT tt.Id_Ticket, weekDay, Id_Cliente, warehouse_id, empresa_id, Id_Consigna, Id_Agencia
FROM Tickets_turno tt
JOIN Tickets t ON tt.Id_Ticket = t.Id_Ticket;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
SET done = 0;
SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0);
OPEN rsTicket;
FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vConsignatario, vAgencia;
WHILE NOT done DO
SELECT date INTO vShipment
FROM time
WHERE year = vYear AND week = vWeek
AND WEEKDAY(date) = vWeekDay;
-- busca si el ticket ya ha sido clonado
IF (select count(*) FROM Tickets t JOIN ticket_observation tob ON t.Id_Ticket = tob.Id_Ticket
WHERE Id_Consigna = vConsignatario AND Fecha = vShipment AND tob.text LIKE CONCAT('%',vTicket,'%')) = 0
THEN
IF (SELECT COUNT(*) FROM Agencias WHERE Id_Agencia = vAgencia AND Agencia LIKE '%turno%') THEN
SET vAgencia = NULL;
END IF;
CALL vn.ticketCreate(vClient, vShipment, vWarehouse, vEmpresa, vConsignatario, vAgencia, NULL, vLanding, vNewTicket);
INSERT INTO Movimientos (Id_Ticket, Id_Article, Concepte, Cantidad, Preu, Descuento, CostFixat, PrecioFijado)
SELECT vNewTicket, Id_Article, Concepte, Cantidad, Preu, Descuento, CostFixat, PrecioFijado
FROM Movimientos WHERE Id_Ticket = vTicket;
INSERT INTO Ordenes (orden,datorden,datticket,codvendedor,codcomprador,cantidad,preciomax,preu,id_article,id_cliente,comentario,
ok, total,datcompra,ko,id_movimiento)
SELECT o.orden,o.datorden,vShipment,o.codvendedor,o.codcomprador,o.cantidad,o.preciomax,o.preu,o.id_article,o.id_cliente,o.comentario,
o.ok, o.total,o.datcompra,o.ko,m2.Id_Movimiento
FROM Movimientos m JOIN Ordenes o ON o.Id_Movimiento = m.Id_Movimiento
JOIN Movimientos m2 ON m.Concepte = m2.Concepte AND m.Cantidad = m2.Cantidad AND m.Id_Article = m2.Id_Article
WHERE m.Id_Ticket = vTicket AND m2.Id_Ticket = vNewTicket;
INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicket))
ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' ');
INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,1,'ATENCION: Contiene lineas de TURNO')
ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' ');
CALL vn.ticketCalculateClon(vNewTicket, vTicket);
END IF;
FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vConsignatario, vAgencia;
END WHILE;
CLOSE rsTicket;
END$$
DELIMITER ;
-- ticketComponentCalculate-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `ticketComponentCalculate`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculate`(
vAddressFk INT,
vAgencyModeFk INT)
proc: BEGIN
/**
* Calcula los componentes de un ticket
*
* @param vAddressFk Id del consignatario
* @param vAgencyModeFk Id del modo de agencia
* @return tmp.ticketComponent, tmp.ticketComponentPrice
*/
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
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, aho.warehouseFk
FROM priceFixed pf
JOIN tmp.agencyHourGetShipped aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0
WHERE aho.shipped 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(amz.price
* amz.inflation, 50)) / vBoxVolume, 4
) cost
FROM tmp.ticketComponentCalculate tcc
JOIN item i ON i.id = tcc.itemFk
JOIN agencyMode am ON am.id = vAgencyModeFk
JOIN `address` a ON a.id = vAddressFk
JOIN agencyProvince ap ON ap.agencyFk = am.agencyFk
AND ap.warehouseFk = tcc.warehouseFk AND ap.provinceFk = a.provinceFk
JOIN agencyModeZone amz ON amz.agencyModeFk = vAgencyModeFk
AND amz.zone = ap.zone AND amz.itemFk = 71 AND amz.warehouseFk = tcc.warehouseFk
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,
SUM(tcs.sumCost) price
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)
SELECT
tcc.warehouseFk,
tcc.itemFk,
2 rate,
tcc.packing grouping,
SUM(tcs.sumCost) price
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)
SELECT
tcc.warehouseFk,
tcc.itemFk,
3 rate,
tcc.available grouping,
SUM(tcs.sumCost) price
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 ;
-- bionic_calc_clon-----------------------------------------------------------------------
USE `vn2008`;
DROP procedure IF EXISTS `vn2008`.`bionic_calc_clon`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_clonKk`(IN v_ticket BIGINT)
BEGIN
/*
* DEPRECATED vn.ticketCalculateClon
*
Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo
*/
DECLARE v_shipment DATE;
DECLARE v_customer INT;
DECLARE v_wh SMALLINT;
DECLARE v_agencia INT;
DECLARE v_consigna INT;
DECLARE v_landing DATE;
DECLARE v_agency INT;
REPLACE order_Tickets(order_id,Id_Ticket) VALUES(48, v_ticket);
SELECT t.Id_Cliente , t.warehouse_id, date(t.Fecha), t.Id_Consigna, t.Id_Agencia, t.landing, a.agency_id
INTO v_customer, v_wh, v_shipment, v_consigna, v_agencia, v_landing, v_agency
FROM vn2008.Agencias a
JOIN vn2008.Tickets t ON t.Id_Agencia = a.Id_Agencia
WHERE t.Id_Ticket = v_ticket;
DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped;
CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ENGINE = MEMORY
SELECT v_wh warehouseFk, v_shipment shipped, v_landing landed;
CALL item_last_buy_ (v_wh, v_shipment); -- rellena la tabla t_item_last_buy con la ultima compra
DROP TEMPORARY TABLE IF EXISTS tmp.bionic_lot;
CREATE TEMPORARY TABLE tmp.bionic_lot
SELECT v_wh warehouse_id,NULL available,
m.Id_Article item_id,ilb.buy_id
FROM Movimientos m
LEFT JOIN t_item_last_buy ilb ON ilb.item_id = m.Id_Article
WHERE m.Id_Ticket = v_ticket GROUP BY m.Id_Article;
CALL bionic_calc_component(v_consigna,v_agencia);
-- Bionizamos lineas con Preu = 0
DROP TEMPORARY TABLE IF EXISTS tmp.movement;
CREATE TEMPORARY TABLE tmp.movement
(PRIMARY KEY (Id_Movimiento)) ENGINE = MEMORY
SELECT Id_Movimiento, v_wh warehouse_id FROM Movimientos m
JOIN Tickets t on t.Id_Ticket = m.Id_Ticket WHERE m.Id_Ticket = v_ticket AND Preu = 0;
CALL bionic_movement_update(1);
-- Bionizamos lineas con Preu > 0
DROP TEMPORARY TABLE IF EXISTS tmp.movement;
CREATE TEMPORARY TABLE tmp.movement
(PRIMARY KEY (Id_Movimiento)) ENGINE = MEMORY
SELECT Id_Movimiento, v_wh warehouse_id FROM Movimientos m
JOIN Tickets t on t.Id_Ticket = m.Id_Ticket WHERE m.Id_Ticket = v_ticket AND Preu > 0;
CALL bionic_movement_update(6);
IF v_landing IS NULL THEN
CALL travel_tree_shipment(v_shipment, v_consigna, v_agency,v_wh);
UPDATE Tickets t
JOIN travel_tree_shipment tts ON t.warehouse_id = tts.warehouse_id
SET t.landing = tts.landing
WHERE Id_Ticket = v_ticket;
END IF;
-- Log
call Ditacio(v_ticket
,'Bioniza Ticket'
,'T'
, 20
, 'proc bionic_calc_clon'
, NULL);
-- Limpieza
DROP TEMPORARY TABLE t_item_last_buy;
END$$
DELIMITER ;

View File

@ -0,0 +1,241 @@
-- zoneGetAgency-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `zoneGetAgency`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency`(vAddress INT, vLanded DATE)
BEGIN
/**
* Devuelve el listado de agencias disponibles para la fecha
* y dirección pasadas.
*
* @param vAddress Id de dirección de envío, %NULL si es recogida
* @param vDate Fecha de recogida
* @select Listado de agencias disponibles
*/
DECLARE vPostalCode varchar(10);
SELECT postalCode INTO vPostalCode
FROM address WHERE id = vAddress;
SELECT * FROM (
SELECT am.id agencyModeFk,
am.name agencyMode,
am.description,
am.deliveryMethodFk,
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
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
JOIN agencyMode am ON am.id = z.agencyModeFk
WHERE zgSon.`name` LIKE vPostalCode
AND zc.delivered = vLanded
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
ORDER BY zgFather.depth DESC) t
GROUP BY agencyModeFk
HAVING isIncluded > 0;
END$$
DELIMITER ;
-- zoneGetFirstShipped-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `zoneGetFirstShipped`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetFirstShipped`(vAgencyModeFk INT, vAddress INT, vWarehouseFk INT)
BEGIN
/**
* Devuelve la primera fecha de envio disponible para una agencia en una direccion y un warehouse
*
* @param vAgencyMode id de la agencia en vn.agencyMode
* @param vAddress id de la direccion
* @param vWarehouse id del warehouse
* @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida
*/
DECLARE vPostalCode varchar(10);
SELECT postalCode INTO vPostalCode
FROM address WHERE id = vAddress;
SELECT * FROM (
SELECT TIMESTAMPADD(DAY,-z.travelingDays, zc.delivered) shipped,
zc.delivered landed
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 z.agencyModeFk = vAgencyModeFk
AND z.warehouseFk = vWarehouseFk
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, zc.delivered) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
ORDER BY landed ASC, zgFather.depth DESC) t
HAVING isIncluded > 0 LIMIT 1;
END$$
DELIMITER ;
-- zoneGetLanded-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `zoneGetLanded`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded`(vShipped DATE, vAddress INT, vAgencyMode INT, vWarehouse INT)
BEGIN
/**
* Devuelve una tabla temporal con el dia de recepcion para vShipped.
*
* @param vShipped Fecha de preparacion de mercancia
* @param vAddress Id de consignatario, %NULL para recogida
* @param vAgencyMode Id agencia
* @table tmp.zoneGetLanded Datos de recepción
*/
DECLARE vPostalCode varchar(10);
SELECT postalCode INTO vPostalCode
FROM address WHERE id = vAddress;
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
CREATE TEMPORARY TABLE tmp.zoneGetLanded
ENGINE = MEMORY
SELECT vWarehouse warehouseFk,delivered landed, isIncluded FROM (
SELECT zi.*, zc.delivered
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 = vAgencyMode
ORDER BY zgFather.depth DESC) t
GROUP BY zoneFk
HAVING isIncluded > 0
LIMIT 1;
END$$
DELIMITER ;
-- zoneGetShipped-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `zoneGetShipped`;
DELIMITER $$
USE `vn`$$
DROP procedure IF EXISTS `zoneGetShipped`;
CREATE DEFINER=`root`@`%` PROCEDURE `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 z.id,
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
vLanded landed,
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, landed ASC, zgFather.depth DESC) t
GROUP BY id
HAVING isIncluded > 0;
END$$
DELIMITER ;
-- zoneGetWarehouse-----------------------------------------------------------------------
USE `vn`;
DROP procedure IF EXISTS `zoneGetWarehouse`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
BEGIN
/**
* Devuelve el listado de agencias disponibles para la fecha,
* dirección y warehouse pasadas
*
* @param vAddress
* @param vWarehouse warehouse
* @param vLanded Fecha de recogida
* @select Listado de agencias disponibles
*/
DECLARE vPostalCode varchar(10);
SELECT postalCode INTO vPostalCode
FROM address WHERE id = vAddress;
SELECT * FROM (
SELECT am.id,
am.name agencyMode,
am.description,
am.deliveryMethodFk,
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
z.warehouseFk,
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
JOIN agencyMode am ON am.id = z.agencyModeFk
WHERE zgSon.`name` LIKE vPostalCode
AND delivered = vLanded
AND z.warehouseFk = vWarehouse
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
ORDER BY zgFather.depth DESC) t
GROUP BY id
HAVING isIncluded > 0;
END$$
DELIMITER ;
-- VIEW `vn`.`item`-----------------------------------------------------------------------
CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vn`.`item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`caja` AS `box`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown`,`t`.`compression` AS `compression` from `vn2008`.`Articles` `t`;
-- TABLE `vn`.`zone`-----------------------------------------------------------------------
ALTER TABLE `vn`.`zone`
ADD COLUMN `isVolumetric` TINYINT(1) NULL DEFAULT 0 AFTER `bonus`;
-- TABLE `vn`.`zone`-----------------------------------------------------------------------
ALTER TABLE `vn`.`zoneGeo`
ADD PRIMARY KEY (`id`);
;

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Client balance path', () => {
xdescribe('Client balance path', () => {
const nightmare = createNightmare();
beforeAll(() => {

View File

@ -24,7 +24,7 @@ describe('Ticket create path', () => {
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Bruce Banner')
.datePicker(selectors.createTicketView.deliveryDateInput, 1, null)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
@ -36,7 +36,7 @@ describe('Ticket create path', () => {
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();

View File

@ -22,7 +22,7 @@ describe('Order catalog', () => {
const url = await nightmare
.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Tony Stark')
.datePicker(selectors.createOrderView.landedDatePicker, 0, today)
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'Silla247')
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createOrderView.createButton)
.waitForURL('/catalog')
.parsedUrl();

View File

@ -89,5 +89,6 @@
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
"Please select at least one sale": "Por favor selecciona al menos una linea",
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket"
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
"NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada"
}

View File

@ -18,7 +18,7 @@ module.exports = Self => {
});
Self.getAgenciesWithWarehouse = async filter => {
let query = `CALL vn.agencyHourGetWarehouse(?, ?, ?)`;
let query = `CALL vn.zoneGetWarehouse(?, ?, ?)`;
let result = await Self.rawSql(query, [filter.addressFk, filter.landed, filter.warehouseFk]);
return result;

View File

@ -18,7 +18,7 @@ module.exports = Self => {
});
Self.getFirstShipped = async params => {
let query = `CALL vn.agencyHourGetFirstShipped(?, ?, ?)`;
let query = `CALL vn.zoneGetFirstShipped(?, ?, ?)`;
let [result] = await Self.rawSql(query, [params.agencyModeFk, params.addressFk, params.warehouseFk]);
return result[0];

View File

@ -1,12 +1,32 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('getLanded', {
description: 'Returns the landed',
Self.remoteMethodCtx('getLanded', {
description: 'Returns the first shipped and landed possible for params',
accessType: 'READ',
accepts: [{
arg: 'params',
type: 'object',
required: true,
description: 'shipped, addressFk, agencyModeFk, warehouseFk'
type: 'Object',
description: `shipped, addressFk, agencyModeFk, warehouseFk`
}, {
arg: 'shipped',
type: 'date',
required: true
},
{
arg: 'addressFk',
type: 'number',
required: true
},
{
arg: 'agencyModeFk',
type: 'number',
required: true
},
{
arg: 'warehouseFk',
type: 'number',
required: true
}],
returns: {
type: 'object',
@ -18,11 +38,24 @@ module.exports = Self => {
}
});
Self.getLanded = async params => {
let query = `CALL vn.agencyHourGetLanded(?, ?, ?, ?);
SELECT * FROM tmp.agencyHourGetLanded`;
let result = await Self.rawSql(query, [params.shipped, params.addressFk || null, params.agencyModeFk, params.warehouseFk]);
Self.getLanded = async(ctx, params) => {
let stmts = [];
params = params || ctx.args;
stmts.push(new ParameterizedSQL(
`CALL vn.zoneGetLanded(?, ?, ?, ?)`, [
params.shipped,
params.addressFk,
params.agencyModeFk,
params.warehouseFk
]
));
return result[1][0].landed;
let rsIndex = stmts.push(
`SELECT * FROM tmp.zoneGetLanded`) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let landed = await Self.rawStmt(sql);
return landed[rsIndex][0];
};
};

View File

@ -1,15 +1,33 @@
module.exports = Self => {
Self.remoteMethod('getShipped', {
Self.remoteMethodCtx('getShipped', {
description: 'Returns the first shipped possible for params',
accessType: 'READ',
accepts: [{
arg: 'params',
type: 'object',
required: true,
description: 'landed, addressFk, agencyModeFk'
type: 'Object',
description: `landed, addressFk, agencyModeFk, warehouseFk`
}, {
arg: 'landed',
type: 'date',
required: true
},
{
arg: 'addressFk',
type: 'number',
required: true
},
{
arg: 'agencyModeFk',
type: 'number',
required: true
},
{
arg: 'warehouseFk',
type: 'number',
required: true
}],
returns: {
type: 'object',
type: 'date',
root: true
},
http: {
@ -18,11 +36,15 @@ module.exports = Self => {
}
});
Self.getShipped = async params => {
let query = `CALL vn.agencyHourGetShipped(?, ?, ?);
SELECT * FROM tmp.agencyHourGetShipped`;
let result = await Self.rawSql(query, [params.landed, params.addressFk, params.agencyModeFk]);
return result[1][0].shipped || null;
Self.getShipped = async(ctx, params)=> {
params = params || ctx.args;
let query = `CALL vn.zoneGetShipped(?, ?, ?, ?)`;
let [response] = await Self.rawSql(query, [
params.landed,
params.addressFk,
params.agencyModeFk,
params.warehouseFk
]);
return (response[0] && response[0].shipped && response[0].shipped.toJSON()) || null;
};
};

View File

@ -18,9 +18,10 @@ module.exports = Self => {
});
Self.landsThatDay = async filter => {
let query = `CALL vn.agencyHourGetAgency(?, ?)`;
let query = `CALL vn.zoneGetAgency(?, ?);
SELECT * FROM tmp.zoneGetAgency`;
let result = await Self.rawSql(query, [filter.addressFk, filter.landed]);
return result;
return result[1];
};
};

View File

@ -1,17 +1,15 @@
const app = require('vn-loopback/server/server');
describe('Agency getLanded()', () => {
const today = new Date();
it('should return the landed', async() => {
let filter = {
shipped: today,
addressFk: 101,
agencyModeFk: 1,
describe('agency getLanded()', () => {
it('should return a landing date', async() => {
let data = {
shipped: new Date(),
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
};
let result = await app.models.Agency.getLanded({}, data);
let result = await app.models.Agency.getLanded(filter);
expect(result).toEqual(jasmine.any(Date));
expect(result.landed).toBeDefined();
});
});

View File

@ -0,0 +1,17 @@
const app = require('vn-loopback/server/server');
describe('Agency getLanded()', () => {
const today = new Date();
it('should return the landed', async() => {
let filter = {
shipped: today,
addressFk: 101,
agencyModeFk: 1,
warehouseFk: 1
};
let result = await app.models.Agency.getLanded(filter);
expect(result).toEqual(jasmine.any(Date));
});
});

View File

@ -1,16 +1,30 @@
const app = require('vn-loopback/server/server');
describe('Agency getShipped()', () => {
const today = new Date();
it('should return the first shipped possible for params', async() => {
let filter = {
landed: today,
addressFk: 101,
agencyModeFk: 1,
describe('agency getShipped()', () => {
it('should return a shipment date', async() => {
let data = {
landed: new Date(),
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
};
let result = await app.models.Agency.getShipped({}, data);
let result = await app.models.Agency.getShipped(filter);
expect(result).toBeDefined();
});
expect(result).toEqual(jasmine.any(Date));
it('should not return a shipment date', async() => {
let newDate = new Date();
newDate.setMonth(newDate.getMonth() - 1);
let data = {
landed: newDate,
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
};
let result = await app.models.Agency.getShipped({}, data);
expect(result).toBeNull();
});
});

View File

@ -0,0 +1,16 @@
const app = require('vn-loopback/server/server');
describe('Agency getShipped()', () => {
const today = new Date();
it('should return the first shipped possible for params', async() => {
let filter = {
landed: today,
addressFk: 101,
agencyModeFk: 1,
};
let result = await app.models.Agency.getShipped(filter);
expect(result).toEqual(jasmine.any(Date));
});
});

View File

@ -91,7 +91,7 @@ module.exports = Self => {
AND child.rgt < parent.rgt
AND child.depth = parent.depth + 1
LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id
AND zoneFk = ?
AND zi.zoneFk = ?
WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]);
// Get nodes from depth greather than Origin

View File

@ -11,7 +11,7 @@ describe('agency clone()', () => {
it('should clone a zone', async() => {
newZone = await app.models.Zone.clone(1);
expect(newZone.name).toEqual('Zone 1 A');
expect(newZone.name).toEqual('Zone pickup A');
});
});

View File

@ -7,6 +7,6 @@ describe('Client get', () => {
expect(result.id).toEqual(101);
expect(result.name).toEqual('Bruce Wayne');
expect(result.debt).toEqual(-14.78);
expect(result.debt).toEqual(-22.4);
});
});

View File

@ -4,7 +4,7 @@ describe('client getDebt()', () => {
it('should return the client debt', async() => {
let result = await app.models.Client.getDebt(101);
expect(result.debt).toEqual(-14.78);
expect(result.debt).toEqual(-22.4);
});
});

View File

@ -17,7 +17,7 @@ describe('client summary()', () => {
it('should return a summary object containing debt', async() => {
let result = await app.models.Client.summary(101);
expect(result.debt.debt).toEqual(-14.78);
expect(result.debt.debt).toEqual(-22.4);
});
it('should return a summary object containing averageInvoiced', async() => {

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
describe('item getShipped()', () => {
it('should return 3 entries and with a given balance for the first one', async() => {
describe('item getDiary()', () => {
it('should return 3 entries, the first one with the property balance -100', async() => {
let params = {where: {itemFk: 1, warehouseFk: 2}};
let result = await app.models.Item.getDiary(params);

View File

@ -31,7 +31,7 @@ module.exports = Self => {
params.items.forEach(item => {
promises.push(
Self.rawSql(
`CALL hedera.orderAddItem(?, ?, ?, ?)`,
`CALL hedera.order_addItem(?, ?, ?, ?)`,
[params.orderFk, item.warehouseFk, item.itemFk, item.quantity]
)
);

View File

@ -166,11 +166,7 @@ module.exports = Self => {
JOIN vn.tag t ON t.id = it.tagFk`) - 1;
// Clean temporary tables
stmts.push(
`DROP TEMPORARY TABLE
tmp.item,
tmp.ticketCalculateItem,
tmp.ticketComponentPrice`);
stmts.push('CALL vn.ticketCalculatePurge()');
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql);

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethod('confirm', {
Self.remoteMethodCtx('confirm', {
description: 'Confirms an order',
accessType: 'WRITE',
accepts: [{
@ -19,8 +19,9 @@ module.exports = Self => {
}
});
Self.confirm = async orderFk => {
let query = `CALL hedera.orderConfirm(?)`;
return await Self.rawSql(query, [orderFk]);
Self.confirm = async(ctx, orderFk) => {
const userId = ctx.req.accessToken.userId;
let query = `CALL hedera.order_confirmWithUser(?, ?)`;
return await Self.rawSql(query, [orderFk, userId]);
};
};

View File

@ -8,7 +8,7 @@ describe('order catalogFilter()', () => {
}
};
let tags = [];
let orderFk = 11;
let orderFk = 20;
let orderBy = {field: 'relevancy DESC, name', way: 'DESC'};
let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags);
let firstItemId = result[0].id;
@ -25,13 +25,14 @@ describe('order catalogFilter()', () => {
}
};
let tags = [{tagFk: 56, value: 'Melee weapon'}];
let orderFk = 11;
let tags = [{tagFk: 56, value: 'Melee Reinforced weapon'}];
let orderFk = 20;
let orderBy = {field: 'relevancy DESC, name', way: 'DESC'};
let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags);
let firstItemId = result[0].id;
expect(result.length).toEqual(1);
expect(firstItemId).toEqual(2);
expect(firstItemId).toEqual(9);
});
});

View File

@ -29,8 +29,7 @@
disabled="!$ctrl.clientFk || !$ctrl.landed"
data="$ctrl._availableAgencies"
label="Agency"
show-field="agency"
value-field="id"
rule="Order.agencyModeFk"
show-field="agencyMode"
value-field="agencyModeFk"
field="$ctrl.order.agencyModeFk">
</vn-autocomplete>

View File

@ -84,7 +84,7 @@ class Controller {
filter = encodeURIComponent(JSON.stringify(filter));
let query = `/api/Agencies/landsThatDay?filter=${filter}`;
this.$http.get(query).then(res => {
this._availableAgencies = res.data[0];
this._availableAgencies = res.data;
});
}
}

View File

@ -3,17 +3,19 @@ let UserError = require('vn-loopback/util/user-error');
describe('sale priceDifference()', () => {
it('should return ticket price differences', async() => {
let tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
let data = {
landed: new Date(),
landed: tomorrow,
addressFk: 121,
agencyModeFk: 1,
agencyModeFk: 7,
warehouseFk: 1
};
let result = await app.models.Sale.priceDifference(11, data);
expect(result.totalUnitPrice).toEqual(4.5);
expect(result.totalNewPrice).toEqual(4.24);
expect(result.totalDifference).toEqual(3.75);
expect(result.totalUnitPrice).toEqual(4.03);
expect(result.totalNewPrice).toEqual(4.03);
expect(result.totalDifference).toEqual(0);
});
it('should return an error if the ticket state is not valid for modifications', async() => {

View File

@ -1,46 +0,0 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('getLanded', {
description: 'Returns ticket available landed date',
accessType: 'READ',
accepts: [{
arg: 'data',
type: 'Object',
required: true,
description: 'shipped, addressFk, agencyModeFk, warehouseFk',
http: {source: 'body'}
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getLanded`,
verb: 'POST'
}
});
Self.getLanded = async data => {
let stmts = [];
let agencyMode = await Self.app.models.AgencyMode.findById(data.agencyModeFk);
stmts.push(new ParameterizedSQL(
`CALL vn.agencyHourGetLanded(?, ?, ?, ?)`, [
data.shipped,
data.addressFk,
agencyMode.agencyFk,
data.warehouseFk
]
));
let rsIndex = stmts.push(
`SELECT * FROM tmp.agencyHourGetLanded`) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let landed = await Self.rawStmt(sql);
return landed[rsIndex][0];
};
};

View File

@ -1,45 +0,0 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('getShipped', {
description: 'Returns ticket available shipment date',
accessType: 'READ',
accepts: [{
arg: 'data',
type: 'Object',
required: true,
description: 'landed, addressFk, agencyModeFk',
http: {source: 'body'}
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getShipped`,
verb: 'POST'
}
});
Self.getShipped = async data => {
let stmts = [];
let agencyMode = await Self.app.models.AgencyMode.findById(data.agencyModeFk);
stmts.push(new ParameterizedSQL(
`CALL vn.agencyHourGetShipped(?, ?, ?)`, [
data.landed,
data.addressFk,
agencyMode.agencyFk
]
));
let rsIndex = stmts.push(`
SELECT * FROM tmp.agencyHourGetShipped`) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let shipped = await Self.rawStmt(sql);
return shipped[rsIndex][0];
};
};

View File

@ -8,7 +8,7 @@ module.exports = Self => {
arg: 'params',
type: 'object',
required: true,
description: 'ClientFk, Shipped, WharehouseFk, CompanyFk, AddressFk, AgencyModeFk, RouteFk, Landed, userId',
description: 'ClientFk, Shipped, WarehouseFk, CompanyFk, AddressFk, AgencyModeFk, RouteFk, Landed, userId',
http: {source: 'body'}
}],
returns: {
@ -39,11 +39,11 @@ module.exports = Self => {
if (!address)
throw new UserError(`This address doesn't exist`);
let agency;
let agencyMode;
if (params && params.agencyModeFk)
agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk);
agencyMode = await Self.app.models.AgencyMode.findById(params.agencyModeFk);
if (address.client().type().code === 'normal' && (!agency || agency.code != 'refund')) {
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
if (address.client().isFreezed)
throw new UserError(`You can't create a ticket for a frozen client`);
@ -56,22 +56,23 @@ module.exports = Self => {
try {
if (!params.shipped && params.landed) {
params.shipped = await Self.app.models.Agency.getShipped({
params.shipped = await Self.app.models.Agency.getShipped(ctx, {
landed: params.landed,
addressFk: address.id,
agencyModeFk: agency.agencyFk
});
}
if (params.shipped && !params.landed) {
params.landed = await Self.app.models.Agency.getLanded({
shipped: params.shipped,
addressFk: address.id,
agencyModeFk: agency.agencyFk,
agencyModeFk: params.agencyModeFk,
warehouseFk: params.warehouseFk
});
}
if (params.shipped && !params.landed) {
const landedResult = await Self.app.models.Agency.getLanded(ctx, {
shipped: params.shipped,
addressFk: address.id,
agencyModeFk: params.agencyModeFk,
warehouseFk: params.warehouseFk
});
params.landed = landedResult.landed;
}
if (!params.userId && ctx.req && ctx.req.accessToken.userId)
params.userId = ctx.req.accessToken.userId;

View File

@ -9,6 +9,8 @@ describe('ticket componentUpdate()', () => {
let componentOfSaleEight = `SELECT value FROM vn.saleComponent
WHERE saleFk = 8 AND componentFk = 15`;
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
let ticketId = 11;
beforeAll(async done => {
@ -29,7 +31,7 @@ describe('ticket componentUpdate()', () => {
warehouseFk: 1,
companyFk: 442,
shipped: today,
landed: today,
landed: tomorrow,
isDeleted: false,
hasToBeUnrouted: false,
option: 1
@ -57,7 +59,7 @@ describe('ticket componentUpdate()', () => {
warehouseFk: 1,
companyFk: 442,
shipped: today,
landed: today,
landed: tomorrow,
isDeleted: false,
hasToBeUnrouted: false,
option: 1

View File

@ -1,15 +0,0 @@
const app = require('vn-loopback/server/server');
describe('ticket getLanded()', () => {
it('should return a landing date', async() => {
let data = {
shipped: new Date(),
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
};
let result = await app.models.Ticket.getLanded(data);
expect(result.landed).toBeDefined();
});
});

View File

@ -1,28 +0,0 @@
const app = require('vn-loopback/server/server');
describe('ticket getShipped()', () => {
it('should return a shipment date', async() => {
let data = {
landed: new Date(),
addressFk: 121,
agencyModeFk: 7
};
let result = await app.models.Ticket.getShipped(data);
expect(result.shipped).toBeDefined();
});
it('should not return a shipment date', async() => {
let newDate = new Date();
newDate.setMonth(newDate.getMonth() - 1);
let data = {
landed: newDate,
addressFk: 121,
agencyModeFk: 7
};
let result = await app.models.Ticket.getShipped(data);
expect(result).toBeUndefined();
});
});

View File

@ -14,8 +14,6 @@ module.exports = Self => {
require('../methods/ticket/getVAT')(Self);
require('../methods/ticket/getSales')(Self);
require('../methods/ticket/getSalesPersonMana')(Self);
require('../methods/ticket/getShipped')(Self);
require('../methods/ticket/getLanded')(Self);
require('../methods/ticket/filter')(Self);
require('../methods/ticket/getPossibleStowaways')(Self);
require('../methods/ticket/canBeInvoiced')(Self);

View File

@ -64,31 +64,42 @@ class Controller {
}
onChangeShipped(value) {
let data = {
let params = {
shipped: value,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk
};
let query = `/api/Tickets/getLanded`;
this.$http.post(query, data).then(res => {
let query = `/api/Agencies/getLanded`;
this.$http.get(query, {params}).then(res => {
if (res.data && res.data.landed)
this.ticket.landed = res.data.landed;
else {
return this.vnApp.showError(
this.$translate.instant(`There's no available agency for this shipping date`)
);
}
});
}
onChangeLanded(value) {
let data = {
let params = {
landed: value,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk
};
let query = `/api/Tickets/getShipped`;
this.$http.post(query, data).then(res => {
if (res.data && res.data.shipped)
this.ticket.shipped = res.data.shipped;
let query = `/api/Agencies/getShipped`;
this.$http.get(query, {params}).then(res => {
if (res.data)
this.ticket.shipped = res.data;
else {
return this.vnApp.showError(
this.$translate.instant(`There's no available agency for this landing date`)
);
}
});
}

View File

@ -5,12 +5,15 @@ describe('Ticket', () => {
let $state;
let controller;
let $httpBackend;
let $httpParamSerializer;
beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, _$httpParamSerializer_) => {
$state = _$state_;
$httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnTicketBasicDataStepOne', {$state});
}));
@ -66,15 +69,17 @@ describe('Ticket', () => {
agencyModeFk: 2,
warehouseFk: 1
};
let data = {
let params = {
shipped: shipped,
addressFk: 121,
agencyModeFk: 2,
warehouseFk: 1
};
$httpBackend.whenPOST(`/api/Tickets/getLanded`, data).respond(200);
$httpBackend.expectPOST(`/api/Tickets/getLanded`, data);
let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `/api/Agencies/getLanded?${serializedParams}`).respond(200);
$httpBackend.expect('GET', `/api/Agencies/getLanded?${serializedParams}`);
controller.onChangeShipped(shipped);
$httpBackend.flush();
});
@ -83,11 +88,24 @@ describe('Ticket', () => {
describe('onChangeLanded()', () => {
it('should return an available shipment date', async() => {
let landed = new Date();
controller._ticket = {id: 1, landed: landed, addressFk: 121, agencyModeFk: 2};
let data = {landed: landed, addressFk: 121, agencyModeFk: 2};
controller._ticket = {
id: 1,
landed: landed,
addressFk: 121,
agencyModeFk: 2,
warehouseFk: 1
};
let params = {
landed: landed,
addressFk: 121,
agencyModeFk: 2,
warehouseFk: 1
};
let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(200);
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
$httpBackend.whenPOST(`/api/Tickets/getShipped`, data).respond(200);
$httpBackend.expectPOST(`/api/Tickets/getShipped`, data);
controller.onChangeLanded(landed);
$httpBackend.flush();
});

View File

@ -1,2 +1,3 @@
There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada
Deleted: Eliminado
There's no available agency for this shipping date: No hay ninguna agencia disponible para la fecha de preparación seleccionada

View File

@ -37,7 +37,7 @@
disabled="!$ctrl.clientFk || !$ctrl.landed || !$ctrl.warehouseFk"
data="$ctrl._availableAgencies"
label="Agency"
show-field="agency"
show-field="agencyMode"
value-field="id"
field="$ctrl.ticket.agencyModeFk">
</vn-autocomplete>

View File

@ -71,7 +71,7 @@ describe('Worker absences()', () => {
let calendar = result[0];
let absences = result[1];
expect(calendar.totalHolidays).toEqual(13.5);
expect(calendar.totalHolidays).toEqual(15.5);
expect(calendar.holidaysEnjoyed).toEqual(5);
let firstType = absences[0].absenceType().name;

83
package-lock.json generated
View File

@ -1513,7 +1513,7 @@
},
"util": {
"version": "0.10.3",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true,
"requires": {
@ -1783,7 +1783,7 @@
"base": {
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
"integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
"integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=",
"dev": true,
"requires": {
"cache-base": "^1.0.1",
@ -2486,7 +2486,7 @@
"cache-base": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
"integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
"integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=",
"dev": true,
"requires": {
"collection-visit": "^1.0.0",
@ -2661,7 +2661,7 @@
"class-utils": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
"integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
"integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=",
"dev": true,
"requires": {
"arr-union": "^3.1.0",
@ -2818,7 +2818,7 @@
},
"string_decoder": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
@ -3360,13 +3360,13 @@
"dependencies": {
"jsesc": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
"dev": true
},
"regexpu-core": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
"resolved": "http://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
"integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=",
"dev": true,
"requires": {
@ -3377,13 +3377,13 @@
},
"regjsgen": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz",
"resolved": "http://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz",
"integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=",
"dev": true
},
"regjsparser": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz",
"resolved": "http://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz",
"integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=",
"dev": true,
"requires": {
@ -4023,7 +4023,7 @@
"dependencies": {
"fs-extra": {
"version": "0.30.0",
"resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"dev": true,
"requires": {
@ -5025,7 +5025,7 @@
},
"file-loader": {
"version": "1.1.11",
"resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==",
"dev": true,
"requires": {
@ -6152,7 +6152,7 @@
"global-modules": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
"integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
"integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=",
"dev": true,
"requires": {
"global-prefix": "^1.0.1",
@ -7008,7 +7008,7 @@
},
"kind-of": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"dev": true
},
@ -7192,7 +7192,7 @@
"dependencies": {
"es6-promise": {
"version": "3.3.1",
"resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
"integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=",
"dev": true
},
@ -8205,7 +8205,7 @@
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=",
"dev": true,
"requires": {
"isobject": "^3.0.1"
@ -8396,7 +8396,7 @@
},
"jasmine-core": {
"version": "2.99.1",
"resolved": "http://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz",
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz",
"integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=",
"dev": true
},
@ -8413,7 +8413,7 @@
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
"dev": true,
"requires": {
"colors": "1.1.2"
@ -10653,7 +10653,7 @@
},
"minimist": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
},
"minstache": {
@ -11195,7 +11195,7 @@
"dependencies": {
"jsesc": {
"version": "0.5.0",
"resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
"dev": true
}
@ -11825,8 +11825,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@ -11854,7 +11853,6 @@
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -11869,8 +11867,7 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
@ -11998,8 +11995,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -12011,7 +12007,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -12026,7 +12021,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -12034,8 +12028,7 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
@ -12139,8 +12132,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -12292,7 +12284,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -12639,7 +12630,7 @@
"dependencies": {
"minimist": {
"version": "0.0.10",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=",
"dev": true
},
@ -13287,7 +13278,7 @@
},
"pretty-bytes": {
"version": "1.0.4",
"resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz",
"integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=",
"dev": true,
"requires": {
@ -13376,7 +13367,7 @@
},
"through2": {
"version": "0.2.3",
"resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
"integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=",
"dev": true,
"requires": {
@ -14276,7 +14267,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true,
"requires": {
@ -14401,7 +14392,7 @@
"dependencies": {
"source-map": {
"version": "0.4.4",
"resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true,
"requires": {
@ -14541,7 +14532,7 @@
"set-value": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
"integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=",
"dev": true,
"requires": {
"extend-shallow": "^2.0.1",
@ -14733,7 +14724,7 @@
"snapdragon-node": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
"integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
"integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=",
"dev": true,
"requires": {
"define-property": "^1.0.0",
@ -14784,7 +14775,7 @@
"snapdragon-util": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
"integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
"integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=",
"dev": true,
"requires": {
"kind-of": "^3.2.0"
@ -15140,7 +15131,7 @@
"split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
"integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
"integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=",
"dev": true,
"requires": {
"extend-shallow": "^3.0.0"
@ -15332,7 +15323,7 @@
},
"string_decoder": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
@ -16711,7 +16702,7 @@
"useragent": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
"integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=",
"dev": true,
"requires": {
"lru-cache": "4.1.x",
@ -17448,7 +17439,7 @@
},
"globby": {
"version": "6.1.0",
"resolved": "http://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
"resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
"dev": true,
"requires": {
@ -17461,7 +17452,7 @@
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}