Merge branch 'dev' into 1882-descriptorRefactor

This commit is contained in:
Juan Ferrer 2020-05-19 09:28:50 +02:00
commit d7f2e686b1
72 changed files with 5701 additions and 4703 deletions

View File

@ -1,3 +0,0 @@
ALTER TABLE `vn`.`ticket`
ADD COLUMN `zonePrice` DECIMAL(10,2) NULL DEFAULT NULL AFTER `collectionFk`,
ADD COLUMN `zoneBonus` DECIMAL(10,2) NULL DEFAULT NULL AFTER `zonePrice`;

View File

@ -1,96 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticketCreateWithUser`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`(
vClientId INT
,vShipped DATE
,vWarehouseFk INT
,vCompanyFk INT
,vAddressFk INT
,vAgencyModeFk INT
,vRouteFk INT
,vlanded DATE
,vUserId INT
,OUT vNewTicket INT)
BEGIN
DECLARE vZoneFk INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2);
IF vClientId IS NULL THEN
CALL util.throw ('CLIENT_NOT_ESPECIFIED');
END IF;
IF NOT vAddressFk OR vAddressFk IS NULL THEN
SELECT id INTO vAddressFk
FROM address
WHERE clientFk = vClientId AND isDefaultAddress;
END IF;
IF vAgencyModeFk IS NOT NULL THEN
CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk);
SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
FROM tmp.zoneGetShipped
WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1;
IF vZoneFk IS NULL OR vZoneFk = 0 THEN
CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS');
END IF;
END IF;
INSERT INTO ticket (
clientFk,
shipped,
addressFk,
agencyModeFk,
nickname,
warehouseFk,
routeFk,
companyFk,
landed,
zoneFk,
zonePrice,
zoneBonus
)
SELECT
vClientId,
vShipped,
a.id,
vAgencyModeFk,
a.nickname,
vWarehouseFk,
IF(vRouteFk,vRouteFk,NULL),
vCompanyFk,
vlanded,
vZoneFk,
vPrice,
vBonus
FROM address a
JOIN agencyMode am ON am.id = a.agencyModeFk
WHERE a.id = vAddressFk;
SET vNewTicket = LAST_INSERT_ID();
INSERT INTO ticketObservation(ticketFk, observationTypeFk, description)
SELECT vNewTicket, ao.observationTypeFk, ao.description
FROM addressObservation ao
JOIN address a ON a.id = ao.addressFk
WHERE a.id = vAddressFk;
INSERT INTO vn.ticketLog
SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket);
IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
SELECT id, vNewTicket, getWorker()
FROM state
WHERE `code` = 'DELIVERED';
END IF;
END$$
DELIMITER ;

View File

@ -1,82 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticket_componentUpdate`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentUpdate`(
vTicketFk INT,
vClientFk INT,
vAgencyModeFk INT,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk TINYINT,
vCompanyFk SMALLINT,
vShipped DATETIME,
vLanded DATE,
vIsDeleted BOOLEAN,
vHasToBeUnrouted BOOLEAN,
vOption INT)
BEGIN
DECLARE vPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
UPDATE ticket t
JOIN address a ON a.id = vAddressFk
SET t.nickname = a.nickname
WHERE t.id = vTicketFk;
END IF;
CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk);
SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
FROM tmp.zoneGetShipped
WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1;
UPDATE ticket t
SET
t.clientFk = vClientFk,
t.agencyModeFk = vAgencyModeFk,
t.addressFk = vAddressFk,
t.zoneFk = vZoneFk,
t.zonePrice = vPrice,
t.zoneBonus = vBonus,
t.warehouseFk = vWarehouseFk,
t.companyFk = vCompanyFk,
t.landed = vLanded,
t.shipped = vShipped,
t.isDeleted = vIsDeleted
WHERE
t.id = vTicketFk;
IF vHasToBeUnrouted THEN
UPDATE ticket t SET t.routeFk = NULL
WHERE t.id = vTicketFk;
END IF;
IF vOption <> 8 THEN
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk))
ENGINE = MEMORY
SELECT id AS saleFk, vWarehouseFk warehouseFk
FROM sale s WHERE s.ticketFk = vTicketFk;
CALL ticketComponentUpdateSale (vOption);
DROP TEMPORARY TABLE tmp.sale;
END IF;
COMMIT;
END$$
DELIMITER ;

View File

@ -1,49 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zoneClosure_recalc`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zoneClosure_recalc`()
proc: BEGIN
/**
* Recalculates the delivery time (hour) for every zone in days + scope in future
*/
DECLARE vScope INT;
DECLARE vCounter INT DEFAULT 0;
DECLARE vShipped DATE DEFAULT CURDATE();
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
DO RELEASE_LOCK('vn.zoneClosure_recalc');
RESIGNAL;
END;
IF NOT GET_LOCK('vn.zoneClosure_recalc', 0) THEN
LEAVE proc;
END IF;
SELECT scope INTO vScope
FROM zoneConfig;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
(INDEX (id))
ENGINE = MEMORY
SELECT id FROM zone;
TRUNCATE TABLE zoneClosure;
WHILE vCounter <= vScope DO
CALL zone_getOptionsForShipment(vShipped, TRUE);
INSERT INTO zoneClosure(zoneFk, dated, `hour`)
SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption;
SET vCounter = vCounter + 1;
SET vShipped = TIMESTAMPADD(DAY, 1, vShipped);
END WHILE;
DROP TEMPORARY TABLE tmp.zone;
DO RELEASE_LOCK('vn.zoneClosure_recalc');
END$$
DELIMITER ;

View File

@ -1,62 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_doCalcInitialize`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`()
proc: BEGIN
/**
* Initialize ticket
* si en 01-07-20 aun esta este proc, kkear
*/
DECLARE vDone BOOL;
DECLARE vTicketFk INT;
DECLARE vLanded DATE;
DECLARE vZoneFk INT;
DECLARE cCur CURSOR FOR
SELECT t.id, t.landed, t.zoneFk
FROM ticket t
WHERE (zonePrice IS NULL OR zoneBonus IS NULL)
AND landed >= '2019-01-01' AND shipped >= '2019-01-01'
GROUP BY landed, zoneFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
OPEN cCur;
myLoop: LOOP
SET vDone = FALSE;
FETCH cCur INTO vTicketFk, vLanded, vZoneFk;
IF vDone THEN
LEAVE myLoop;
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
(INDEX (id))
ENGINE = MEMORY
SELECT vZoneFk id;
CALL zone_getOptionsForLanding(vLanded, TRUE);
UPDATE ticket t
LEFT JOIN tmp.zoneOption zo ON TRUE
SET zonePrice = zo.price, zoneBonus = zo.bonus
WHERE t.zoneFk = vZoneFk AND landed = vLanded;
UPDATE ticket t
LEFT JOIN vn.zone z ON z.id = t.zoneFk
SET zonePrice = z.price, zoneBonus = z.bonus
WHERE t.zonePrice IS NULL AND z.id = vZoneFk
AND landed >= '2019-01-01' AND shipped >= '2019-01-01';
END LOOP;
CLOSE cCur;
END$$
DELIMITER ;

View File

@ -1,30 +0,0 @@
USE `util`;
DROP procedure IF EXISTS `procNoOverlap`;
DELIMITER $$
USE `util`$$
CREATE PROCEDURE `procNoOverlap` (procName VARCHAR(255))
SQL SECURITY INVOKER
proc: BEGIN
/**
* call procedure without overlap
*/
DECLARE vIsChanged BOOL;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
DO RELEASE_LOCK(procName);
RESIGNAL;
END;
IF !GET_LOCK(procName, 0) THEN
LEAVE proc;
END IF;
CALL exec(CONCAT('CALL ', procName));
DO RELEASE_LOCK(procName);
END$$
DELIMITER ;

View File

