Merge branch 'test'
gitea/salix/master This commit looks good
Details
gitea/salix/master This commit looks good
Details
This commit is contained in:
commit
073c457abb
|
@ -0,0 +1,5 @@
|
|||
|
||||
ALTER TABLE `vn`.`zone`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD INDEX `zone_name_idx` (`name` ASC);
|
|
@ -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 ;
|
|
@ -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
|
@ -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 ;
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -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`))));
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
||||
;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
||||
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
RENAME TABLE hedera.myOrderMyTicket TO hedera.myOrderTicket;
|
|
@ -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;
|
File diff suppressed because one or more lines are too long
|
@ -141,33 +141,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'),
|
||||
|
@ -230,8 +203,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),
|
||||
|
@ -262,8 +235,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
|
||||
|
@ -283,10 +256,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;
|
||||
|
||||
UPDATE `vn`.`client` `c`
|
||||
JOIN `vn`.`address` `a` ON `a`.`clientFk` = `c`.`id`
|
||||
SET `c`.`defaultAddressFk` = `a`.`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;
|
||||
|
||||
INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`)
|
||||
VALUES
|
||||
|
@ -434,7 +413,7 @@ INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped
|
|||
(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() , CURDATE() , 101, 'address 21', 121, NULL, 0, CURDATE() ),
|
||||
(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) ),
|
||||
|
@ -635,8 +614,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()),
|
||||
|
@ -688,13 +667,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
|||
(5, 29, -18.72),
|
||||
(5, 39, 0.02),
|
||||
(6, 23, 6.5),
|
||||
(7, 15, 0.2839),
|
||||
(7, 21, 0.166),
|
||||
(7, 15, 0.0114),
|
||||
(7, 28, 5.6),
|
||||
(7, 29, -4.6),
|
||||
(7, 39, 0.01),
|
||||
(8, 15, 0.039),
|
||||
(8, 21, -0.003),
|
||||
(8, 15, 0.0016),
|
||||
(8, 28, 20.72),
|
||||
(8, 29, -19.72),
|
||||
(8, 37, 2),
|
||||
|
@ -992,34 +969,7 @@ 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
|
||||
|
@ -1290,37 +1240,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`, `secret`, `caller_id`)
|
||||
VALUES
|
||||
(1, 1010, '123456', 'employee'),
|
||||
|
@ -1404,4 +1323,311 @@ INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk
|
|||
|
||||
INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`)
|
||||
VALUES
|
||||
(1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY));
|
||||
(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),
|
||||
(106, CONCAT(CURDATE(), ' 10:00'), TRUE),
|
||||
(106, CONCAT(CURDATE(), ' 10:10'), TRUE),
|
||||
(106, CONCAT(CURDATE(), ' 15:00'), TRUE);
|
||||
|
||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||
VALUES
|
||||
(1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'),
|
||||
(2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'),
|
||||
(3, 'Laboral', 'laboral', NULL, NULL, 'hhrrData'),
|
||||
(4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'),
|
||||
(5, 'Otros', 'otros', 1, NULL, 'miscellaneous'),
|
||||
(6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'),
|
||||
(7, 'IAE Clientes', 'IAE_Clientes', NULL, NULL, 'economicActivitiesTax'),
|
||||
(8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'),
|
||||
(9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'),
|
||||
(10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'),
|
||||
(11, 'Contratos', 'contratos', NULL, NULL, 'contracts'),
|
||||
(12, 'ley de pagos', 'ley pagos', NULL, NULL, 'paymentsLaw'),
|
||||
(13, 'Basura', 'basura', NULL, NULL, 'trash'),
|
||||
(14, 'Ticket', 'tickets', 1, NULL, 'ticket'),
|
||||
(15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'),
|
||||
(16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
|
||||
(17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
|
||||
(18, 'dua', 'dua', NULL, NULL, 'dua'),
|
||||
(19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets');
|
||||
|
||||
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
||||
VALUES
|
||||
(1, 14, '1.pdf', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', CURDATE()),
|
||||
(2, 5, '2.pdf', 5, 1, 442, 1, TRUE, 'Client:101', 'Client:101 dms for the client', CURDATE()),
|
||||
(3, 5, '3.pdf', 5, 1, 442, NULL, TRUE, 'Client: 101', 'Client:101 readme', CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`)
|
||||
VALUES
|
||||
(11, 1);
|
||||
|
||||
INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
|
||||
VALUES
|
||||
(101, 2),
|
||||
(101, 3);
|
||||
|
||||
INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) VALUES ('aaa', 'android', '9');
|
||||
|
|
13508
db/dump/structure.sql
13508
db/dump/structure.sql
File diff suppressed because it is too large
Load Diff
|
@ -84,6 +84,7 @@ dump_tables ${TABLES[@]}
|
|||
|
||||
TABLES=(
|
||||
hedera
|
||||
imageCollection
|
||||
tpvConfig
|
||||
tpvError
|
||||
tpvResponse
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ;
|
|
@ -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`);
|
||||
;
|
|
@ -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(() => {
|
||||
|
|
|
@ -7,57 +7,10 @@ describe('Ticket Edit basic data path', () => {
|
|||
beforeAll(() => {
|
||||
return nightmare
|
||||
.loginAndModule('employee', 'ticket')
|
||||
.accessToSearchResult('id:11')
|
||||
.accessToSearchResult(11)
|
||||
.accessToSection('ticket.card.basicData.stepOne');
|
||||
});
|
||||
|
||||
it(`should edit the client and address of the ticket then click next`, async() => {
|
||||
let url = await nightmare
|
||||
.autocompleteSearch(selectors.ticketBasicData.clientAutocomplete, 'Charles Xavier')
|
||||
.wait(500)
|
||||
.autocompleteSearch(selectors.ticketBasicData.addressAutocomplete, 'Charles Xavier')
|
||||
.waitToClick(selectors.ticketBasicData.nextStepButton)
|
||||
.waitForURL('data/step-two')
|
||||
.parsedUrl();
|
||||
|
||||
expect(url.hash).toContain('data/step-two');
|
||||
});
|
||||
|
||||
it(`should have no price diference`, async() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
||||
|
||||
expect(result).toContain('0');
|
||||
});
|
||||
|
||||
it(`should click next to move on to step three`, async() => {
|
||||
let url = await nightmare
|
||||
.waitToClick(selectors.ticketBasicData.nextStepButton)
|
||||
.waitForURL('data/step-three')
|
||||
.parsedUrl();
|
||||
|
||||
expect(url.hash).toContain('data/step-three');
|
||||
});
|
||||
|
||||
it(`should select a reason for the changes made then click on finalize`, async() => {
|
||||
let url = await nightmare
|
||||
.autocompleteSearch(selectors.ticketBasicData.chargesReasonAutocomplete, 'No realizar modificaciones en precios')
|
||||
.waitToClick(selectors.ticketBasicData.finalizeButton)
|
||||
.waitForURL('summary')
|
||||
.parsedUrl();
|
||||
|
||||
expect(url.hash).toContain('summary');
|
||||
});
|
||||
|
||||
it(`should go back to ticket.basicData section`, async() => {
|
||||
let url = await nightmare
|
||||
.waitToClick(selectors.ticketBasicData.basicDataButton)
|
||||
.waitForURL('data/step-one')
|
||||
.parsedUrl();
|
||||
|
||||
expect(url.hash).toContain('data/step-one');
|
||||
});
|
||||
|
||||
it(`should edit the ticket agency then click next`, async() => {
|
||||
let url = await nightmare
|
||||
.autocompleteSearch(selectors.ticketBasicData.agencyAutocomplete, 'Silla247Expensive')
|
||||
|
@ -70,10 +23,9 @@ describe('Ticket Edit basic data path', () => {
|
|||
|
||||
it(`should have a price diference`, async() => {
|
||||
const result = await nightmare
|
||||
.wait(1900)
|
||||
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
||||
|
||||
expect(result).toContain('-€203.25');
|
||||
expect(result).toContain('-€4.50');
|
||||
});
|
||||
|
||||
it(`should then click next to move on to step three`, async() => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import createNightmare from '../../helpers/nightmare';
|
||||
|
||||
describe('Ticket services path', () => {
|
||||
xdescribe('Ticket services path', () => {
|
||||
const nightmare = createNightmare();
|
||||
|
||||
beforeAll(() => {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -82,5 +82,6 @@
|
|||
"That item is not available on that day": "El item no esta disponible para esa fecha",
|
||||
"That item doesn't exists": "That item doesn't exists",
|
||||
"You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
|
||||
"This ticket can not be modified": "Este ticket no puede ser modificado"
|
||||
"This ticket can not be modified": "Este ticket no puede ser modificado",
|
||||
"NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada"
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getLanded', {
|
||||
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];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket getLanded()', () => {
|
||||
describe('agency getLanded()', () => {
|
||||
it('should return a landing date', async() => {
|
||||
let data = {
|
||||
shipped: new Date(),
|
||||
|
@ -8,7 +8,7 @@ describe('ticket getLanded()', () => {
|
|||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getLanded(data);
|
||||
let result = await app.models.Agency.getLanded({}, data);
|
||||
|
||||
expect(result.landed).toBeDefined();
|
||||
});
|
|
@ -1,15 +1,16 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket getShipped()', () => {
|
||||
describe('agency getShipped()', () => {
|
||||
it('should return a shipment date', async() => {
|
||||
let data = {
|
||||
landed: new Date(),
|
||||
addressFk: 121,
|
||||
agencyModeFk: 7
|
||||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getShipped(data);
|
||||
let result = await app.models.Agency.getShipped({}, data);
|
||||
|
||||
expect(result.shipped).toBeDefined();
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not return a shipment date', async() => {
|
||||
|
@ -19,10 +20,11 @@ describe('ticket getShipped()', () => {
|
|||
let data = {
|
||||
landed: newDate,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 7
|
||||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getShipped(data);
|
||||
let result = await app.models.Agency.getShipped({}, data);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('Client activeWorkersWithRole', () => {
|
|||
|
||||
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
|
||||
|
||||
expect(result.length).toEqual(11);
|
||||
expect(result.length).toEqual(12);
|
||||
expect(isSalesPerson).toBeTruthy();
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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() => {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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]
|
||||
)
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
disabled="!$ctrl.clientFk || !$ctrl.landed"
|
||||
data="$ctrl._availableAgencies"
|
||||
label="Agency"
|
||||
show-field="agency"
|
||||
value-field="id"
|
||||
show-field="agencyMode"
|
||||
value-field="agencyModeFk"
|
||||
field="$ctrl.order.agencyModeFk">
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() => {
|
||||
|
|
|
@ -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];
|
||||
};
|
||||
};
|
|
@ -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];
|
||||
};
|
||||
};
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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`)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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
|
||||
Deleted: Eliminado
|
||||
There's no available agency for this shipping date: No hay ninguna agencia disponible para la fecha de preparación seleccionada
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
Author : Enrique Blasco BLanquer
|
||||
Date: 27 de mayo de 2019
|
||||
*/
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('checkUuid', {
|
||||
description: 'Check UUID from user',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'data',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'uuid,model',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: [{
|
||||
type: 'Object',
|
||||
root: true
|
||||
}],
|
||||
http: {
|
||||
path: `/checkUuid`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.checkUuid = async(ctx, data) => {
|
||||
const myUserId = ctx.req.accessToken.userId;
|
||||
// 1 Check is a registered user with a uuid
|
||||
let deviceUser = await Self.findOne({where: {userFk: myUserId, sn: data.uuid}});
|
||||
|
||||
if (deviceUser != null)
|
||||
return {'state': true, 'mng': ''};
|
||||
else {
|
||||
// 2 If it does not exist it can be for two reasons:
|
||||
// 2.1 It is the first time that the application enters so we have to register a new user associated with the user
|
||||
// 2.2 Has the user associated with a different uuid, so we deny access.
|
||||
|
||||
let device = await Self.findOne({where: {userFk: myUserId}});
|
||||
if (device != null) {
|
||||
// The device is already registered by another user, access is denied
|
||||
return {'state': false, 'mng': 'Ya estas regisgtrado en otro dispositivo, contacta con los dioses de informática.'};
|
||||
} else {
|
||||
// Check that the device is free
|
||||
let aDevice = await Self.findOne({where: {sn: data.uuid}});
|
||||
if (aDevice != null)
|
||||
return {'state': false, 'mng': 'El dispositivo esta siendo usado por otro usuario'};
|
||||
else {
|
||||
// It's the first time you access the application, insert
|
||||
/* await Self.rawSql('INSERT INTO vn2008.device (sn, model) VALUES (?,?);', [data.uuid, data.model]);*/
|
||||
await Self.create({
|
||||
sn: data.uuid,
|
||||
model: data.model,
|
||||
userFk: myUserId
|
||||
});
|
||||
|
||||
return {'state': true, 'mng': 'Nuevo dispositivo registrado'};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('device checkUuid()', () => {
|
||||
it('should return an state equal to false', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let data = {'uuid': '123', 'model': 'ihpne kike molon'};
|
||||
let result = await app.models.Device.checkUuid(ctx, data);
|
||||
|
||||
expect(result.name).toBeFalsy();
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Author : Enrique Blasco BLanquer
|
||||
Date: 27 de mayo de 2019
|
||||
*/
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('addAutoTime', {
|
||||
description: 'Adds a new hour registry by app in manual 0',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'data',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'timed',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: [{
|
||||
type: 'Object',
|
||||
root: true
|
||||
}],
|
||||
http: {
|
||||
path: `/addAutoTime`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.addAutoTime = async(ctx, data) => {
|
||||
const myUserId = ctx.req.accessToken.userId;
|
||||
|
||||
// get all worked time control, needed to calculate order
|
||||
let hours = await Self.rawSql(`SELECT * FROM vn.workerTimeControl
|
||||
WHERE userFk = ?
|
||||
AND DATE(timed) = CURDATE()
|
||||
ORDER BY timed DESC LIMIT 1`, [myUserId]);
|
||||
|
||||
// 1 get next order
|
||||
let order = 0;
|
||||
if (hours.length > 0)
|
||||
order = hours[hours.length - 1].order;
|
||||
|
||||
// 2 create element in db
|
||||
return Self.create({
|
||||
userFk: myUserId,
|
||||
timed: data.timed,
|
||||
order: order + 1,
|
||||
manual: 0
|
||||
});
|
||||
};
|
||||
};
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Author : Enrique Blasco BLanquer
|
||||
Date: 28 de mayo de 2019
|
||||
*/
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getHoursWorked', {
|
||||
description: 'Get worked hours in current week, month and year',
|
||||
accessType: 'WRITE',
|
||||
returns: [{
|
||||
type: 'Object',
|
||||
root: true
|
||||
}],
|
||||
http: {
|
||||
path: `/getHoursWorked`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getHoursWorked = async(ctx, data) => {
|
||||
let totalHours = 0; // total hours worked in one year
|
||||
let totalMinutes = 0; // total minutes worked in one year
|
||||
let totalHoursMonth = 0; // total hours worked in one month
|
||||
let totalMinutesMonth = 0; // total minutes worked in one month
|
||||
let totalHoursWeek = 0; // total hours worked in one week
|
||||
let totalMinutesWeek = 0; // total minutes worked in one week
|
||||
const myUserId = ctx.req.accessToken.userId; // user id
|
||||
let today = new Date(); // needed to calculate total hours worked to current date
|
||||
let fromDate = today.getFullYear() + '-01-01'; // from date, current year
|
||||
let toDate = today.getFullYear() + '-12-31'; // to date, current year
|
||||
|
||||
|
||||
// 1 hours worked in a year
|
||||
let hoursYear = await Self.rawSql(`SELECT wtc.userFk, DATE(wtc.timed) dated,
|
||||
UNIX_TIMESTAMP(MIN(timed))timedStart,
|
||||
SEC_TO_TIME(SUM(if( mod(wtc.order,2)=1,
|
||||
UNIX_TIMESTAMP(timed) *-1,
|
||||
UNIX_TIMESTAMP(timed)))) timeWorkDay
|
||||
FROM vn.workerTimeControl wtc
|
||||
WHERE wtc.timed BETWEEN ? AND ? AND userFk = ?
|
||||
GROUP BY wtc.userFk,dated ORDER BY dated DESC`, [fromDate, toDate, myUserId]);
|
||||
|
||||
|
||||
// 2 Get days of week
|
||||
let week = [];
|
||||
// Starting Monday not Sunday
|
||||
let current = new Date();
|
||||
current.setDate((current.getDate() - current.getDay() + 1));
|
||||
for (let i = 0; i < 7; i++) {
|
||||
week.push(
|
||||
new Date(current)
|
||||
);
|
||||
current.setDate(current.getDate() + 1);
|
||||
}
|
||||
|
||||
// 3 I have all timed control for one year... NOW I CALCULATE TOTAL HOURS IN YEAR, MONTH, WEEK, Let's GO!
|
||||
for (hour of hoursYear) {
|
||||
if (parseInt(hour.timeWorkDay.split(':')[0]) > 0) {
|
||||
// YEAR
|
||||
totalHours += parseInt(hour.timeWorkDay.split(':')[0]);
|
||||
totalMinutes += parseInt(hour.timeWorkDay.split(':')[1]);
|
||||
// If it exceeds 5 hours we add 20 minutes of breakfast.
|
||||
if (parseInt(hour.timeWorkDay.split(':')[0]) >= 5)
|
||||
totalMinutes += 20;
|
||||
// MONTH
|
||||
|
||||
if ((new Date(hour.dated)).getMonth() == today.getMonth()) {
|
||||
totalHoursMonth += parseInt(hour.timeWorkDay.split(':')[0]);
|
||||
totalMinutesMonth += parseInt(hour.timeWorkDay.split(':')[1]);
|
||||
// If it exceeds 5 hours we add 20 minutes of breakfast.
|
||||
if (parseInt(hour.timeWorkDay.split(':')[0]) >= 5)
|
||||
totalMinutesMonth += 20;
|
||||
}
|
||||
// WEEK
|
||||
for (day of week) {
|
||||
let dayOfWeek = new Date(day);
|
||||
let dayOfCurrentWeek = new Date(hour.dated);
|
||||
if (dayOfWeek.getMonth() == dayOfCurrentWeek.getMonth() && dayOfWeek.getDate() == dayOfCurrentWeek.getDate()) {
|
||||
totalHoursWeek += parseInt(hour.timeWorkDay.split(':')[0]);
|
||||
totalMinutesWeek += parseInt(hour.timeWorkDay.split(':')[1]);
|
||||
// If it exceeds 5 hours we add 20 minutes of breakfast.
|
||||
if (parseInt(hour.timeWorkDay.split(':')[0]) >= 5)
|
||||
totalMinutesWeek += 20;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TOTAL WORKED HOURS IN THE YEAR
|
||||
totalHours += totalMinutes / 60;
|
||||
totalHours = decimalToHour(totalHours);
|
||||
|
||||
// TOTAL WORKED HOURS IN THE MONTH
|
||||
totalHoursMonth += totalMinutesMonth / 60;
|
||||
totalHoursMonth = decimalToHour(totalHoursMonth);
|
||||
|
||||
// TOTAL WORKED HOURS IN THE WEEK
|
||||
totalHoursWeek += totalMinutesWeek / 60;
|
||||
totalHoursWeek = decimalToHour(totalHoursWeek);
|
||||
|
||||
return {
|
||||
'totalWorekdYear': totalHours,
|
||||
'totalWorekdMonth': totalHoursMonth,
|
||||
'totalWorkedWeek': totalHoursWeek
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
function to calculate hours and minutes from decimal value
|
||||
*/
|
||||
function decimalToHour(value) {
|
||||
let decimalTime = parseFloat(value);
|
||||
decimalTime = decimalTime * 60 * 60;
|
||||
let hoursDay = Math.floor((decimalTime / (60 * 60)));
|
||||
decimalTime = decimalTime - (hoursDay * 60 * 60);
|
||||
let minutesDay = Math.floor((decimalTime / 60));
|
||||
return hoursDay + ':' + minutesDay;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
Author : Enrique Blasco BLanquer
|
||||
Date: 29 de mayo de 2019
|
||||
*/
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getWorkedWeek', {
|
||||
description: 'get worked week info',
|
||||
accessType: 'WRITE',
|
||||
returns: [{
|
||||
type: 'Object',
|
||||
root: true
|
||||
}],
|
||||
http: {
|
||||
path: `/getWorkedWeek`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getWorkedWeek = async(ctx, data) => {
|
||||
const myUserId = ctx.req.accessToken.userId; // user id
|
||||
let lastDate = new Date('1986-09-24'); // reference date
|
||||
let diff = 0; // difference of value between two dates
|
||||
let total = 0; // total hours
|
||||
|
||||
// 1 Get days of week
|
||||
let week = [];
|
||||
// 2 Starting Monday not Sunday
|
||||
let current = new Date();
|
||||
current.setDate((current.getDate() - current.getDay() + 1));
|
||||
for (let i = 0; i < 7; i++) {
|
||||
week.push(
|
||||
new Date(current)
|
||||
);
|
||||
current.setDate(current.getDate() + 1);
|
||||
}
|
||||
|
||||
let fromDate = week[0].getFullYear() + '-' + (week[0].getMonth() + 1) + '-' + week[0].getDate();
|
||||
let toDate = week[week.length - 1].getFullYear() + '-' + (week[week.length - 1].getMonth() + 1) + '-' + week[week.length - 1].getDate();
|
||||
|
||||
|
||||
// 3 hours worked in a current week
|
||||
let hoursWeek = await Self.rawSql(`SELECT wtc.timed ,wtc.order
|
||||
FROM vn.workerTimeControl wtc
|
||||
WHERE userFk = ?
|
||||
AND DATE(timed) BETWEEN ? AND ? ORDER BY timed DESC;`, [myUserId, fromDate, toDate]);
|
||||
|
||||
// 4 treat data
|
||||
let isFirst = true;
|
||||
for (let i = hoursWeek.length - 1; i >= 0; i--) {
|
||||
let d = new Date(hoursWeek[i].timed);
|
||||
if (isFirst) {
|
||||
lastDate = d;
|
||||
isFirst = false;
|
||||
} else {
|
||||
if (lastDate.getDate() === d.getDate()) {
|
||||
diff += Math.abs(d.getTime() - lastDate.getTime());
|
||||
lastDate = d;
|
||||
} else {
|
||||
total += diff;
|
||||
diff = 0;
|
||||
lastDate = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
total += diff;
|
||||
|
||||
// 5 calculate hours and minutes
|
||||
let decimalTime = total / 1000 / 3600;
|
||||
decimalTime = decimalTime * 60 * 60;
|
||||
let hours = Math.floor((decimalTime / (60 * 60)));
|
||||
decimalTime = decimalTime - (hours * 60 * 60);
|
||||
let minutes = Math.floor((decimalTime / 60));
|
||||
|
||||
return {'timeds': hoursWeek, 'totalWorked': hours + ':' + minutes};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('workerTimeControl addAutoTime()', () => {
|
||||
it('should return an undefined value', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let data = {'timed': new Date()};
|
||||
let result = await app.models.WorkerTimeControl.addAutoTime(ctx, data);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('workerTimeControl getHoursWorked()', () => {
|
||||
it('should return an totalWorkedYear to be defined', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let result = await app.models.WorkerTimeControl.getHoursWorked(ctx, null);
|
||||
|
||||
expect(result.totalWorekdYear).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('workerTimeControl getWorkedWeek()', () => {
|
||||
it('should return an timeds to be defined', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let result = await app.models.WorkerTimeControl.getWorkedWeek(ctx, null);
|
||||
|
||||
expect(result.timeds).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
Author : Enrique Blasco BLanquer
|
||||
Date: 28 de mayo de 2019
|
||||
*/
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getWorkerInfo', {
|
||||
description: 'Get worker info (name, isWorking, total worked hours ...)',
|
||||
accessType: 'WRITE',
|
||||
returns: [{
|
||||
type: 'Object',
|
||||
root: true
|
||||
}],
|
||||
http: {
|
||||
path: `/getWorkerInfo`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getWorkerInfo = async(ctx, data) => {
|
||||
let prevHour = new Date(); // default value to start work
|
||||
let diff = 0; // difference of value between two dates
|
||||
let isOdd = true; // determine if timed is odd or not in db
|
||||
const myUserId = ctx.req.accessToken.userId; // get user id
|
||||
|
||||
|
||||
// 1 get name and photo for the user
|
||||
let [user] = await Self.rawSql(`SELECT u.name, t.Foto FROM vn.user u INNER JOIN vn2008.Trabajadores t ON u.id = t.user_id WHERE id = ?;`, [myUserId]);
|
||||
// 2 get all jornaly work time registered
|
||||
let workedHours = await Self.rawSql(`SELECT * FROM vn.workerTimeControl WHERE userFk = ? AND DATE(timed) = CURDATE() ORDER BY timed ASC;`, [myUserId]);
|
||||
let today = new Date();
|
||||
// 3 get the number of hours to work in one day
|
||||
let date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
||||
let [hoursForDay] = await Self.rawSql(`SELECT cl.hours_week AS hoursWeek,
|
||||
GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-') start ,
|
||||
GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-') end,
|
||||
CAST(IFNULL((SUM(TIME_TO_SEC(j.end))-SUM(TIME_TO_SEC(j.start)))/3600,if(cl.hours_week=40
|
||||
AND DAYOFWEEK(t.dated) IN(2,3,4,5,6),8,0)) AS DECIMAL(10,2)) workingHours
|
||||
FROM vn.time t
|
||||
LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end,? )
|
||||
LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id
|
||||
LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id
|
||||
LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
|
||||
LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
|
||||
LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
|
||||
LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(t.dated)+1
|
||||
WHERE t.dated BETWEEN ? AND ? AND userFk = ?
|
||||
GROUP BY w.userFk,dated`, [date, date, date, myUserId]);
|
||||
|
||||
// 4 Add all the hours and see the total worked
|
||||
for (hour of workedHours) {
|
||||
if (!isOdd)
|
||||
diff += Math.abs((new Date(hour.timed)).getTime() - prevHour.getTime());
|
||||
else
|
||||
prevHour = new Date(hour.timed);
|
||||
|
||||
isOdd = !isOdd;
|
||||
}
|
||||
|
||||
// 5 calculate hours and minutes from a number value
|
||||
let decimalTime = diff / 1000 / 3600;
|
||||
decimalTime = decimalTime * 60 * 60;
|
||||
let hours = Math.floor((decimalTime / (60 * 60)));
|
||||
decimalTime = decimalTime - (hours * 60 * 60);
|
||||
let minutes = Math.floor((decimalTime / 60));
|
||||
|
||||
// 6 default total hours
|
||||
let totalHours = '7:40';
|
||||
let hoursWeek = 40;
|
||||
|
||||
// 7 Get the hours you have to work today and the hours to work in a week
|
||||
if (hoursForDay != null) {
|
||||
// If it exceeds 5 hours we take 20 minutes of breakfast.
|
||||
if (hoursForDay.workingHours > 5)
|
||||
hoursForDay.workingHours -= 20 * 0.016666;
|
||||
let decimalTime = parseFloat(hoursForDay.workingHours);
|
||||
decimalTime = decimalTime * 60 * 60;
|
||||
let hoursDay = Math.floor((decimalTime / (60 * 60)));
|
||||
decimalTime = decimalTime - (hoursDay * 60 * 60);
|
||||
let minutesDay = Math.floor((decimalTime / 60));
|
||||
totalHours = hoursDay + ':' + minutesDay;
|
||||
}
|
||||
|
||||
|
||||
// 8 return value
|
||||
if (hoursForDay != null)
|
||||
hoursWeek = hoursForDay.hoursWeek;
|
||||
return {
|
||||
'name': user.name,
|
||||
'hours': hours,
|
||||
'minutes': minutes,
|
||||
'today': today,
|
||||
'isWorking': !isOdd,
|
||||
'lastDate': prevHour,
|
||||
'totalHours': totalHours,
|
||||
'hoursWeek': hoursWeek
|
||||
};
|
||||
};
|
||||
};
|
|
@ -43,5 +43,11 @@
|
|||
},
|
||||
"WorkerCalendar": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerTimeControl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Device": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/device/checkUuid')(Self);
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(``);
|
||||
return err;
|
||||
});
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "Device",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "device"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number"
|
||||
},
|
||||
"sn": {
|
||||
"type": "String"
|
||||
},
|
||||
"model": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/worker-time-control/addAutoTime')(Self);
|
||||
require('../methods/worker-time-control/getHoursWorked')(Self);
|
||||
require('../methods/worker-time-control/getWorkedWeek')(Self);
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`The introduced hour already exists`);
|
||||
return err;
|
||||
});
|
||||
};
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "WorkerTimeControl",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "workerTimeControl"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number"
|
||||
},
|
||||
"timed": {
|
||||
"type": "Date"
|
||||
},
|
||||
"manual": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"order": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/worker/filter')(Self);
|
||||
require('../methods/worker/getWorkerInfo')(Self);
|
||||
};
|
||||
|
|
|
@ -1505,7 +1505,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": {
|
||||
|
@ -1733,7 +1733,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",
|
||||
|
@ -2321,7 +2321,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",
|
||||
|
@ -2496,7 +2496,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",
|
||||
|
@ -2656,7 +2656,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": {
|
||||
|
@ -3194,13 +3194,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": {
|
||||
|
@ -3211,13 +3211,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": {
|
||||
|
@ -3847,7 +3847,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": {
|
||||
|
@ -4844,7 +4844,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": {
|
||||
|
@ -5907,7 +5907,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",
|
||||
|
@ -6259,7 +6259,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
|
||||
},
|
||||
|
@ -6443,7 +6443,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
|
||||
},
|
||||
|
@ -7458,7 +7458,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"
|
||||
|
@ -7628,7 +7628,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
|
||||
},
|
||||
|
@ -7645,7 +7645,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"
|
||||
|
@ -9690,7 +9690,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": {
|
||||
|
@ -10162,7 +10162,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
|
||||
}
|
||||
|
@ -10792,8 +10792,7 @@
|
|||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
|
@ -10821,7 +10820,6 @@
|
|||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -10836,8 +10834,7 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
|
@ -10848,8 +10845,7 @@
|
|||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -10966,8 +10962,7 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -10979,7 +10974,6 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -10994,7 +10988,6 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -11002,14 +10995,12 @@
|
|||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -11028,7 +11019,6 @@
|
|||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -11109,8 +11099,7 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -11122,7 +11111,6 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -11208,8 +11196,7 @@
|
|||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
|
@ -11245,7 +11232,6 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
@ -11265,7 +11251,6 @@
|
|||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
|
@ -11309,14 +11294,12 @@
|
|||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -11615,7 +11598,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
|
||||
},
|
||||
|
@ -12171,7 +12154,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": {
|
||||
|
@ -12260,7 +12243,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": {
|
||||
|
@ -13151,7 +13134,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": {
|
||||
|
@ -13276,7 +13259,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": {
|
||||
|
@ -13416,7 +13399,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",
|
||||
|
@ -13603,7 +13586,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",
|
||||
|
@ -13654,7 +13637,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"
|
||||
|
@ -14010,7 +13993,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"
|
||||
|
@ -14194,7 +14177,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": {
|
||||
|
@ -15565,7 +15548,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",
|
||||
|
@ -16302,7 +16285,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": {
|
||||
|
@ -16315,7 +16298,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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue