feat: refs #6777 change dependencies vn2008 to vn part7
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
00d64b2a57
commit
c598e62d1e
|
@ -11,13 +11,13 @@ AS SELECT `time`.`year` AS `year`,
|
||||||
FROM (
|
FROM (
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
`vn2008`.`Tickets` `t`
|
`vn`.`ticket` `t`
|
||||||
JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`)
|
JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`)
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`Movimientos` `m` ON(`t`.`Id_Ticket` = `m`.`Id_Ticket`)
|
JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`)
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`Fecha` AS date))
|
JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date))
|
||||||
)
|
)
|
||||||
WHERE `t`.`Fecha` >= '2014-01-01'
|
WHERE `t`.`shipped` >= '2014-01-01'
|
||||||
GROUP BY `time`.`year`,
|
GROUP BY `time`.`year`,
|
||||||
`time`.`month`
|
`time`.`month`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn`.`ticketMRW`
|
VIEW `vn`.`ticketMRW`
|
||||||
AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`,
|
AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`,
|
||||||
`Tickets`.`empresa_id` AS `empresa_id`,
|
`ticket`.`companyFk` AS `empresa_id`,
|
||||||
`Consignatarios`.`consignatario` AS `Consignatario`,
|
`Consignatarios`.`consignatario` AS `Consignatario`,
|
||||||
`Consignatarios`.`domicilio` AS `DOMICILIO`,
|
`Consignatarios`.`domicilio` AS `DOMICILIO`,
|
||||||
`Consignatarios`.`poblacion` AS `POBLACION`,
|
`Consignatarios`.`poblacion` AS `POBLACION`,
|
||||||
|
@ -19,13 +19,13 @@ AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`,
|
||||||
0
|
0
|
||||||
) AS `movil`,
|
) AS `movil`,
|
||||||
`Clientes`.`if` AS `IF`,
|
`Clientes`.`if` AS `IF`,
|
||||||
`Tickets`.`Id_Ticket` AS `Id_Ticket`,
|
`ticket`.`id` AS `Id_Ticket`,
|
||||||
`Tickets`.`warehouse_id` AS `warehouse_id`,
|
`ticket`.`warehouseFk` AS `warehouse_id`,
|
||||||
`Consignatarios`.`id_consigna` AS `Id_Consigna`,
|
`Consignatarios`.`id_consigna` AS `Id_Consigna`,
|
||||||
`Paises`.`Codigo` AS `CodigoPais`,
|
`Paises`.`Codigo` AS `CodigoPais`,
|
||||||
`Tickets`.`Fecha` AS `Fecha`,
|
`ticket`.`shipped` AS `Fecha`,
|
||||||
`province`.`province_id` AS `province_id`,
|
`province`.`province_id` AS `province_id`,
|
||||||
`Tickets`.`landing` AS `landing`
|
`ticket`.`landed` AS `landing`
|
||||||
FROM (
|
FROM (
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
|
@ -35,8 +35,8 @@ FROM (
|
||||||
`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`
|
`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`Tickets` ON(
|
JOIN `vn`.`ticket` ON(
|
||||||
`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`
|
`Consignatarios`.`id_consigna` = `ticket`.`addressFk`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`province` ON(
|
JOIN `vn2008`.`province` ON(
|
||||||
|
|
|
@ -2,24 +2,24 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
SELECT Agencia,
|
SELECT Agencia,
|
||||||
Consignatario,
|
Consignatario,
|
||||||
ti.Id_Ticket,
|
ti.id Id_Ticket,
|
||||||
ts.userFk Id_Trabajador,
|
ts.userFk Id_Trabajador,
|
||||||
IFNULL(ncajas,0) AS ncajas,
|
IFNULL(ncajas,0) AS ncajas,
|
||||||
IFNULL(nbultos,0) AS nbultos,
|
IFNULL(nbultos,0) AS nbultos,
|
||||||
IFNULL(notros,0) AS notros,
|
IFNULL(notros,0) AS notros,
|
||||||
ts.code AS Estado
|
ts.code AS Estado
|
||||||
FROM Tickets ti
|
FROM Tickets ti
|
||||||
INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
|
INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna
|
||||||
INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia
|
INNER JOIN Agencias ON ti.agencyModeFk = Agencias.Id_Agencia
|
||||||
LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.Id_Ticket=sub1.Ticket_Id
|
LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.id=sub1.Ticket_Id
|
||||||
LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.Id_Ticket=sub2.Ticket_Id
|
LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.id=sub2.Ticket_Id
|
||||||
LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.Id_Ticket=sub3.Ticket_Id
|
LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.id=sub3.Ticket_Id
|
||||||
INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
|
INNER JOIN vn.ticketState ts ON ti.id = ts.ticketFk
|
||||||
WHERE ti.Fecha=util.VN_CURDATE() AND
|
WHERE ti.shipped=util.VN_CURDATE() AND
|
||||||
ts.userFk=intId_Trabajador
|
ts.userFk=intId_Trabajador
|
||||||
GROUP BY ti.Id_Ticket;
|
GROUP BY ti.id;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -30,18 +30,19 @@ proc: BEGIN
|
||||||
|
|
||||||
DELETE ts
|
DELETE ts
|
||||||
FROM Tickets_stack ts
|
FROM Tickets_stack ts
|
||||||
JOIN Tickets t ON ts.Id_Ticket = t.Id_Ticket
|
JOIN vn.ticket t ON ts.Id_Ticket = t.id
|
||||||
WHERE t.Fecha < vDate;
|
WHERE t.shipped < vDate;
|
||||||
|
|
||||||
DELETE tobs
|
DELETE tobs
|
||||||
FROM ticketObservation tobs
|
FROM ticketObservation tobs
|
||||||
JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket
|
JOIN vn.ticket t ON tobs.ticketFk = t.id
|
||||||
WHERE t.Fecha < vDate;
|
WHERE t.shipped < vDate;
|
||||||
|
|
||||||
DELETE tobs
|
DELETE tobs
|
||||||
FROM movement_label tobs
|
FROM movement_label tobs
|
||||||
JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento
|
JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento
|
||||||
JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate;
|
JOIN vn.ticket t ON m.Id_Ticket = t.id
|
||||||
|
WHERE t.shipped < vDate;
|
||||||
|
|
||||||
DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18;
|
DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18;
|
||||||
|
|
||||||
|
@ -92,9 +93,9 @@ proc: BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Tickets Nulos PAK 11/10/2016
|
-- Tickets Nulos PAK 11/10/2016
|
||||||
UPDATE Tickets
|
UPDATE vn.ticket
|
||||||
SET empresa_id = 965
|
SET companyFk = 965
|
||||||
WHERE Id_Cliente = 31
|
WHERE clientFk = 31
|
||||||
AND empresa_id != 965;
|
AND companyFk != 965;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -13,28 +13,28 @@ SELECT * FROM
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(SELECT Euros, date(Fecha) as Fecha FROM
|
(SELECT Euros, date(Fecha) as Fecha FROM
|
||||||
(
|
(
|
||||||
SELECT Fechacobro as Fecha, Entregado as Euros
|
SELECT Fechacobro as Fecha, Entregado as Euros
|
||||||
FROM Recibos
|
FROM Recibos
|
||||||
WHERE Id_Cliente = vCustomer
|
WHERE Id_Cliente = vCustomer
|
||||||
AND Fechacobro >= '2017-01-01'
|
AND Fechacobro >= '2017-01-01'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe
|
SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe
|
||||||
FROM Facturas f
|
FROM Facturas f
|
||||||
JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente
|
JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente
|
||||||
WHERE f.Id_Cliente = vCustomer
|
WHERE f.Id_Cliente = vCustomer
|
||||||
AND Fecha >= '2017-01-01'
|
AND Fecha >= '2017-01-01'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT '2016-12-31', Debt
|
SELECT '2016-12-31', Debt
|
||||||
FROM bi.customerDebtInventory
|
FROM bi.customerDebtInventory
|
||||||
WHERE Id_Cliente = vCustomer
|
WHERE Id_Cliente = vCustomer
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100)
|
SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100)
|
||||||
FROM Tickets t
|
FROM vn.ticket t
|
||||||
JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket
|
JOIN Movimientos m on m.Id_Ticket = t.id
|
||||||
WHERE Id_Cliente = vCustomer
|
WHERE t.clientFk = vCustomer
|
||||||
AND Factura IS NULL
|
AND t.refFk IS NULL
|
||||||
AND Fecha >= '2017-01-01'
|
AND t.shipped >= '2017-01-01'
|
||||||
GROUP BY Fecha
|
GROUP BY t.shipped
|
||||||
) sub2
|
) sub2
|
||||||
ORDER BY Fecha
|
ORDER BY Fecha
|
||||||
)sub ON time.date = sub.Fecha
|
)sub ON time.date = sub.Fecha
|
||||||
|
|
|
@ -14,8 +14,8 @@ BEGIN
|
||||||
DECLARE txt TEXT;
|
DECLARE txt TEXT;
|
||||||
|
|
||||||
DECLARE rs CURSOR FOR
|
DECLARE rs CURSOR FOR
|
||||||
SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
|
SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
|
||||||
FROM Tickets t
|
FROM vn.ticket t
|
||||||
JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna
|
JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`,
|
SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`,
|
||||||
|
@ -24,15 +24,15 @@ BEGIN
|
||||||
) AS `amount`
|
) AS `amount`
|
||||||
FROM (
|
FROM (
|
||||||
`vn2008`.`Movimientos`
|
`vn2008`.`Movimientos`
|
||||||
JOIN `vn2008`.`Tickets` ON(
|
JOIN `vn`.`ticket` ON(
|
||||||
`Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`
|
`Movimientos`.`Id_Ticket` = `ticket`.`id`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH
|
WHERE `ticket`.`shipped` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH
|
||||||
GROUP BY `Movimientos`.`Id_Ticket`
|
GROUP BY `Movimientos`.`Id_Ticket`
|
||||||
) v ON v.Id_Ticket = t.Id_Ticket
|
) v ON v.Id_Ticket = t.id
|
||||||
WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date)
|
WHERE t.shipped BETWEEN v_Date AND util.dayEnd(v_Date)
|
||||||
AND t.Id_Cliente = v_Client_Id;
|
AND t.clientFk = v_Client_Id;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
|
||||||
|
|
||||||
|
|
|
@ -2,50 +2,50 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
if bolCLIENT then
|
IF bolCLIENT THEN
|
||||||
|
|
||||||
select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo
|
SELECT m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) Saldo
|
||||||
from Movimientos m
|
FROM Movimientos m
|
||||||
join Articles a on m.Id_Article = a.Id_Article
|
JOIN Articles a ON m.Id_Article = a.Id_Article
|
||||||
join Tipos tp on tp.tipo_id = a.tipo_id
|
JOIN Tipos tp ON tp.tipo_id = a.tipo_id
|
||||||
join Tickets t using(Id_Ticket)
|
JOIN ticket t ON t.id = m.Id_Ticket
|
||||||
join Consignatarios cs using(Id_Consigna)
|
JOIN Consignatarios cs using(Id_Consigna)
|
||||||
where cs.Id_Cliente = idPEOPLE
|
WHERE cs.Id_Cliente = idPEOPLE
|
||||||
and Tipo = 'Contenedores'
|
AND Tipo = 'Contenedores'
|
||||||
and t.Fecha > '2010-01-01'
|
AND t.shipped > '2010-01-01'
|
||||||
group by m.Id_Article;
|
GROUP BY m.Id_Article;
|
||||||
|
|
||||||
else
|
ELSE
|
||||||
|
|
||||||
select Id_Article, Article, sum(Cantidad) as Saldo
|
SELECT Id_Article, Article, sum(Cantidad) Saldo
|
||||||
from
|
FROM
|
||||||
(select Id_Article, Cantidad
|
(SELECT Id_Article, Cantidad
|
||||||
from Compres c
|
FROM Compres c
|
||||||
join Articles a using(Id_Article)
|
JOIN Articles a using(Id_Article)
|
||||||
join Tipos tp using(tipo_id)
|
JOIN Tipos tp using(tipo_id)
|
||||||
join Entradas e using(Id_Entrada)
|
JOIN Entradas e using(Id_Entrada)
|
||||||
join travel tr on tr.id = travel_id
|
JOIN travel tr ON tr.id = travel_id
|
||||||
where Id_Proveedor = idPEOPLE
|
WHERE Id_Proveedor = idPEOPLE
|
||||||
and landing >= '2010-01-01'
|
AND landing >= '2010-01-01'
|
||||||
and reino_id = 6
|
AND reino_id = 6
|
||||||
|
|
||||||
union all
|
union all
|
||||||
|
|
||||||
select Id_Article, - Cantidad
|
SELECT Id_Article, - Cantidad
|
||||||
from Movimientos m
|
FROM Movimientos m
|
||||||
join Articles a using(Id_Article)
|
JOIN Articles a using(Id_Article)
|
||||||
join Tipos tp using(tipo_id)
|
JOIN Tipos tp using(tipo_id)
|
||||||
join Tickets t using(Id_Ticket)
|
JOIN ticket t ON t.id = m.Id_Ticket
|
||||||
join Consignatarios cs using(Id_Consigna)
|
JOIN Consignatarios cs using(Id_Consigna)
|
||||||
join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
|
JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente
|
||||||
where Id_Proveedor = idPEOPLE
|
WHERE Id_Proveedor = idPEOPLE
|
||||||
and reino_id = 6
|
AND reino_id = 6
|
||||||
and t.Fecha > '2010-01-01') mov
|
AND t.shipped > '2010-01-01') mov
|
||||||
|
|
||||||
join Articles a using(Id_Article)
|
JOIN Articles a using(Id_Article)
|
||||||
group by Id_Article;
|
GROUP BY Id_Article;
|
||||||
|
|
||||||
end if;
|
END IF;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -2,77 +2,78 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
|
IF bolCLIENT THEN
|
||||||
|
|
||||||
if bolCLIENT then
|
SELECT m.Id_Article
|
||||||
|
, Article
|
||||||
|
, IF(Cantidad < 0, - Cantidad, NULL) Entrada
|
||||||
|
, IF(Cantidad < 0, NULL, Cantidad) Salida
|
||||||
|
, 'T' Tabla
|
||||||
|
, t.id Registro
|
||||||
|
, t.shipped Fecha
|
||||||
|
, w.name Almacen
|
||||||
|
, cast(Preu as Decimal(5,2)) Precio
|
||||||
|
, c.Cliente Proveedor
|
||||||
|
, abbreviation Empresa
|
||||||
|
FROM Movimientos m
|
||||||
|
JOIN Articles a using(Id_Article)
|
||||||
|
JOIN ticket t ON t.id = m.Id_Ticket
|
||||||
|
JOIN empresa e ON e.id = t.companyFk
|
||||||
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
|
JOIN Consignatarios cs using(Id_Consigna)
|
||||||
|
JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente
|
||||||
|
WHERE cs.Id_Cliente = idPEOPLE
|
||||||
|
AND m.Id_Article = idARTICLE
|
||||||
|
AND t.shipped > '2010-01-01';
|
||||||
|
|
||||||
select m.Id_Article
|
ELSE
|
||||||
, Article
|
|
||||||
, IF(Cantidad < 0, - Cantidad, NULL) as Entrada
|
|
||||||
, IF(Cantidad < 0, NULL, Cantidad) as Salida
|
|
||||||
, 'T' as Tabla
|
|
||||||
, t.Id_Ticket as Registro
|
|
||||||
, t.Fecha
|
|
||||||
, w.name as Almacen
|
|
||||||
, cast(Preu as Decimal(5,2)) Precio
|
|
||||||
, c.Cliente as Proveedor
|
|
||||||
, abbreviation as Empresa
|
|
||||||
from Movimientos m
|
|
||||||
join Articles a using(Id_Article)
|
|
||||||
join Tickets t using(Id_Ticket)
|
|
||||||
join empresa e on e.id = t.empresa_id
|
|
||||||
join warehouse w on w.id = t.warehouse_id
|
|
||||||
join Consignatarios cs using(Id_Consigna)
|
|
||||||
join Clientes c on c.Id_Cliente = cs.Id_Cliente
|
|
||||||
where cs.Id_Cliente = idPEOPLE
|
|
||||||
and m.Id_Article = idARTICLE
|
|
||||||
and t.Fecha > '2010-01-01';
|
|
||||||
|
|
||||||
else
|
SELECT Id_Article,
|
||||||
|
Tabla,
|
||||||
|
Registro,
|
||||||
|
Fecha,
|
||||||
|
Article,
|
||||||
|
w.name Almacen,
|
||||||
|
Entrada,
|
||||||
|
Salida,
|
||||||
|
Proveedor,
|
||||||
|
cast(Precio as Decimal(5,2)) Precio
|
||||||
|
FROM
|
||||||
|
(SELECT Id_Article
|
||||||
|
, IF(Cantidad > 0, Cantidad, NULL) Entrada
|
||||||
|
, IF(Cantidad > 0, NULL,- Cantidad) Salida
|
||||||
|
, 'E' Tabla
|
||||||
|
, Id_Entrada Registro
|
||||||
|
, landing Fecha
|
||||||
|
, tr.warehouse_id
|
||||||
|
, Costefijo Precio
|
||||||
|
FROM Compres c
|
||||||
|
JOIN Entradas e using(Id_Entrada)
|
||||||
|
JOIN travel tr ON tr.id = travel_id
|
||||||
|
WHERE Id_Proveedor = idPEOPLE
|
||||||
|
AND Id_Article = idARTICLE
|
||||||
|
AND landing >= '2010-01-01'
|
||||||
|
|
||||||
select Id_Article, Tabla, Registro, Fecha, Article
|
union all
|
||||||
, w.name as Almacen, Entrada, Salida, Proveedor, cast(Precio as Decimal(5,2)) Precio
|
|
||||||
|
|
||||||
from
|
|
||||||
|
|
||||||
(select Id_Article
|
|
||||||
, IF(Cantidad > 0, Cantidad, NULL) as Entrada
|
|
||||||
, IF(Cantidad > 0, NULL,- Cantidad) as Salida
|
|
||||||
, 'E' as Tabla
|
|
||||||
, Id_Entrada as Registro
|
|
||||||
, landing as Fecha
|
|
||||||
, tr.warehouse_id
|
|
||||||
, Costefijo as Precio
|
|
||||||
from Compres c
|
|
||||||
join Entradas e using(Id_Entrada)
|
|
||||||
join travel tr on tr.id = travel_id
|
|
||||||
where Id_Proveedor = idPEOPLE
|
|
||||||
and Id_Article = idARTICLE
|
|
||||||
and landing >= '2010-01-01'
|
|
||||||
|
|
||||||
union all
|
|
||||||
|
|
||||||
select Id_Article
|
|
||||||
, IF(Cantidad < 0, - Cantidad, NULL) as Entrada
|
|
||||||
, IF(Cantidad < 0, NULL, Cantidad) as Salida
|
|
||||||
, 'T'
|
|
||||||
, Id_Ticket
|
|
||||||
, Fecha
|
|
||||||
, t.warehouse_id
|
|
||||||
, Preu
|
|
||||||
from Movimientos m
|
|
||||||
join Tickets t using(Id_Ticket)
|
|
||||||
join Consignatarios cs using(Id_Consigna)
|
|
||||||
join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
|
|
||||||
where Id_Proveedor = idPEOPLE
|
|
||||||
and Id_Article = idARTICLE
|
|
||||||
and t.Fecha > '2010-01-01') mov
|
|
||||||
|
|
||||||
join Articles a using(Id_Article)
|
|
||||||
join Proveedores p on Id_Proveedor = idPEOPLE
|
|
||||||
join warehouse w on w.id = mov.warehouse_id
|
|
||||||
;
|
|
||||||
|
|
||||||
end if;
|
|
||||||
|
|
||||||
|
SELECT Id_Article
|
||||||
|
, IF(Cantidad < 0, - Cantidad, NULL) Entrada
|
||||||
|
, IF(Cantidad < 0, NULL, Cantidad) Salida
|
||||||
|
, 'T'
|
||||||
|
, Id_Ticket
|
||||||
|
, Fecha
|
||||||
|
, t.warehouseFk warehouse_id
|
||||||
|
, Preu
|
||||||
|
FROM Movimientos m
|
||||||
|
JOIN ticket t ON t.id = m.Id_Ticket
|
||||||
|
JOIN Consignatarios cs using(Id_Consigna)
|
||||||
|
JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente
|
||||||
|
WHERE Id_Proveedor = idPEOPLE
|
||||||
|
AND Id_Article = idARTICLE
|
||||||
|
AND t.shipped > '2010-01-01') mov
|
||||||
|
JOIN Articles a using(Id_Article)
|
||||||
|
JOIN Proveedores p ON Id_Proveedor = idPEOPLE
|
||||||
|
JOIN warehouse w ON w.id = mov.warehouse_id;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -50,20 +50,20 @@ BEGIN
|
||||||
AND E.Inventario = 0
|
AND E.Inventario = 0
|
||||||
AND E.Redada = 0
|
AND E.Redada = 0
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT T.Fecha Fecha,
|
SELECT t.shipped Fecha,
|
||||||
NULL Entrada,
|
NULL Entrada,
|
||||||
M.Cantidad Salida,
|
M.Cantidad Salida,
|
||||||
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
|
(M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK,
|
||||||
T.Alias Alias,
|
t.nickname Alias,
|
||||||
T.Factura Referencia,
|
t.refFk Referencia,
|
||||||
T.Id_Ticket,
|
t.id Id_Ticket,
|
||||||
T.PedidoImpreso
|
t.isPrinted PedidoImpreso
|
||||||
FROM Movimientos M
|
FROM Movimientos M
|
||||||
INNER JOIN Tickets T USING (Id_Ticket)
|
INNER JOIN ticket t USING (Id_Ticket)
|
||||||
JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
|
JOIN Clientes C ON C.Id_Cliente = t.clientFk
|
||||||
WHERE T.Fecha >= '2001-01-01'
|
WHERE t.shipped >= '2001-01-01'
|
||||||
AND M.Id_Article = idART
|
AND M.Id_Article = idART
|
||||||
AND wh IN (T.warehouse_id , 0)
|
AND wh IN (t.warehouseFk , 0)
|
||||||
) t1
|
) t1
|
||||||
ORDER BY Fecha, Entrada DESC, OK DESC;
|
ORDER BY Fecha, Entrada DESC, OK DESC;
|
||||||
|
|
||||||
|
|
|
@ -66,17 +66,17 @@ BEGIN
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT T.Fecha as Fecha,
|
SELECT t.shipped as Fecha,
|
||||||
NULL as Entrada,
|
NULL as Entrada,
|
||||||
M.Cantidad as Salida,
|
M.Cantidad as Salida,
|
||||||
warehouse_id as wh,
|
warehouse_id as wh,
|
||||||
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
|
(M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK,
|
||||||
T.Factura as Referencia,
|
t.refFk as Referencia,
|
||||||
T.Id_Ticket as id
|
t.id as id
|
||||||
|
|
||||||
FROM Movimientos M
|
FROM Movimientos M
|
||||||
INNER JOIN Tickets T USING (Id_Ticket)
|
INNER JOIN ticket t ON t.id = M.Id_Ticket
|
||||||
WHERE T.Fecha >= vDateInventory
|
WHERE t.shipped >= vDateInventory
|
||||||
AND M.Id_Article = vItemFk
|
AND M.Id_Article = vItemFk
|
||||||
|
|
||||||
) AS Historia
|
) AS Historia
|
||||||
|
|
|
@ -6,17 +6,17 @@ BEGIN
|
||||||
* DEPRECATED use vn.routeGressPriority
|
* DEPRECATED use vn.routeGressPriority
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UPDATE Tickets mt
|
UPDATE vn.ticket mt
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad
|
SELECT tt.addressFk Id_Consigna, round(ifnull(avg(t.priority),0),0) as Prioridad
|
||||||
from Tickets t
|
FROM vn.ticket t
|
||||||
JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna
|
JOIN vn.ticket tt on tt.addressFk = t.addressFk
|
||||||
where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
|
WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
|
||||||
AND tt.Id_Ruta = vRutaId
|
AND tt.routeFk = vRutaId
|
||||||
GROUP BY Id_Consigna
|
GROUP BY addressFk
|
||||||
) sub ON sub.Id_Consigna = mt.Id_Consigna
|
) sub ON sub.Id_Consigna = mt.Id_Consigna
|
||||||
SET mt.Prioridad = sub.Prioridad
|
SET mt.priority = sub.Prioridad
|
||||||
WHERE mt.Id_Ruta = vRutaId;
|
WHERE mt.routeFk = vRutaId;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -5,17 +5,17 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.ticket_list
|
CREATE TEMPORARY TABLE tmp.ticket_list
|
||||||
(PRIMARY KEY (Id_Ticket))
|
(PRIMARY KEY (Id_Ticket))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT t.Id_Ticket, c.Id_Cliente
|
SELECT t.id Id_Ticket, c.Id_Cliente
|
||||||
FROM Tickets t
|
FROM vn.ticket t
|
||||||
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket
|
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente
|
JOIN Clientes c ON c.Id_Cliente = t.clientFk
|
||||||
WHERE c.typeFk IN ('normal','handMaking','internalUse')
|
WHERE c.typeFk IN ('normal','handMaking','internalUse')
|
||||||
AND (
|
AND (
|
||||||
Fecha BETWEEN util.today() AND vEndingDate
|
Fecha BETWEEN util.today() AND vEndingDate
|
||||||
OR (
|
OR (
|
||||||
ts.alertLevel < 3
|
ts.alertLevel < 3
|
||||||
AND t.Fecha >= vStartingDate
|
AND t.shipped >= vStartingDate
|
||||||
AND t.Fecha < util.today()
|
AND t.shipped < util.today()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -33,14 +33,14 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.tickets_sin_facturar
|
CREATE TEMPORARY TABLE tmp.tickets_sin_facturar
|
||||||
(PRIMARY KEY (Id_Cliente))
|
(PRIMARY KEY (Id_Cliente))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total
|
SELECT t.clientFk Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total
|
||||||
FROM Movimientos m
|
FROM Movimientos m
|
||||||
JOIN Tickets t on m.Id_Ticket = t.Id_Ticket
|
JOIN vn.ticket t on m.Id_Ticket = t.id
|
||||||
JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente
|
JOIN tmp.client_list c on c.Id_Cliente = t.clientFk
|
||||||
JOIN vn.client cl ON cl.id = t.Id_Cliente
|
JOIN vn.client cl ON cl.id = t.clientFk
|
||||||
WHERE Factura IS NULL
|
WHERE Factura IS NULL
|
||||||
AND Fecha BETWEEN startingDate AND endingDate
|
AND Fecha BETWEEN startingDate AND endingDate
|
||||||
GROUP BY t.Id_Cliente;
|
GROUP BY t.clientFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
||||||
CREATE TEMPORARY TABLE tmp.risk
|
CREATE TEMPORARY TABLE tmp.risk
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn2008`.`item_out`
|
VIEW `vn2008`.`item_out`
|
||||||
AS SELECT `t`.`warehouse_id` AS `warehouse_id`,
|
AS SELECT `t`.`warehouseFk` AS `warehouse_id`,
|
||||||
`t`.`Fecha` AS `dat`,
|
`t`.`shipped` AS `dat`,
|
||||||
`m`.`Id_Article` AS `item_id`,
|
`m`.`Id_Article` AS `item_id`,
|
||||||
- `m`.`Cantidad` AS `amount`,
|
- `m`.`Cantidad` AS `amount`,
|
||||||
`m`.`OK` AS `ok`,
|
`m`.`OK` AS `ok`,
|
||||||
`m`.`Reservado` AS `Reservado`,
|
`m`.`Reservado` AS `Reservado`,
|
||||||
`t`.`Factura` AS `invoice`,
|
`t`.`refFk` AS `invoice`,
|
||||||
`m`.`Id_Movimiento` AS `saleFk`,
|
`m`.`Id_Movimiento` AS `saleFk`,
|
||||||
`m`.`Id_Ticket` AS `ticketFk`
|
`m`.`Id_Ticket` AS `ticketFk`
|
||||||
FROM (
|
FROM (
|
||||||
`vn2008`.`Movimientos` `m`
|
`vn2008`.`Movimientos` `m`
|
||||||
JOIN `vn2008`.`Tickets` `t` ON(`m`.`Id_Ticket` = `t`.`Id_Ticket`)
|
JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`)
|
||||||
)
|
)
|
||||||
WHERE `m`.`Cantidad` <> 0
|
WHERE `m`.`Cantidad` <> 0
|
||||||
|
|
Loading…
Reference in New Issue