@ -1,66 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_getOptionsForLanding`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN)
BEGIN
/**
* Gets computed options for the passed zones and delivery date.
*
* @table tmp.zones(id) The zones ids
* @param vLanded The delivery date
* @return tmp.zoneOption The computed options
*/
DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
CREATE TEMPORARY TABLE tmp.zoneOption
ENGINE = MEMORY
SELECT
zoneFk,
`hour`,
travelingDays,
price,
bonus,
TIMESTAMPADD(DAY, -travelingDays, vLanded) shipped
FROM (
SELECT t.id zoneFk,
TIME(IFNULL(e.`hour`, z.`hour`)) `hour`,
IFNULL(e.travelingDays, z.travelingDays) travelingDays,
IFNULL(e.price, z.price) price,
IFNULL(e.bonus, z.bonus) bonus
FROM tmp.zone t
JOIN zone z ON z.id = t.id
JOIN zoneEvent e ON e.zoneFk = t.id
WHERE (
e.`type` = 'day'
AND e.dated = vLanded
) OR (
e.`type` != 'day'
AND e.weekDays & (1 << WEEKDAY(vLanded))
AND (e.`started` IS NULL OR vLanded >= e.`started`)
AND (e.`ended` IS NULL OR vLanded <= e.`ended`)
)
ORDER BY
zoneFk,
CASE
WHEN e.`type` = 'day'
THEN 1
WHEN e.`type` = 'range'
THEN 2
ELSE 3
END
) t
GROUP BY zoneFk;
DELETE t FROM tmp.zoneOption t
JOIN zoneExclusion e
ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded;
IF NOT vShowExpiredZones THEN
DELETE FROM tmp.zoneOption
WHERE shipped < CURDATE()
OR (shipped = CURDATE() AND CURTIME() > `hour`);
END IF;
END$$
DELIMITER ;

View File

@ -1,171 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `rutasAnalyze`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT)
BEGIN
/* Analiza los costes de las rutas de reparto y lo almacena en la tabla Rutas_Master
*
* PAK 15/4/2019
*/
DELETE FROM bi.rutasBoard
WHERE year = vYear AND month = vMonth;
-- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales"
INSERT INTO bi.rutasBoard(year,
month,
warehouse_id,
Id_Ruta,
Id_Agencia,
km,
Dia,
Fecha,
Bultos,
Matricula,
Tipo,
Terceros)
SELECT YEAR(r.created),
MONTH(r.created),
GREATEST(1,a.warehouseFk),
r.id,
r.agencyModeFk,
r.kmEnd - r.kmStart,
DAYNAME(r.created),
r.created,
SUM(sv.volume / ebv.m3),
v.numberPlate,
IF(ISNULL(`r`.`cost`), 'P', 'A'),
r.cost
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.agency a ON a.id = am.agencyFk
LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = 71
WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
AND z.isVolumetric
GROUP BY r.id;
-- Rellenamos la tabla con los datos de las rutas NO VOLUMETRICAS, especialmente con los bultos "virtuales"
INSERT INTO bi.rutasBoard(year,
month,
warehouse_id,
Id_Ruta,
Id_Agencia,
km,
Dia,
Fecha,
Bultos,
Matricula,
Tipo,
Terceros)
SELECT YEAR(r.created),
MONTH(r.created),
GREATEST(1,a.warehouseFk),
r.id,
r.agencyModeFk,
r.kmEnd - r.kmStart,
DAYNAME(r.created),
r.created,
SUM(t.packages),
v.numberPlate,
IF(ISNULL(`r`.`cost`), 'P', 'A'),
r.cost
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.agency a ON a.id = am.agencyFk
LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk
WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
AND z.isVolumetric = FALSE
GROUP BY r.id
ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
-- Coste REAL de cada bulto "virtual", de acuerdo con el valor apuntado a mano en la ruta
UPDATE bi.rutasBoard r
INNER JOIN vn2008.Rutas_Master rm ON rm.año = r.year AND rm.mes = r.month AND rm.warehouse_id = r.warehouse_id
SET r.coste_bulto = IF(r.Tipo ='A', r.Terceros, r.km * rm.coste_km ) / r.Bultos
WHERE r.Bultos > 0
AND rm.año = vYear
AND rm.mes = vMonth;
-- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta
UPDATE bi.rutasBoard r
JOIN (
SELECT t.routeFk, sum(s.quantity * sc.value) practicoTotal
FROM vn.route r
JOIN vn.time tm ON tm.dated = r.created
JOIN vn.ticket t ON t.routeFk = r.id
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.`component` c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.type = 'agencia'
AND tm.year = vYear
AND tm.month = vMonth
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta
SET r.practico = sub.practicoTotal / r.Bultos;
-- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc
UPDATE bi.rutasBoard r
JOIN (
SELECT t.routeFk,
SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.time tm ON tm.dated = r.created
JOIN vn.expedition e ON e.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.isBox
JOIN vn.address ad ON ad.id = t.addressFk
JOIN vn.client c ON c.id = ad.clientFk
LEFT JOIN vn.zone z ON z.id = t.zoneFk
WHERE tm.year = vYear
AND tm.month = vMonth
AND z.isVolumetric = FALSE
GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
SET r.teorico = sub.BultoTeoricoMedio;
-- Coste VOLUMETRICO TEORICO de una caja "virtual" para cada ruta
UPDATE bi.rutasBoard r
JOIN (
SELECT t.routeFk,
SUM(freight) AS BultoTeoricoMedio
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.time tm ON tm.dated = r.created
JOIN vn.saleVolume sf ON sf.ticketFk = t.id
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.zone z ON z.id = t.zoneFk
WHERE tm.year = vYear
AND tm.month = vMonth
AND z.isVolumetric != FALSE
GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
SET r.teorico = sub.BultoTeoricoMedio / r.Bultos;
-- La diferencia entre el teorico y el practico se deberia de cobrar en greuges, cada noche
UPDATE bi.rutasBoard r
JOIN (
SELECT t.routeFk,
Sum(g.amount) AS greuge
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.time tm ON tm.dated = r.created
JOIN vn.greuge g ON g.ticketFk = t.id
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
WHERE tm.year = vYear
AND tm.month = vMonth
AND gt.name = 'Diferencia portes'
GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk
SET r.greuge = sub.greuge / r.Bultos;
END$$
DELIMITER ;

View File

@ -1,26 +0,0 @@
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `saleVolume` AS
SELECT
`s`.`ticketFk` AS `ticketFk`,
`s`.`id` AS `saleFk`,
IFNULL(ROUND(((((`i`.`compression` * (GREATEST(`i`.`density`, 167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),
2),
0) AS `litros`,
`t`.`routeFk` AS `routeFk`,
`t`.`shipped` AS `shipped`,
(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,
((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (GREATEST(`i`.`density`, 167) / 167)) / 1000000) AS `physicalWeight`,
(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,
(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,
((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`
FROM
((((`sale` `s`
JOIN `item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
JOIN `ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
JOIN `packaging` `cb` ON ((`cb`.`id` = '94')))
JOIN `itemCost` `ic` ON (((`ic`.`itemFk` = `s`.`itemFk`)
AND (`ic`.`warehouseFk` = `t`.`warehouseFk`))));

View File

@ -1,24 +0,0 @@
DROP VIEW IF EXISTS `vn`.`saleFreight` ;
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `saleFreight__` AS
SELECT
`s`.`ticketFk` AS `ticketFk`,
`t`.`clientFk` AS `clientFk`,
`t`.`routeFk` AS `routeFk`,
`s`.`id` AS `saleFk`,
`t`.`zoneFk` AS `zoneFk`,
`t`.`companyFk` AS `companyFk`,
`t`.`shipped` AS `shipped`,
`t`.`zonePrice` AS `price`,
((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`
FROM
((((`vn`.`sale` `s`
JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
JOIN `vn`.`packaging` `cb` ON ((`cb`.`id` = '94')))
JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`)
AND (`r`.`warehouse_id` = `t`.`warehouseFk`))));

View File

@ -1,43 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_getShippedWarehouse`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
BEGIN
/**
* Devuelve la mínima fecha de envío para cada warehouse
*
* @param vLanded La fecha de recepcion
* @param vAddressFk Id del consignatario
* @param vAgencyModeFk Id de la agencia
* @return tmp.zoneGetShipped
*/
CALL zone_getFromGeo(address_getGeo(vAddressFk));
CALL zone_getOptionsForLanding(vLanded,TRUE);
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
CREATE TEMPORARY TABLE tmp.zoneGetShipped
ENGINE = MEMORY
SELECT * FROM (
SELECT zo.zoneFk,
TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
zo.`hour`,
zw.warehouseFk,
z.agencyModeFk,
zo.price,
zo.bonus
FROM tmp.zoneOption zo
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
JOIN zone z ON z.id = zo.zoneFk
WHERE z.agencyModeFk = vAgencyModeFk
ORDER BY shipped) t
GROUP BY warehouseFk;
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
END$$
DELIMITER ;

View File

@ -1,42 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_getAgency`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAgency`(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 vLanded Fecha de recogida
* @select Listado de agencias disponibles
*/
CALL zone_getFromGeo(address_getGeo(vAddress));
CALL zone_getOptionsForLanding(vLanded, FALSE);
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency;
CREATE TEMPORARY TABLE tmp.zoneGetAgency
(INDEX (agencyModeFk)) ENGINE = MEMORY
SELECT am.name agencyMode,
am.description,
z.agencyModeFk,
am.deliveryMethodFk,
TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
TRUE isIncluded,
zo.zoneFk
FROM tmp.zoneOption zo
JOIN zone z ON z.id = zo.zoneFk
JOIN agencyMode am ON am.id = z.agencyModeFk
GROUP BY agencyModeFk;
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
END$$
DELIMITER ;

View File

@ -1,18 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_getAvailable`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE)
BEGIN
CALL zone_getFromGeo(address_getGeo(vAddress));
CALL zone_getOptionsForLanding(vLanded, FALSE);
SELECT * FROM tmp.zoneOption;
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
END$$
DELIMITER ;

View File

@ -1,41 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `zone_getWarehouse`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
BEGIN
/**
* Devuelve el listado de agencias disponibles para la fecha,
* dirección y almacén pasados.
*
* @param vAddress
* @param vWarehouse warehouse
* @param vLanded Fecha de recogida
* @select Listado de agencias disponibles
*/
CALL zone_getFromGeo(address_getGeo(vAddress));
CALL zone_getOptionsForLanding(vLanded, FALSE);
SELECT am.id agencyModeFk,
am.name agencyMode,
am.description,
am.deliveryMethodFk,
TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
zw.warehouseFk,
z.id zoneFk
FROM tmp.zoneOption zo
JOIN zone z ON z.id = zo.zoneFk
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
WHERE zw.warehouseFk
GROUP BY z.agencyModeFk
ORDER BY agencyMode;
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
END$$
DELIMITER ;

View File

@ -1 +0,0 @@
REPLACE INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('CustomsAgent', '*', '*', 'ALLOW', 'ROLE', 'employee');

View File

@ -1,11 +0,0 @@
CREATE TABLE `vn`.`customsAgent` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fiscalName` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`street` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`nif` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `vn`.`customsAgent`
ADD UNIQUE KEY `nif_UNIQUE` (`nif`);

View File

@ -1,10 +0,0 @@
CREATE TABLE `vn`.`incoterms` (
`code` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Internacional Commercial Terms';
ALTER TABLE `vn`.`incoterms`
ADD PRIMARY KEY (`code`);
REPLACE INTO `vn`.`incoterms` (`code`, `name`) VALUES
('FAS', 'Free Alongside Ship');

View File

@ -1,26 +0,0 @@
ALTER TABLE `vn`.`address`
ADD COLUMN `customsAgentFk` INT NULL DEFAULT NULL AFTER `isEqualizated`;
ALTER TABLE `vn`.`address`
ADD COLUMN `incotermsFk` VARCHAR(3) NULL DEFAULT NULL AFTER `customsAgentFk`;
ALTER TABLE `vn`.`address`
ADD INDEX `address_customsAgentFk_idx` (`customsAgentFk` ASC);
ALTER TABLE `vn`.`address`
ADD INDEX `address_incotermsFk_idx` (`incotermsFk` ASC);
ALTER TABLE `vn`.`address`
ADD CONSTRAINT `address_customsAgentFk`
FOREIGN KEY (`customsAgentFk`)
REFERENCES `vn`.`customsAgent` (`id`)
ON DELETE RESTRICT
ON UPDATE CASCADE;
ALTER TABLE `vn`.`address`
ADD CONSTRAINT `address_incotermsFk`
FOREIGN KEY (`incotermsFk`)
REFERENCES `vn`.`incoterms` (`code`)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -1,5 +0,0 @@
ALTER TABLE `vn`.`ticketUpdateAction`
ADD COLUMN `code` VARCHAR(45) NOT NULL AFTER `description`;
UPDATE `vn`.`ticketUpdateAction` SET `code`='changePrice' WHERE `id`='1';
UPDATE `vn`.`ticketUpdateAction` SET `code`='turnInMana' WHERE `id`='3';

View File

@ -1,2 +0,0 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES ('Intrastat', '*', '*', 'ALLOW', 'ROLE', 'buyer');

View File

@ -1,6 +0,0 @@
ALTER TABLE `vn`.`sample`
ADD COLUMN `hasPreview` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `hasCompany`,
CHANGE COLUMN `isVisible` `isVisible` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' ,
CHANGE COLUMN `hasCompany` `hasCompany` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' ;
UPDATE `vn`.`sample` SET `hasPreview` = '0' WHERE (`id` = '14');

View File

@ -1,2 +0,0 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES ('EntryLog', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');

View File

@ -1,4 +0,0 @@
ALTER TABLE `vn`.`workerDocument`
ADD COLUMN `isReadableByWorker` TINYINT(1) NOT NULL DEFAULT 0 AFTER `document`;
UPDATE `vn`.`workerDocument` SET `isReadableByWorker` = '1' WHERE (`id` = '1');

View File

@ -1,182 +0,0 @@
DROP procedure IF EXISTS `vn`.`workerTimeControl_check`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vTabletFk VARCHAR(100), vTimed DATETIME)
BEGIN
/**
* Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd
* @param vUserFk Identificador del trabajador
* @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
* En caso de tener algun problema retorna el primero que encuentra
*/
DECLARE vLastIn DATETIME ;
DECLARE vLastOut DATETIME ;
DECLARE vDayWorkMax INT;
DECLARE vDayBreak INT;
DECLARE vWeekBreak INT ;
DECLARE vWeekMaxBreak INT;
DECLARE vWeekScope INT;
DECLARE vWeekMaxScope INT;
DECLARE vDayStayMax INT;
DECLARE vAskInOut INT;
DECLARE vTimedWorked INT;
DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
DECLARE vDepartmentFk INT;
DECLARE vTo VARCHAR(50) DEFAULT NULL;
DECLARE vUserName VARCHAR(50) DEFAULT NULL;
DECLARE vBody VARCHAR(255) DEFAULT NULL;
IF (vTimed IS NULL) THEN
SET vTimed = NOW();
END IF;
SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax, weekMaxBreak, weekMaxScope, askInOut
INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax, vWeekMaxBreak, vWeekMaxScope, vAskInOut
FROM vn.workerTimeControlParams;
SELECT MAX(timed) INTO vLastIn
FROM vn.workerTimeControl
WHERE userFk = vUserFk AND
direction = 'in';
SELECT MAX(timed) INTO vLastOut
FROM vn.workerTimeControl
WHERE userFk = vUserFk AND
direction = 'out';
SELECT email INTO vTo
FROM vn.worker w
WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk);
SELECT CONCAT(firstName,' ',lastName) INTO vUserName
FROM vn.worker w
WHERE w.id = vUserFk;
-- VERIFICAR CONTRATO EN VIGOR
IF (SELECT COUNT(*)
FROM postgresql.business b
JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id
JOIN vn.worker w ON w.id = p.id_trabajador
WHERE w.userFk = vUserFk AND
b.date_start <= CURDATE() AND
IFNULL(b.date_end,CURDATE()) >= CURDATE()
) = 0 THEN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw("No hay un contrato en vigor");
END IF;
-- VERIFICAR DEPARTAMENTO
IF vTabletFk IS NOT NULL THEN
IF ( SELECT COUNT(*)
FROM vn.tabletDepartment td
JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk
WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk
) = 0 THEN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw("No perteneces a este departamento.");
END IF;
END IF;
SELECT IFNULL(dayBreak, vDayBreak) INTO vDayBreak
FROM postgresql.business b
JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id
JOIN postgresql. business_labour bl ON b.business_id = bl.business_id
JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id
WHERE p.id_trabajador = vUserFk AND
b.date_start <= DATE(vTimed) AND
IFNULL(b.date_end, DATE(vTimed)) >= DATE(vTimed);
-- VERIFICAR DESCANSO DIARIO
-- 12 / 9 horas dependiendo del valor de vDayBreak
IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vDayBreak/3600,0) ," h") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw(CONCAT("Descansos ", FORMAT(vDayBreak/3600,0) ," h"));
END IF;
-- VERIFICAR FICHADAS IMPARES DEL ÃÆÅ¡LTIMO DÃÆÍA QUE SE FICHÃÆââ¬Å“
IF (SELECT MOD(COUNT(*),2) -- <>0
FROM vn.workerTimeControl
WHERE userFk = vUserFk AND
timed >= vLastIn
) THEN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw("Dias con fichadas impares");
END IF;
-- VERIFICAR VACACIONES
SELECT cs.type INTO vCalendarStateType
FROM postgresql.calendar_employee ce
JOIN postgresql.business b USING(business_id)
JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id
JOIN postgresql.calendar_state cs USING(calendar_state_id)
JOIN vn.worker w ON w.id = p.id_trabajador
WHERE ce.date = CURDATE() AND
cs.isAllowedToWork = FALSE AND
w.userFk = vUserFk
LIMIT 1;
IF(LENGTH(vCalendarStateType)) THEN
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw(vCalendarStateType);
END IF;
-- VERIFICAR DESCANSO SEMANAL
SET @vHasBreakWeek:= FALSE;
SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekScope SECOND));
DROP TEMPORARY TABLE IF EXISTS tmp.trash;
CREATE TEMPORARY TABLE tmp.trash
SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
@vLastTimed:= UNIX_TIMESTAMP(timed)
FROM workerTimeControl
WHERE timed>= (vTimed - INTERVAL vWeekScope SECOND) AND
userFk= vUserFk AND
direction IN ('in','out')
ORDER BY timed ASC;
IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÃÆââ¬Â°S DE LA ÃÆÅ¡LTIMA FICHADA
SET @vHasBreakWeek:= FALSE;
SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekMaxScope SECOND));
DROP TEMPORARY TABLE tmp.trash;
CREATE TEMPORARY TABLE tmp.trash
SELECT IF(vWeekMaxBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
@vLastTimed:= UNIX_TIMESTAMP(timed)
FROM workerTimeControl
WHERE timed>= (vTimed - INTERVAL vWeekMaxScope SECOND) AND
userFk= vUserFk AND
direction IN ('in','out')
ORDER BY timed ASC;
IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekMaxBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÃÆââ¬Â°S DE LA ÃÆÅ¡LTIMA FICHADA
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.throw(CONCAT( "Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h"));
END IF;
-- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekBreak/3600,0) ," h") INTO vBody;
CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
CALL util.warn(CONCAT( "Descansos ", FORMAT(vWeekBreak/3600,0) ," h"));
END IF;
DROP TEMPORARY TABLE tmp.trash;
-- Preguntar direcciÃÆón de la fichada
IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) >= vAskInOut AND (SELECT MOD(COUNT(*),2)
FROM vn.workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn) THEN
CALL util.warn("AskInOut");
END IF ;
END$$
DELIMITER ;

View File

@ -1 +0,0 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('WorkerLog', '*', 'READ', 'ALLOW', 'ROLE', 'hr');

View File

@ -1,6 +0,0 @@
ALTER TABLE `vn`.`workerLog`
ADD COLUMN `changedModel` VARCHAR(45) NULL DEFAULT NULL AFTER `description`,
ADD COLUMN `oldInstance` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
ADD COLUMN `newInstance` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
ADD COLUMN `changedModelId` int(11) DEFAULT NULL,
ADD COLUMN `changedModelValue` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL;

View File

@ -1,108 +0,0 @@
DROP procedure IF EXISTS `vn`.`collectionPlacement_get`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`collectionPlacement_get`(vCollectionFk INT)
BEGIN
DECLARE vCalcFk INT;
DECLARE vWarehouseFk INT;
DECLARE vWarehouseAliasFk INT;
SELECT t.warehouseFk, w.aliasFk
INTO vWarehouseFk, vWarehouseAliasFk
FROM vn.ticket t
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
JOIN vn.warehouse w ON w.id = t.warehouseFk
WHERE tc.collectionFk = vCollectionFk
LIMIT 1;
CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk);
DROP TEMPORARY TABLE IF EXISTS tmp.parked;
CREATE TEMPORARY TABLE tmp.parked
ENGINE MEMORY
SELECT s.itemFk, 0 as quantity
FROM vn.ticketCollection tc
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
WHERE tc.collectionFk = vCollectionFk;
UPDATE tmp.parked pk
JOIN ( SELECT itemFk, sum(visible) as visible
FROM vn.itemShelvingStock iss
JOIN vn.warehouse w ON w.id = iss.warehouseFk
WHERE w.aliasFk = vWarehouseAliasFk
GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk
SET pk.quantity = iss.visible;
DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`;
CREATE TEMPORARY TABLE tmp.`grouping`
ENGINE MEMORY
SELECT itemFk, `grouping`
FROM (
SELECT itemFk,
CASE groupingMode
WHEN 0 THEN 1
WHEN 2 THEN packing
ELSE `grouping`
END AS `grouping`
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWarehouseFk
AND landed BETWEEN (SELECT inventoried FROM vn.config LIMIT 1) AND CURDATE()
AND b.isIgnored = FALSE
ORDER BY tr.landed DESC
) sub
GROUP BY sub.itemFk ;
DROP TEMPORARY TABLE IF EXISTS tmp.grouping2;
CREATE TEMPORARY TABLE tmp.grouping2
ENGINE MEMORY
SELECT * FROM tmp.`grouping`;
SELECT s.id as saleFk, s.itemFk,
p.code COLLATE utf8_general_ci as placement ,
sh.code COLLATE utf8_general_ci as shelving,
ish.created,
ish.visible,
0 as `order`,
IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping`
FROM vn.ticketCollection tc
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk
JOIN tmp.`grouping` g ON g.itemFk = s.itemFk
WHERE tc.collectionFk = vCollectionFk
AND w.aliasFk = vWarehouseAliasFk
AND ish.visible > 0
UNION ALL
SELECT s.id as saleFk, s.itemFk,
ip.code COLLATE utf8_general_ci as placement,
'' COLLATE latin1_general_ci as shelving,
modificationDate as created,
v.visible - p.quantity as visible,
0 as `order`,
g.`grouping`
FROM vn.ticketCollection tc
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk
JOIN tmp.parked p ON p.itemFk = s.itemFk
JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk
LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk
WHERE tc.collectionFk = vCollectionFk
AND v.visible - p.quantity > 0;
DROP TEMPORARY TABLE
tmp.parked,
tmp.`grouping`,
tmp.grouping2;
END
$$
DELIMITER ;

View File

@ -1,39 +0,0 @@
DROP procedure IF EXISTS `vn`.`collection_faults`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`collection_faults`(
vShelvingFk VARCHAR(10),
vQuantity INT,
vItemFk INT)
BEGIN
DECLARE vQuantityTotal INT DEFAULT 0;
DECLARE vshelve VARCHAR(2);
DECLARE vdeep INT(11);
DECLARE vpriority INT(11);
DECLARE vgrouping SMALLINT(5);
DECLARE vpacking INT(11);
DECLARE vpackagingFk VARCHAR(10);
DECLARE vlevel VARCHAR(45);
DECLARE vuserFk INT(10);
SELECT SUM(quantity),shelve,deep,priority,`grouping`,packing,packagingFk,`level`,userFk
INTO vQuantityTotal,vshelve,vdeep,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk
FROM vn.itemShelving
WHERE shelvingFk = vShelvingFk COLLATE utf8mb4_unicode_ci AND itemFk = vItemFk
GROUP BY itemFk;
SELECT vQuantityTotal - vQuantity INTO vQuantityTotal;
DELETE FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8mb4_unicode_ci AND itemFk = vItemFk;
INSERT INTO vn.itemShelving (itemFk, shelvingFk,shelve,deep,quantity,visible,available,priority,`grouping`,packing,packagingFk,`level`,userFk )
VALUES (vItemFk,vShelvingFk,vshelve,vdeep,vQuantityTotal,vQuantityTotal,vQuantityTotal,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk );
SELECT * FROM vn.itemShelving
WHERE shelvingFk = vShelvingFk COLLATE utf8mb4_unicode_ci AND itemFk = vItemFk;
END$$
DELIMITER ;

View File

@ -1,42 +0,0 @@
DROP procedure IF EXISTS `vn`.`collection_updateSale`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`collection_updateSale`(
vSaleFk INT,
vOriginalQuantity INT,
vWorkerFk INT,
vStateFk INT,
vTicketFk INT)
BEGIN
DECLARE vNumPrepared INT;
DECLARE vNumTotal INT;
REPLACE INTO vn.saleTracking(saleFk,isChecked, originalQuantity, workerFk, actionFk,stateFk)
VALUES(vSaleFk,1,vOriginalQuantity,vWorkerFk,vStateFk,vStateFk);
UPDATE vn.sale SET isPicked = 1
WHERE id = vSaleFk;
SELECT COUNT(s.id) INTO vNumPrepared
FROM vn.sale s
WHERE s.ticketFk = vTicketFk AND s.isPicked = 1;
SELECT COUNT(s.id) INTO vNumTotal
FROM vn.sale s
WHERE s.ticketFk = vTicketFk;
IF vNumPrepared = vNumTotal THEN
INSERT INTO vncontrol.inter
SET state_id = vStateFk, Id_Ticket = vTicketFk, Id_Trabajador = vWorkerFk;
CALL vn.collection_update(vTicketFk);
END IF;
END$$
DELIMITER ;

View File

@ -1,13 +0,0 @@
/*DROP view IF EXISTS `vn`.`coolerPathDetail`;
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`coolerPathDetail` AS
SELECT
`c`.`cooler_path_detail_id` AS `id`,
`c`.`cooler_path_id` AS `coolerPathFk`,
`c`.`pasillo` AS `hallway`
FROM
`vn2008`.`cooler_path_detail` `c`*/

View File

@ -1,15 +0,0 @@
DROP procedure IF EXISTS `vn`.`sale_updateOriginalQuantity`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_updateOriginalQuantity`(vSale INT, vQuantity INT)
proc: BEGIN
UPDATE vn.sale SET originalQuantity = vQuantity
WHERE id = vSale;
SELECT * FROM vn.sale WHERE id = vSale;
END$$
DELIMITER ;

View File

@ -1,14 +0,0 @@
DROP procedure IF EXISTS `vn`.`sector_getWarehouse`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sector_getWarehouse`(vSectorFk INT)
BEGIN
SELECT s.warehouseFk
FROM vn.sector s
WHERE s.id = vSectorFk;
END$$
DELIMITER ;

View File

@ -0,0 +1,2 @@
ALTER TABLE `vn`.`claim`
ADD COLUMN `hasToPickUp` TINYINT(1) NOT NULL AFTER `ticketFk`;

View File

@ -0,0 +1,17 @@
ALTER TABLE `vn`.`claimState`
DROP FOREIGN KEY `roleFgn`;
ALTER TABLE `vn`.`claimState`
ADD COLUMN `code` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL AFTER `id`,
CHANGE COLUMN `roleFk` `roleFk` INT(10) UNSIGNED NOT NULL DEFAULT '1' ;
ALTER TABLE `vn`.`claimState`
ADD CONSTRAINT `roleFgn`
FOREIGN KEY (`roleFk`)
REFERENCES `account`.`role` (`id`)
ON UPDATE CASCADE;
UPDATE `vn`.`claimState` SET `code` = 'pending' WHERE (`id` = '1');
UPDATE `vn`.`claimState` SET `code` = 'canceled' WHERE (`id` = '4');
UPDATE `vn`.`claimState` SET `code` = 'resolved' WHERE (`id` = '3');
UPDATE `vn`.`claimState` SET `code` = 'disputed' WHERE (`id` = '5');
UPDATE `vn`.`claimState` SET `code` = 'mana' WHERE (`id` = '6');
UPDATE `vn`.`claimState` SET `code` = 'managed' WHERE (`id` = '2');

View File

@ -0,0 +1,6 @@
ALTER TABLE `vn`.`workerLog`
ADD COLUMN `changedModel` VARCHAR(45) NULL DEFAULT NULL AFTER `description`,
ADD COLUMN `oldInstance` TEXT NULL DEFAULT NULL AFTER `changedModel`,
ADD COLUMN `newInstance` TEXT NULL DEFAULT NULL AFTER `oldInstance`,
ADD COLUMN `changedModelId` INT(11) NULL DEFAULT NULL AFTER `newInstance`,
ADD COLUMN `changedModelValue` VARCHAR(45) NULL DEFAULT NULL AFTER `changedModelId`;

View File

@ -1,3 +1,9 @@
USE `edi`;
DROP procedure IF EXISTS `ekt_load`;
DELIMITER $$
USE `edi`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load`(IN `vSelf` INT)
BEGIN
DECLARE vRef INT;

View File

@ -0,0 +1,10 @@
ALTER TABLE `vn`.`claimState`
ADD COLUMN `priority` INT NOT NULL DEFAULT 1 AFTER `roleFk`;
UPDATE `vn`.`claimState` SET `priority` = '1' WHERE (`id` = '1');
UPDATE `vn`.`claimState` SET `priority` = '5' WHERE (`id` = '2');
UPDATE `vn`.`claimState` SET `priority` = '7' WHERE (`id` = '3');
UPDATE `vn`.`claimState` SET `priority` = '6' WHERE (`id` = '4');
UPDATE `vn`.`claimState` SET `priority` = '3' WHERE (`id` = '5');
UPDATE `vn`.`claimState` SET `priority` = '4' WHERE (`id` = '6');
UPDATE `vn`.`claimState` SET `priority` = '2' WHERE (`id` = '7');

View File

@ -23,7 +23,7 @@ USE `util`;
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
INSERT INTO `config` VALUES (1,'10161',0,'production',NULL);
INSERT INTO `config` VALUES (1,'10170',0,'production',NULL);
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@ -36,7 +36,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:09
-- Dump completed on 2020-05-13 12:18:35
USE `account`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -94,7 +94,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:11
-- Dump completed on 2020-05-13 12:18:36
USE `salix`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -142,7 +142,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:12
-- Dump completed on 2020-05-13 12:18:38
USE `vn`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -287,7 +287,7 @@ UNLOCK TABLES;
LOCK TABLES `state` WRITE;
/*!40000 ALTER TABLE `state` DISABLE KEYS */;
INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1,0),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0,0),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0,0);
INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1,0,4),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0,0,2),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1,0,4),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0,0,4),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0,0,3),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0,3),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0,0,3),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,0,3),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3),(33,'Auto_Impreso',4,1,'PRINTED_AUTO',2,29,1,0,1,0,0,0,2);
/*!40000 ALTER TABLE `state` ENABLE KEYS */;
UNLOCK TABLES;
@ -307,7 +307,7 @@ UNLOCK TABLES;
LOCK TABLES `department` WRITE;
/*!40000 ALTER TABLE `department` DISABLE KEYS */;
INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,46,NULL,72,230,3,11,1,0,0,14,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',47,48,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',49,70,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',71,72,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',73,74,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',75,78,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',79,80,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',81,82,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',83,84,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',85,86,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',87,88,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',89,90,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',91,92,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',93,94,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',95,96,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',97,98,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',99,100,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',50,51,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',101,102,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',103,104,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',76,77,NULL,72,230,4,15,0,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',52,53,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',105,106,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',107,108,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(90,'TRAILER',109,110,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',111,112,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL);
INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,46,NULL,72,230,3,11,1,0,0,14,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',47,48,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',49,72,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL),(44,'GERENCIA',73,74,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',75,76,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',77,80,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',81,82,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',83,84,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',85,86,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',87,88,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',89,90,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',91,92,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',93,94,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',95,96,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',97,98,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',99,100,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',101,102,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',50,51,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',103,104,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',105,106,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',78,79,NULL,72,230,4,15,0,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',52,53,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',107,108,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',109,110,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(90,'TRAILER',111,112,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',113,114,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(115,'EQUIPO CLAUDI',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo');
/*!40000 ALTER TABLE `department` ENABLE KEYS */;
UNLOCK TABLES;
@ -317,7 +317,7 @@ UNLOCK TABLES;
LOCK TABLES `component` WRITE;
/*!40000 ALTER TABLE `component` DISABLE KEYS */;
INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',12,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',11,NULL,NULL,1,'mismatch'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',4,NULL,NULL,1,'freightCharge');
INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',12,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',11,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',4,NULL,NULL,1,'freightCharge');
/*!40000 ALTER TABLE `component` ENABLE KEYS */;
UNLOCK TABLES;
@ -340,7 +340,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:18
-- Dump completed on 2020-05-13 12:18:43
USE `cache`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -378,7 +378,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:19
-- Dump completed on 2020-05-13 12:18:44
USE `hedera`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -436,7 +436,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:21
-- Dump completed on 2020-05-13 12:18:45
USE `postgresql`;
-- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64)
--
@ -511,7 +511,7 @@ UNLOCK TABLES;
LOCK TABLES `workcenter` WRITE;
/*!40000 ALTER TABLE `workcenter` DISABLE KEYS */;
INSERT INTO `workcenter` VALUES (1,'Silla',20,1033,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20008,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2852,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10);
INSERT INTO `workcenter` VALUES (1,'Silla',20,1033,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2852,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL);
/*!40000 ALTER TABLE `workcenter` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@ -524,4 +524,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-16 9:45:23
-- Dump completed on 2020-05-13 12:18:47

View File

@ -39,8 +39,8 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`
FROM `account`.`role` WHERE id <> 20
ORDER BY id;
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`, `email`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9, 'test@nightmare.es'
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
FROM `vn`.`user`;
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
@ -68,13 +68,13 @@ INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,
(111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'),
(112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en');
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `email`)
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`)
VALUES
(106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106, 'test@nightmare.es'),
(107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107, 'test@nightmare.es'),
(108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108, 'test@nightmare.es'),
(109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109, 'test@nightmare.es'),
(110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110, 'test@nightmare.es');
(106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106),
(107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107),
(108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108),
(109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109),
(110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110);
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`)
VALUES
@ -975,10 +975,10 @@ INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
INSERT INTO `vn`.`itemPlacement`(`id`, `itemFk`, `warehouseFk`, `code`)
VALUES
(1, 1, 1, 'A1'),
(2, 1, 2, 'A2'),
(3, 1, 3, 'A3'),
(4, 2, 1, 'A4');
(1, 1, 1, 'A11'),
(2, 1, 2, 'A22'),
(3, 1, 3, 'A33'),
(4, 2, 1, 'A44');
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`)
@ -1473,14 +1473,15 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
(4, 102, 2, CURDATE(), 18, 18, 567),
(5, 102, 3, CURDATE(), 19, 19, 567);
INSERT INTO `vn`.`claimState`(`id`, `description`, `roleFk`)
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`)
VALUES
( 1, 'Pendiente', 1),
( 2, 'Gestionado', 1),
( 3, 'Resuelto', 21),
( 4, 'Anulado', 1),
( 5, 'Cuestionado', 21),
( 6, 'Mana', 1);
( 1, 'pending', 'Pendiente', 1, 1),
( 2, 'managed', 'Gestionado', 1, 5),
( 3, 'resolved', 'Resuelto', 21, 7),
( 4, 'canceled', 'Anulado', 1, 6),
( 5, 'disputed', 'Cuestionado', 21, 3),
( 6, 'mana', 'Mana', 1, 4),
( 7, 'inProgress', 'En Curso', 1, 2);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created` )
VALUES
@ -2039,12 +2040,14 @@ REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `
(1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'),
(2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com');
INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`)
VALUES
('1', 'TEST', 'ON THE FIXTURES', '0'),
('2', 'DEV', 'OTHER TABLET', '0');
INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`)
VALUES
(1, 23),
(2, 1);
INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`)
VALUES
('1', 'TEST', 'ON THE FIXTURES', '0'),
('2', 'DEV', 'OTHER TABLET', '0');

File diff suppressed because it is too large Load Diff

View File

@ -479,7 +479,7 @@ export default {
secondSaleIdInput: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number',
secondSaleConceptCell: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6) > div',
secondSaleConceptCell: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)',
secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield',
totalImport: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
@ -613,7 +613,8 @@ export default {
firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[ng-model="saleClaimed.claimDestinationFk"]',
secondLineDestination: 'vn-claim-action vn-tr:nth-child(2) vn-autocomplete[ng-model="saleClaimed.claimDestinationFk"]',
firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]',
hasToPickUpCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.hasToPickUp"]'
},
ordersIndex: {
searchResult: 'vn-order-index vn-card > vn-table > div > vn-tbody > a.vn-tr',

View File

@ -21,7 +21,7 @@ describe('Item create niche path', () => {
await page.waitToClick(selectors.itemNiches.addNicheButton);
await page.waitToClick(selectors.itemNiches.secondNicheRemoveButton);
await page.autocompleteSearch(selectors.itemNiches.thirdWarehouse, 'Warehouse Two');
await page.write(selectors.itemNiches.thirdCode, 'A4');
await page.write(selectors.itemNiches.thirdCode, 'A44');
await page.waitToClick(selectors.itemNiches.submitNichesButton);
const message = await page.waitForSnackbar();
@ -39,7 +39,7 @@ describe('Item create niche path', () => {
result = await page
.waitToGetProperty(selectors.itemNiches.firstCode, 'value');
expect(result).toEqual('A1');
expect(result).toEqual('A11');
});
it(`should confirm the second niche is the expected one`, async() => {
@ -50,7 +50,7 @@ describe('Item create niche path', () => {
result = await page
.waitToGetProperty(selectors.itemNiches.secondCode, 'value');
expect(result).toEqual('A3');
expect(result).toEqual('A33');
});
it(`should confirm the third niche is the expected one`, async() => {
@ -61,6 +61,6 @@ describe('Item create niche path', () => {
result = await page
.waitToGetProperty(selectors.itemNiches.thirdCode, 'value');
expect(result).toEqual('A4');
expect(result).toEqual('A44');
});
});

View File

@ -79,9 +79,8 @@ describe('Ticket List sale path', () => {
expect(message.type).toBe('success');
});
// #1865
xit('should update the description of the new sale', async() => {
await page.focusElement(selectors.ticketSales.secondSaleConceptCell);
it('should update the description of the new sale', async() => {
await page.click(selectors.ticketSales.secondSaleConceptCell);
await page.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor');
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();

View File

@ -66,17 +66,25 @@ describe('Claim action path', () => {
});
it('should check the "is paid with mana" checkbox', async() => {
page.waitFor(3000); // can't use waitForNavigation here and needs more time than a single second to get the section ready...
await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox);
const message = await page.waitForSnackbar();
expect(message.type).toBe('success');
});
it('should confirm the "is paid with mana" checkbox is checked', async() => {
await page.reloadSection('claim.card.action');
const result = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
it('should check the "Pick up" checkbox', async() => {
await page.waitToClick(selectors.claimAction.hasToPickUpCheckbox);
const message = await page.waitForSnackbar();
expect(result).toBe('checked');
expect(message.type).toBe('success');
});
it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => {
await page.reloadSection('claim.card.action');
const isPaidWithManaCheckbox = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
const hasToPickUpCheckbox = await page.checkboxState(selectors.claimAction.hasToPickUpCheckbox);
expect(isPaidWithManaCheckbox).toBe('checked');
expect(hasToPickUpCheckbox).toBe('checked');
});
});

View File

@ -35,7 +35,7 @@ describe('Order lines', () => {
const result = await page
.waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText');
expect(result).toContain('90.10');
expect(result).toContain('80.54');
});
it('should confirm the whole order and redirect to ticket index filtered by clientFk', async() => {

View File

@ -47,7 +47,7 @@ export default class Range extends FormInput {
}
onValueUpdate() {
this.change(this.input.value);
this.change(parseInt(this.input.value));
this.$.$applyAsync();
}
}

View File

@ -47,7 +47,7 @@ export default class Tooltip extends Component {
}
/**
* Repositions the tooltip acording to it's own size and parent location.
* Repositions the tooltip acording to it's own size, position and parent location.
*/
relocate() {
let axis;

View File

@ -2,119 +2,154 @@ import './tooltip';
describe('Component vnTooltip', () => {
let $element;
let controller;
let tooltip;
let tooltipCtrl;
let $parent;
let element;
let window;
beforeEach(ngModule('vnCore'));
beforeEach(inject(($componentController, $compile, $templateRequest, $document) => {
$element = angular.element(`<vn-tooltip class="text">test</span></vn-tooltip>`);
beforeEach(inject(($rootScope, $compile, $document) => {
let scope = $rootScope.$new();
$element = $compile(`<vn-tooltip class="text">test</span></vn-tooltip>`)(scope);
$document.find('body').append($element);
controller = $componentController('vnTooltip', {$document, $compile, $templateRequest, $element});
element = $element[0];
window = controller.window;
tooltip = $element[0];
tooltipCtrl = tooltip.$ctrl;
window = tooltipCtrl.window;
$parent = angular.element('<div/>');
$parent.css({
backgroundColor: 'red',
position: 'absolute',
width: '100px',
height: '100px',
top: '0',
left: '0'
});
$document.find('body').append($parent);
}));
afterEach(() => {
$element.remove();
$parent.remove();
});
$document.find('body').append($parent);
$parent[0].getBoundingClientRect = () => {};
jest.spyOn(tooltip, 'getBoundingClientRect').mockReturnValue({bottom: 0, height: 40, left: 0, right: 0, top: 0, width: 40});
}));
describe('show()', () => {
it(`should check that tooltip is visible into the screen`, () => {
expect(element.classList).not.toContain('show');
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: window.innerHeight - 120,
width: window.innerWidth - 120,
top: 60,
left: 60,
});
controller.show($parent[0]);
expect(tooltip.classList).not.toContain('show');
let rect = element.getBoundingClientRect();
tooltipCtrl.show($parent[0]);
expect(element.classList).toContain('show');
let tooltipStyle = tooltip.style;
expect(0).toBeLessThanOrEqual(rect.top);
expect(0).toBeLessThanOrEqual(rect.left);
expect(window.innerHeight).toBeGreaterThan(rect.bottom);
expect(window.innerWidth).toBeGreaterThan(rect.right);
let tooltipTop = parseInt(tooltipStyle['top']);
let tooltipLeft = parseInt(tooltipStyle['left']);
expect(tooltip.classList).toContain('show');
expect(tooltipTop).toBeLessThanOrEqual(window.innerHeight);
expect(tooltipTop).toBeGreaterThanOrEqual(0);
expect(tooltipLeft).toBeLessThanOrEqual(window.innerWidth);
expect(tooltipLeft).toBeGreaterThanOrEqual(0);
});
});
describe('hide()', () => {
it(`should check that tooltip is not visible`, () => {
controller.show($parent[0]);
it('should check that tooltip is not visible', () => {
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: window.innerHeight,
width: window.innerWidth - 80,
top: 0,
left: 60,
});
tooltipCtrl.show($parent[0]);
expect(element.classList).toContain('show');
controller.hide();
expect(tooltip.classList).toContain('show');
tooltipCtrl.hide();
expect(element.classList).not.toContain('show');
expect(tooltip.classList).not.toContain('show');
});
});
// #1892 reparar unitarios front tooltip.js
xdescribe('relocate()', () => {
it(`should reallocate tooltip on top-left`, () => {
controller.show($parent[0]);
let rect = element.getBoundingClientRect();
describe('relocate()', () => {
it('should reallocate tooltip to the left', () => {
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: window.innerHeight,
width: window.innerWidth - 80,
top: 0,
left: 60,
});
expect(controller.margin).toBeLessThan(rect.top);
expect(controller.margin).toEqual(rect.left);
tooltipCtrl.position = 'left';
tooltipCtrl.show($parent[0]);
let tooltipStyle = tooltip.style;
let tooltipTop = parseInt(tooltipStyle['top']);
let tooltipLeft = parseInt(tooltipStyle['left']);
expect(tooltipTop).toEqual((window.innerHeight / 2) - (tooltipCtrl.margin * 2));
expect(tooltipLeft).toEqual(tooltipCtrl.margin);
});
it(`should reallocate tooltip on bottom-left`, () => {
$parent.css({
top: `${window.innerHeight}px`
it('should reallocate tooltip on bottom', () => {
let parentHeight = window.innerHeight - 80;
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: parentHeight,
width: window.innerWidth,
top: 0,
left: 0,
});
controller.show($parent[0]);
let rect = element.getBoundingClientRect();
expect(window.innerHeight).toBeGreaterThan(rect.top);
expect(controller.margin).toEqual(rect.left);
tooltipCtrl.position = 'bottom';
tooltipCtrl.show($parent[0]);
let tooltipStyle = tooltip.style;
let tooltipTop = parseInt(tooltipStyle['top']);
let tooltipLeft = parseInt(tooltipStyle['left']);
expect(tooltipLeft).toEqual((window.innerWidth / 2) - (tooltipCtrl.margin * 2));
expect(tooltipTop).toEqual(parentHeight + tooltipCtrl.margin);
});
it(`should reallocate tooltip on bottom-right`, () => {
$parent.css({
top: `${window.innerHeight}px`,
left: `${window.innerWidth}px`
it(`should reallocate tooltip on right`, () => {
let parentWidth = window.innerWidth - 80;
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: window.innerHeight,
width: parentWidth,
top: 0,
left: 0,
});
controller.show($parent[0]);
let rect = element.getBoundingClientRect();
expect(window.innerWidth).toBeGreaterThan(rect.left);
expect(window.innerWidth - controller.margin).toEqual(rect.right);
tooltipCtrl.position = 'right';
tooltipCtrl.show($parent[0]);
let tooltipStyle = tooltip.style;
let tooltipTop = parseInt(tooltipStyle['top']);
let tooltipLeft = parseInt(tooltipStyle['left']);
expect(tooltipLeft).toEqual(parentWidth + tooltipCtrl.margin);
expect(tooltipTop).toEqual((window.innerHeight / 2) - (tooltipCtrl.margin * 2));
});
it(`should reallocate tooltip on top-right`, () => {
$parent.css({
left: `${window.innerWidth}px`
it(`should reallocate tooltip on top`, () => {
jest.spyOn($parent[0], 'getBoundingClientRect').mockReturnValue({
height: window.innerHeight - 80,
width: window.innerWidth,
top: 60,
left: 0,
});
controller.show($parent[0]);
let rect = element.getBoundingClientRect();
expect(controller.margin).toBeLessThan(rect.top);
expect(window.innerWidth - controller.margin).toEqual(rect.right);
});
tooltipCtrl.position = 'top';
tooltipCtrl.show($parent[0]);
it(`should reallocate tooltip on center`, () => {
$parent.css({
top: `${window.window.innerHeight / 2}px`,
left: `${window.window.innerWidth / 2}px`
});
controller.show($parent[0]);
let rect = element.getBoundingClientRect();
let tooltipStyle = tooltip.style;
expect(window.innerHeight / 2).toBeLessThan(rect.top);
expect(window.innerWidth / 2).toBeGreaterThan(rect.left);
let tooltipTop = parseInt(tooltipStyle['top']);
let tooltipLeft = parseInt(tooltipStyle['left']);
expect(tooltipLeft).toEqual((window.innerWidth / 2) - (tooltipCtrl.margin * 2));
expect(tooltipTop).toEqual(tooltipCtrl.margin);
});
});
});

View File

@ -1,8 +1,9 @@
describe('Currency filter', () => {
beforeEach(ngModule('vnCore'));
let currencyFilter;
beforeEach(inject(_currencyFilter_ => {
beforeEach(inject((_currencyFilter_, $translate) => {
currencyFilter = _currencyFilter_;
jest.spyOn($translate, 'use').mockReturnValue('en-US');
}));
it('should return a ONE decimal number as per the argument', () => {

View File

@ -8,7 +8,7 @@ describe('Model rewriteDbError()', () => {
});
it('should handle a duplicated warehouse error', async() => {
let itemNiche = {itemFk: 1, warehouseFK: 1, code: 'A1'};
let itemNiche = {itemFk: 1, warehouseFK: 1, code: 'A11'};
let error;
await app.models.ItemNiche.create(itemNiche).catch(e => {
error = e;

View File

@ -62,6 +62,7 @@
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*",
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})",
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Claim will be picked": "The product from the claim (#{{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
"This ticket is not an stowaway anymore": "The ticket id [#{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",

View File

@ -125,6 +125,7 @@
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*",
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Claim will be picked": "Se recogerá el género de la reclamación (#{{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
"This ticket is not an stowaway anymore": "El ticket id [#{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",

View File

@ -114,7 +114,6 @@ module.exports = Self => {
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk`
);
stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1;

View File

@ -3,21 +3,22 @@ module.exports = Self => {
description: 'Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company',
accessType: 'WRITE',
accepts: [{
arg: 'params',
type: 'object',
http: {source: 'body'}
arg: 'id',
type: 'number',
description: 'The claim id',
http: {source: 'path'}
}],
returns: {
type: ['Object'],
root: true
},
http: {
path: `/regularizeClaim`,
path: `/:id/regularizeClaim`,
verb: 'POST'
}
});
Self.regularizeClaim = async(ctx, params) => {
Self.regularizeClaim = async(ctx, claimFk) => {
const models = Self.app.models;
const $t = ctx.req.__; // $translate
const resolvedState = 3;
@ -31,7 +32,7 @@ module.exports = Self => {
relation: 'claimDestination',
fields: ['addressFk']
},
where: {claimFk: params.claimFk}
where: {claimFk: claimFk}
}, options);
for (let i = 0; i < claimEnds.length; i++) {
@ -87,11 +88,32 @@ module.exports = Self => {
}, options);
}
let claim = await Self.findById(params.claimFk, null, options);
let claim = await Self.findById(claimFk, {
include: {
relation: 'client',
scope: {
include: {
relation: 'salesPerson'
}
}
}
}, options);
claim = await claim.updateAttributes({
claimStateFk: resolvedState
}, options);
// Get sales person from claim client
const salesPerson = claim.client().salesPerson();
if (salesPerson && claim.hasToPickUp) {
const origin = ctx.req.headers.origin;
const message = $t('Claim will be picked', {
claimId: claim.id,
clientName: claim.client().name,
claimUrl: `${origin}/#!/claim/${claim.id}/summary`
});
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
}
await tx.commit();
return claim;

View File

@ -12,7 +12,10 @@ describe('regularizeClaim()', () => {
afterAll(async done => {
let claim = await app.models.Claim.findById(claimFk);
await claim.updateAttributes({claimStateFk: pendentState});
await claim.updateAttributes({
claimStateFk: pendentState,
hasToPickUp: false
});
await app.models.Ticket.destroyById(trashTicket.id);
claimEnds.forEach(async line => {
@ -33,7 +36,6 @@ describe('regularizeClaim()', () => {
return params.nickname;
};
let params = {claimFk: claimFk};
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
@ -46,9 +48,9 @@ describe('regularizeClaim()', () => {
claimEnd.updateAttributes({claimDestinationFk: trashDestination});
});
let claimBefore = await app.models.Claim.findById(params.claimFk);
await app.models.Claim.regularizeClaim(ctx, params);
let claimAfter = await app.models.Claim.findById(params.claimFk);
let claimBefore = await app.models.Claim.findById(claimFk);
await app.models.Claim.regularizeClaim(ctx, claimFk);
let claimAfter = await app.models.Claim.findById(claimFk);
trashTicket = await app.models.Ticket.findOne({where: {addressFk: 12}});
@ -70,7 +72,6 @@ describe('regularizeClaim()', () => {
return params.nickname;
};
let params = {claimFk: claimFk};
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
@ -78,9 +79,35 @@ describe('regularizeClaim()', () => {
claimEnd.updateAttributes({claimDestinationFk: okDestination});
});
await app.models.Claim.regularizeClaim(ctx, params);
await app.models.Claim.regularizeClaim(ctx, claimFk);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
});
it('should send a chat message to the salesPerson when claim isPickUp is enabled', async() => {
const ctx = {
req: {
accessToken: {userId: 18},
headers: {origin: 'http://localhost'}
}
};
ctx.req.__ = (value, params) => {
return params.nickname;
};
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
claimEnds.forEach(async claimEnd => {
claimEnd.updateAttributes({claimDestinationFk: okDestination});
});
const claim = await app.models.Claim.findById(claimFk);
await claim.updateAttribute('hasToPickUp', true);
await app.models.Claim.regularizeClaim(ctx, claimFk);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(5);
});
});

View File

@ -26,16 +26,16 @@ describe('Update Claim', () => {
});
it('should update the claim isChargedToMana attribute', async() => {
const data = {isChargedToMana: false};
const result = await app.models.Claim.updateClaimAction(newInstance.id, data);
const ctx = {args: {isChargedToMana: false}};
const result = await app.models.Claim.updateClaimAction(ctx, newInstance.id);
expect(result.id).toEqual(newInstance.id);
expect(result.isChargedToMana).toBeFalsy();
});
it('should update the claim responsibility attribute', async() => {
const data = {responsibility: 2};
const result = await app.models.Claim.updateClaimAction(newInstance.id, data);
const ctx = {args: {responsibility: 2}};
const result = await app.models.Claim.updateClaimAction(ctx, newInstance.id);
expect(result.id).toEqual(newInstance.id);
expect(result.responsibility).toEqual(2);

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethod('updateClaimAction', {
Self.remoteMethodCtx('updateClaimAction', {
description: 'Update a claim with privileges',
accessType: 'WRITE',
accepts: [{
@ -10,11 +10,17 @@ module.exports = Self => {
description: 'Claim id',
http: {source: 'path'}
}, {
arg: 'data',
type: 'object',
required: true,
description: 'Data to update on the model',
http: {source: 'body'}
arg: 'responsibility',
type: 'number',
required: false
}, {
arg: 'isChargedToMana',
type: 'boolean',
required: false
}, {
arg: 'hasToPickUp',
type: 'boolean',
required: false
}],
returns: {
type: 'object',
@ -22,22 +28,16 @@ module.exports = Self => {
},
http: {
path: `/:id/updateClaimAction`,
verb: 'post'
verb: 'patch'
}
});
Self.updateClaimAction = async(id, data) => {
let models = Self.app.models;
Self.updateClaimAction = async(ctx, id) => {
const models = Self.app.models;
const claim = await models.Claim.findById(id);
const args = ctx.args;
delete args.ctx;
let claim = await models.Claim.findById(id);
let updatedData = {};
if (data.hasOwnProperty('responsibility'))
updatedData.responsibility = data.responsibility;
if (data.hasOwnProperty('isChargedToMana'))
updatedData.isChargedToMana = data.isChargedToMana;
return await claim.updateAttributes(updatedData);
return await claim.updateAttributes(args);
};
};

View File

@ -12,9 +12,17 @@
"id": true,
"description": "Identifier"
},
"code": {
"type": "String",
"required": true
},
"description": {
"type": "String",
"required": true
},
"priority": {
"type": "nomber",
"required": true
}
},
"relations": {

View File

@ -13,7 +13,7 @@
"description": "Identifier"
},
"observation": {
"type": "String"
"type": "string"
},
"ticketCreated": {
"type": "date",
@ -26,16 +26,19 @@
"type": "date"
},
"responsibility": {
"type": "Number"
"type": "number"
},
"hasToPickUp": {
"type": "boolean"
},
"ticketFk": {
"type": "Number"
"type": "number"
},
"claimStateFk": {
"type": "Number"
"type": "number"
},
"workerFk": {
"type": "Number"
"type": "number"
}
},
"relations": {

View File

@ -1,6 +1,7 @@
<vn-crud-model vn-id="model"
url="ClaimEnds"
filter="$ctrl.filter"
link="{claimFk: $ctrl.$params.id}"
data="$ctrl.salesClaimed"
auto-load="true"
auto-save="true"
@ -21,13 +22,13 @@
<vn-tool-bar class="vn-mb-md">
<vn-button
label="Import claim"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
vn-http-click="$ctrl.importToNewRefundTicket()"p
translate-attr="{title: 'Imports claim details'}">
</vn-button>
<vn-button
label="Import ticket"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
ng-click="$ctrl.showLastTickets($event)"
translate-attr="{title: 'Imports ticket lines'}">
</vn-button>
@ -39,15 +40,18 @@
max="$ctrl.maxResponsibility"
min="1"
step="1"
vn-acl="salesAssistant"
on-change="$ctrl.saveResponsibility(value)">
on-change="$ctrl.save({responsibility: value})">
</vn-range>
</vn-tool-bar>
<vn-check vn-one class="vn-mr-md"
label="Pick up"
ng-model="$ctrl.claim.hasToPickUp"
on-change="$ctrl.save({hasToPickUp: value})">
</vn-check>
<vn-check vn-one
label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant"
on-change="$ctrl.saveMana(value)">
on-change="$ctrl.save({isChargedToMana: value})">
</vn-check>
</section>
<vn-data-viewer model="model">
@ -83,7 +87,7 @@
{{::saleClaimed.sale.ticketFk}}
</span>
</vn-td>
<vn-td>
<vn-td expand>
<vn-autocomplete vn-one id="claimDestinationFk"
ng-model="saleClaimed.claimDestinationFk"
data="claimDestinations"
@ -105,7 +109,7 @@
<vn-icon-button
vn-tooltip="Remove line"
icon="delete"
ng-click="$ctrl.deleteClaimedSale(saleClaimed.id)"
ng-click="model.remove($index)"
tabindex="-1">
</vn-icon-button>
</vn-td>
@ -116,46 +120,11 @@
<vn-button-bar>
<vn-button
label="Regularize"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
vn-http-click="$ctrl.regularize()">
</vn-button>
</vn-button-bar>
</vn-card>
<!-- Add Lines Dialog -->
<vn-dialog vn-id="addSales">
<tpl-body>
<h3 translate>Claimable sales from ticket</h3><h3> {{$ctrl.claim.ticketFk}}</h3>
<vn-table>
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th>Landed</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Disc.</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr
ng-repeat="sale in $ctrl.salesToClaim"
class="clickable"
ng-click="$ctrl.addClaimedSale(sale.saleFk)">
<vn-td number>{{sale.saleFk}}</vn-td>
<vn-td>{{sale.landed | date: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{sale.quantity}}</vn-td>
<vn-td expand>{{sale.concept}}</vn-td>
<vn-td number>{{sale.price | currency: 'EUR':2}}</vn-td>
<vn-td number>{{sale.discount}} %</vn-td>
<vn-td number>
{{sale.quantity * sale.price * ((100 - sale.discount) * / 100) | currency: 'EUR':2}}
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</tpl-body>
</vn-dialog>
<vn-crud-model
vn-id="lastTicketsModel"
url="Tickets"

View File

@ -6,7 +6,6 @@ export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
where: {claimFk: this.$params.id},
include: [
{relation: 'sale',
scope: {
@ -20,46 +19,29 @@ export default class Controller extends Section {
{relation: 'claimDestination'}
]
};
this.resolvedState = 3;
this.getResolvedState();
this.maxResponsibility = 5;
}
openAddSalesDialog() {
this.getClaimedSales();
this.$.addSales.show();
}
getClaimedSales() {
let query = `ClaimBeginnings/${this.claim.id}`;
this.$http.get(query).then(res => {
if (res.data)
this.claimedSales = res.data;
});
}
addClaimedSale(saleFk) {
let saleToAdd = {saleFk: saleFk, claimFk: this.claim.id, workerFk: this.claim.workerFk, claimDestinationFk: 1};
let query = `ClaimEnds/`;
this.$http.post(query, saleToAdd).then(() => {
this.$.model.refresh();
this.$.addSales.hide();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
deleteClaimedSale(id) {
let query = `ClaimEnds/${id}`;
this.$http.delete(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
getResolvedState() {
const query = `ClaimStates/findOne`;
const params = {
filter: {
where: {
code: 'resolved'
}
}
};
this.$http.get(query, params).then(res =>
this.resolvedStateId = res.data.id
);
}
importToNewRefundTicket() {
let query = `ClaimBeginnings/${this.$params.id}/importToNewRefundTicket`;
return this.$http.post(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
@ -72,7 +54,9 @@ export default class Controller extends Section {
calculateTotals() {
this.claimedTotal = 0;
this.salesClaimed.forEach(sale => {
this.claimedTotal += (sale.sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100);
const price = sale.sale.quantity * sale.sale.price;
const discount = (sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100;
this.claimedTotal += price - discount;
});
}
@ -101,20 +85,19 @@ export default class Controller extends Section {
let query = `ClaimEnds/importTicketSales`;
this.$http.post(query, data).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showSuccess(this.$t('Data saved!'));
this.$.lastTicketsPopover.hide();
this.$.model.refresh();
});
}
regularize() {
let data = {claimFk: this.$params.id};
let query = `Claims/regularizeClaim`;
return this.$http.post(query, data).then(() => {
const query = `Claims/${this.$params.id}/regularizeClaim`;
return this.$http.post(query).then(() => {
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)
this.$.updateGreuge.show();
else
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showSuccess(this.$t('Data saved!'));
this.card.reload();
});
@ -148,7 +131,7 @@ export default class Controller extends Section {
return Promise.all(promises).then(() => {
const data = {
clientFk: this.claim.clientFk,
description: this.$translate.instant('ClaimGreugeDescription', {
description: this.$t('ClaimGreugeDescription', {
claimId: this.claim.id
}).toUpperCase(),
amount: this.freightPickUpPrice,
@ -156,32 +139,22 @@ export default class Controller extends Section {
ticketFk: this.claim.ticketFk
};
return this.$http.post(`Greuges/`, data).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showMessage(this.$translate.instant('Greuge inserted'));
this.vnApp.showSuccess(this.$t('Data saved!'));
this.vnApp.showMessage(this.$t('Greuge inserted'));
});
});
} else
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showSuccess(this.$t('Data saved!'));
}
saveResponsibility(value) {
let query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.post(query, {responsibility: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
saveMana(value) {
let query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.post(query, {isChargedToMana: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
save(data) {
const query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.patch(query, data)
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
onSave() {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.vnApp.showSuccess(this.$t('Data saved!'));
}
}

View File

@ -32,56 +32,16 @@ describe('claim', () => {
show: () => {}
};
controller.card = {reload: () => {}};
$httpBackend.expectGET(`ClaimStates/findOne`).respond({});
}));
describe('openAddSalesDialog()', () => {
it('should call getClaimableFromTicket and $.addSales.show', () => {
controller.$ = {addSales: {show: () => {}}};
jest.spyOn(controller, 'getClaimedSales');
jest.spyOn(controller.$.addSales, 'show');
controller.openAddSalesDialog();
expect(controller.getClaimedSales).toHaveBeenCalledWith();
expect(controller.$.addSales.show).toHaveBeenCalledWith();
});
});
describe('getClaimedSales()', () => {
it('should make a query and set salesToClaim', () => {
controller.claim.id = 1;
$httpBackend.expectGET(`ClaimBeginnings/1`).respond(200, 1);
controller.getClaimedSales();
describe('getResolvedState()', () => {
it('should return the resolved state id', () => {
$httpBackend.expectGET(`ClaimStates/findOne`).respond({id: 1});
controller.getResolvedState();
$httpBackend.flush();
expect(controller.claimedSales).toEqual(1);
});
});
describe('addClaimedSale(saleFk)', () => {
it('should make a post and call refresh, hide and showSuccess', () => {
jest.spyOn(controller.$.model, 'refresh');
jest.spyOn(controller.$.addSales, 'hide');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`ClaimEnds/`).respond({});
controller.addClaimedSale(1);
$httpBackend.flush();
expect(controller.$.model.refresh).toHaveBeenCalledWith();
expect(controller.$.addSales.hide).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
});
});
describe('deleteClaimedSale(id)', () => {
it('should make a delete and call refresh and showSuccess', () => {
jest.spyOn(controller.$.model, 'refresh');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectDELETE(`ClaimEnds/1`).respond({});
controller.deleteClaimedSale(1);
$httpBackend.flush();
expect(controller.$.model.refresh).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
expect(controller.resolvedStateId).toEqual(1);
});
});
@ -102,6 +62,7 @@ describe('claim', () => {
it('should perform a post query and add lines from a new ticket', () => {
jest.spyOn(controller.$.model, 'refresh');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('POST', `ClaimBeginnings/1/importToNewRefundTicket`).respond({});
controller.importToNewRefundTicket();
$httpBackend.flush();
@ -115,6 +76,7 @@ describe('claim', () => {
it('should get a list of tickets and call lastTicketsPopover show() method', () => {
jest.spyOn(controller.$.lastTicketsModel, 'refresh');
jest.spyOn(controller.$.lastTicketsPopover, 'show');
controller.showLastTickets({});
expect(controller.$.lastTicketsModel.refresh).toHaveBeenCalledWith();
@ -127,6 +89,7 @@ describe('claim', () => {
jest.spyOn(controller.$.model, 'refresh');
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.$.lastTicketsPopover, 'hide');
let data = {claimFk: 1, ticketFk: 1};
$httpBackend.expect('POST', `ClaimEnds/importTicketSales`, data).respond({});
controller.importTicketLines(1);
@ -143,8 +106,7 @@ describe('claim', () => {
jest.spyOn(controller.card, 'reload');
jest.spyOn(controller.vnApp, 'showSuccess');
let data = {claimFk: $state.params.id};
$httpBackend.expect('POST', `Claims/regularizeClaim`, data).respond({});
$httpBackend.expect('POST', `Claims/1/regularizeClaim`).respond({});
controller.regularize();
$httpBackend.flush();
@ -153,6 +115,19 @@ describe('claim', () => {
});
});
describe('save()', () => {
it('should perform a patch query and show a success message', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
const data = {hasToPickUp: true};
$httpBackend.expect('PATCH', `Claims/1/updateClaimAction`, data).respond({});
controller.save(data);
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
});
});
describe('onUpdateGreugeResponse()', () => {
const greugeTypeId = 7;
const freightPickUpPrice = 11;

View File

@ -10,3 +10,4 @@ Do you want to insert greuges?: Desea insertar greuges?
Insert greuges on client card: Insertar greuges en la ficha del cliente
Greuge inserted: Greuge insertado
ClaimGreugeDescription: Reclamación id {{claimId}}
Pick up: Recoger

View File

@ -40,6 +40,7 @@
show-field="description"
value-field="id"
label="Claim state"
order="priority ASC"
vn-focus>
</vn-autocomplete>
</vn-horizontal>

View File

@ -2,7 +2,7 @@
vn-id="model"
url="Claims/filter"
limit="20"
order="claimStateFk ASC, created DESC"
order="priority ASC, created DESC"
auto-load="true">
</vn-crud-model>
<vn-portal slot="topbar">

View File

@ -34,7 +34,12 @@
value="{{$ctrl.client.creditInsurance | currency: 'EUR': 2}}">
</vn-label-value>
<vn-label-value
label="Sales person"
label="Risk"
value="{{$ctrl.client.debt | currency: 'EUR':2}}"
ng-class="{alert: $ctrl.client.debt > $ctrl.client.credit}"
info="Invoices minus payments plus orders not yet invoiced">
</vn-label-value>
<vn-label-value label="Sales person"
value="{{$ctrl.client.salesPerson.user.nickname}}">
</vn-label-value>
</div>

View File

@ -32,6 +32,14 @@
</vn-label-value>
</vn-item-section>
<vn-item-section side>
<vn-icon-button ng-show="client.isActive == false"
vn-tooltip="Client inactive"
icon="icon-disabled">
</vn-icon-button>
<vn-icon-button ng-show="client.isActive && client.isFreezed == true"
vn-tooltip="Client frozen"
icon="icon-frozen">
</vn-icon-button>
<vn-icon-button
ng-click="$ctrl.filterTickets(client, $event)"
vn-tooltip="Client tickets"

View File

@ -69,8 +69,7 @@ module.exports = Self => {
}
}
}
},
{
}, {
relation: 'address',
scope: {
fields: ['street', 'city', 'provinceFk', 'phone', 'mobile'],
@ -81,8 +80,7 @@ module.exports = Self => {
}
}
}
},
{
}, {
relation: 'notes',
scope: {
fields: ['id', 'observationTypeFk', 'description'],
@ -91,8 +89,7 @@ module.exports = Self => {
fields: ['description']
}
}
},
{
}, {
relation: 'state',
scope: {
fields: ['stateFk'],
@ -101,6 +98,11 @@ module.exports = Self => {
fields: ['name']
}
}
}, {
relation: 'invoiceOut',
scope: {
fields: ['id']
}
}
],
where: {id: ticketFk}

View File

@ -3,7 +3,7 @@
"name": "Tickets",
"icon": "icon-ticket",
"validations": true,
"dependencies": ["worker", "item", "client", "route"],
"dependencies": ["worker", "item", "client", "route", "invoiceOut"],
"menus": {
"main": [
{"state": "ticket.index", "icon": "icon-ticket"},

View File

@ -37,8 +37,12 @@
{{$ctrl.summary.routeFk}}
</span>
</vn-label-value>
<vn-label-value label="Invoice"
value="{{$ctrl.summary.refFk}}">
<vn-label-value label="Invoice">
<span
ng-class="{link: $ctrl.summary.refFk}"
ng-click="$ctrl.showInvoiceOutDescriptor($event, $ctrl.summary.refFk)">
{{$ctrl.summary.refFk | dashIfEmpty}}
</span>
</vn-label-value>
</vn-one>
<vn-one>
@ -235,3 +239,6 @@
warehouse-fk="$ctrl.ticket.warehouseFk",
ticket-fk="$ctrl.ticket.id">
</vn-item-descriptor-popover>
<vn-invoice-out-descriptor-popover
vn-id="invoice-out-descriptor">
</vn-invoice-out-descriptor-popover>

40
package-lock.json generated
View File

@ -3244,7 +3244,7 @@
},
"util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true,
"requires": {
@ -4060,7 +4060,7 @@
"base": {
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
"integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=",
"integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
"dev": true,
"requires": {
"cache-base": "^1.0.1",
@ -4577,7 +4577,7 @@
"cache-base": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
"integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=",
"integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
"dev": true,
"requires": {
"collection-visit": "^1.0.0",
@ -4754,7 +4754,7 @@
"class-utils": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
"integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=",
"integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
"dev": true,
"requires": {
"arr-union": "^3.1.0",
@ -5816,7 +5816,7 @@
"dot-prop": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
"integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=",
"integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==",
"requires": {
"is-obj": "^1.0.0"
}
@ -6751,7 +6751,7 @@
},
"file-loader": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==",
"dev": true,
"requires": {
@ -7918,7 +7918,7 @@
"global-modules": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
"integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=",
"integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
"dev": true,
"requires": {
"global-prefix": "^1.0.1",
@ -8500,7 +8500,7 @@
"dependencies": {
"es6-promise": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
"resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
"integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=",
"dev": true
},
@ -9579,7 +9579,7 @@
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dev": true,
"requires": {
"isobject": "^3.0.1"
@ -9935,7 +9935,7 @@
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"dev": true,
"requires": {
"colors": "1.1.2"
@ -11932,7 +11932,7 @@
},
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
},
"mississippi": {
@ -12972,7 +12972,7 @@
"dependencies": {
"minimist": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=",
"dev": true
},
@ -14180,7 +14180,7 @@
"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
}
@ -14558,7 +14558,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true,
"requires": {
@ -14648,7 +14648,7 @@
"dependencies": {
"source-map": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true,
"requires": {
@ -15006,7 +15006,7 @@
"snapdragon-node": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
"integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=",
"integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
"dev": true,
"requires": {
"define-property": "^1.0.0",
@ -15057,7 +15057,7 @@
"snapdragon-util": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
"integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=",
"integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
"dev": true,
"requires": {
"kind-of": "^3.2.0"
@ -15332,7 +15332,7 @@
"split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
"integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=",
"integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
"dev": true,
"requires": {
"extend-shallow": "^3.0.0"
@ -16409,7 +16409,7 @@
"touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
"integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=",
"integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
"dev": true,
"requires": {
"nopt": "~1.0.10"
@ -17888,7 +17888,7 @@
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
},
"xmlcreate": {