feat: refs #6777 change dependencies vn2008 to vn part7
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-02-06 14:03:33 +01:00
parent 00d64b2a57
commit c598e62d1e
14 changed files with 213 additions and 211 deletions

View File

@ -11,13 +11,13 @@ AS SELECT `time`.`year` AS `year`,
FROM (
(
(
`vn2008`.`Tickets` `t`
JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`)
`vn`.`ticket` `t`
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`,
`time`.`month`

View File

@ -1,8 +1,8 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`ticketMRW`
AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`,
`Tickets`.`empresa_id` AS `empresa_id`,
AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`,
`ticket`.`companyFk` AS `empresa_id`,
`Consignatarios`.`consignatario` AS `Consignatario`,
`Consignatarios`.`domicilio` AS `DOMICILIO`,
`Consignatarios`.`poblacion` AS `POBLACION`,
@ -19,13 +19,13 @@ AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`,
0
) AS `movil`,
`Clientes`.`if` AS `IF`,
`Tickets`.`Id_Ticket` AS `Id_Ticket`,
`Tickets`.`warehouse_id` AS `warehouse_id`,
`ticket`.`id` AS `Id_Ticket`,
`ticket`.`warehouseFk` AS `warehouse_id`,
`Consignatarios`.`id_consigna` AS `Id_Consigna`,
`Paises`.`Codigo` AS `CodigoPais`,
`Tickets`.`Fecha` AS `Fecha`,
`ticket`.`shipped` AS `Fecha`,
`province`.`province_id` AS `province_id`,
`Tickets`.`landing` AS `landing`
`ticket`.`landed` AS `landing`
FROM (
(
(
@ -35,8 +35,8 @@ FROM (
`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`
)
)
JOIN `vn2008`.`Tickets` ON(
`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`
JOIN `vn`.`ticket` ON(
`Consignatarios`.`id_consigna` = `ticket`.`addressFk`
)
)
JOIN `vn2008`.`province` ON(

View File

@ -2,24 +2,24 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int)
BEGIN
SELECT Agencia,
Consignatario,
ti.Id_Ticket,
ts.userFk Id_Trabajador,
IFNULL(ncajas,0) AS ncajas,
IFNULL(nbultos,0) AS nbultos,
IFNULL(notros,0) AS notros,
ts.code AS Estado
FROM Tickets ti
INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
INNER JOIN Agencias ON ti.Id_Agencia = 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 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 notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.Id_Ticket=sub3.Ticket_Id
INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
WHERE ti.Fecha=util.VN_CURDATE() AND
ts.userFk=intId_Trabajador
GROUP BY ti.Id_Ticket;
SELECT Agencia,
Consignatario,
ti.id Id_Ticket,
ts.userFk Id_Trabajador,
IFNULL(ncajas,0) AS ncajas,
IFNULL(nbultos,0) AS nbultos,
IFNULL(notros,0) AS notros,
ts.code AS Estado
FROM Tickets ti
INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna
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=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=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=sub3.Ticket_Id
INNER JOIN vn.ticketState ts ON ti.id = ts.ticketFk
WHERE ti.shipped=util.VN_CURDATE() AND
ts.userFk=intId_Trabajador
GROUP BY ti.id;
END$$
DELIMITER ;

View File

@ -30,18 +30,19 @@ proc: BEGIN
DELETE ts
FROM Tickets_stack ts
JOIN Tickets t ON ts.Id_Ticket = t.Id_Ticket
WHERE t.Fecha < vDate;
JOIN vn.ticket t ON ts.Id_Ticket = t.id
WHERE t.shipped < vDate;
DELETE tobs
FROM ticketObservation tobs
JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket
WHERE t.Fecha < vDate;
JOIN vn.ticket t ON tobs.ticketFk = t.id
WHERE t.shipped < vDate;
DELETE tobs
FROM movement_label tobs
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;
@ -92,9 +93,9 @@ proc: BEGIN
END IF;
-- Tickets Nulos PAK 11/10/2016
UPDATE Tickets
SET empresa_id = 965
WHERE Id_Cliente = 31
AND empresa_id != 965;
UPDATE vn.ticket
SET companyFk = 965
WHERE clientFk = 31
AND companyFk != 965;
END$$
DELIMITER ;

View File

@ -13,28 +13,28 @@ SELECT * FROM
LEFT JOIN
(SELECT Euros, date(Fecha) as Fecha FROM
(
SELECT Fechacobro as Fecha, Entregado as Euros
SELECT Fechacobro as Fecha, Entregado as Euros
FROM Recibos
WHERE Id_Cliente = vCustomer
AND Fechacobro >= '2017-01-01'
UNION ALL
SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe
AND Fechacobro >= '2017-01-01'
UNION ALL
SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe
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
AND Fecha >= '2017-01-01'
UNION ALL
SELECT '2016-12-31', Debt
AND Fecha >= '2017-01-01'
UNION ALL
SELECT '2016-12-31', Debt
FROM bi.customerDebtInventory
WHERE Id_Cliente = vCustomer
UNION ALL
SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100)
FROM Tickets t
JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket
WHERE Id_Cliente = vCustomer
AND Factura IS NULL
AND Fecha >= '2017-01-01'
GROUP BY Fecha
UNION ALL
SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100)
FROM vn.ticket t
JOIN Movimientos m on m.Id_Ticket = t.id
WHERE t.clientFk = vCustomer
AND t.refFk IS NULL
AND t.shipped >= '2017-01-01'
GROUP BY t.shipped
) sub2
ORDER BY Fecha
)sub ON time.date = sub.Fecha

View File

@ -14,8 +14,8 @@ BEGIN
DECLARE txt TEXT;
DECLARE rs CURSOR FOR
SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
FROM Tickets t
SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
FROM vn.ticket t
JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna
JOIN (
SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`,
@ -24,15 +24,15 @@ BEGIN
) AS `amount`
FROM (
`vn2008`.`Movimientos`
JOIN `vn2008`.`Tickets` ON(
`Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`
JOIN `vn`.`ticket` ON(
`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`
) v ON v.Id_Ticket = t.Id_Ticket
WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date)
AND t.Id_Cliente = v_Client_Id;
) v ON v.Id_Ticket = t.id
WHERE t.shipped BETWEEN v_Date AND util.dayEnd(v_Date)
AND t.clientFk = v_Client_Id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

View File

@ -2,50 +2,50 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN)
BEGIN
if bolCLIENT then
IF bolCLIENT THEN
select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo
from Movimientos m
join Articles a on m.Id_Article = a.Id_Article
join Tipos tp on tp.tipo_id = a.tipo_id
join Tickets t using(Id_Ticket)
join Consignatarios cs using(Id_Consigna)
where cs.Id_Cliente = idPEOPLE
and Tipo = 'Contenedores'
and t.Fecha > '2010-01-01'
group by m.Id_Article;
SELECT m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) Saldo
FROM Movimientos m
JOIN Articles a ON m.Id_Article = a.Id_Article
JOIN Tipos tp ON tp.tipo_id = a.tipo_id
JOIN ticket t ON t.id = m.Id_Ticket
JOIN Consignatarios cs using(Id_Consigna)
WHERE cs.Id_Cliente = idPEOPLE
AND Tipo = 'Contenedores'
AND t.shipped > '2010-01-01'
GROUP BY m.Id_Article;
else
ELSE
select Id_Article, Article, sum(Cantidad) as Saldo
from
(select Id_Article, Cantidad
from Compres c
join Articles a using(Id_Article)
join Tipos tp using(tipo_id)
join Entradas e using(Id_Entrada)
join travel tr on tr.id = travel_id
where Id_Proveedor = idPEOPLE
and landing >= '2010-01-01'
and reino_id = 6
SELECT Id_Article, Article, sum(Cantidad) Saldo
FROM
(SELECT Id_Article, Cantidad
FROM Compres c
JOIN Articles a using(Id_Article)
JOIN Tipos tp using(tipo_id)
JOIN Entradas e using(Id_Entrada)
JOIN travel tr ON tr.id = travel_id
WHERE Id_Proveedor = idPEOPLE
AND landing >= '2010-01-01'
AND reino_id = 6
union all
union all
select Id_Article, - Cantidad
from Movimientos m
join Articles a using(Id_Article)
join Tipos tp using(tipo_id)
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 reino_id = 6
and t.Fecha > '2010-01-01') mov
SELECT Id_Article, - Cantidad
FROM Movimientos m
JOIN Articles a using(Id_Article)
JOIN Tipos tp using(tipo_id)
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 reino_id = 6
AND t.shipped > '2010-01-01') mov
join Articles a using(Id_Article)
group by Id_Article;
JOIN Articles a using(Id_Article)
GROUP BY Id_Article;
end if;
END IF;
END$$
DELIMITER ;

View File

@ -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)
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
, 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
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
, 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;
union all
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$$
DELIMITER ;

View File

@ -50,20 +50,20 @@ BEGIN
AND E.Inventario = 0
AND E.Redada = 0
UNION ALL
SELECT T.Fecha Fecha,
SELECT t.shipped Fecha,
NULL Entrada,
M.Cantidad Salida,
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
T.Alias Alias,
T.Factura Referencia,
T.Id_Ticket,
T.PedidoImpreso
(M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK,
t.nickname Alias,
t.refFk Referencia,
t.id Id_Ticket,
t.isPrinted PedidoImpreso
FROM Movimientos M
INNER JOIN Tickets T USING (Id_Ticket)
JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
WHERE T.Fecha >= '2001-01-01'
INNER JOIN ticket t USING (Id_Ticket)
JOIN Clientes C ON C.Id_Cliente = t.clientFk
WHERE t.shipped >= '2001-01-01'
AND M.Id_Article = idART
AND wh IN (T.warehouse_id , 0)
AND wh IN (t.warehouseFk , 0)
) t1
ORDER BY Fecha, Entrada DESC, OK DESC;

View File

@ -66,17 +66,17 @@ BEGIN
UNION ALL
SELECT T.Fecha as Fecha,
SELECT t.shipped as Fecha,
NULL as Entrada,
M.Cantidad as Salida,
warehouse_id as wh,
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
T.Factura as Referencia,
T.Id_Ticket as id
(M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK,
t.refFk as Referencia,
t.id as id
FROM Movimientos M
INNER JOIN Tickets T USING (Id_Ticket)
WHERE T.Fecha >= vDateInventory
INNER JOIN ticket t ON t.id = M.Id_Ticket
WHERE t.shipped >= vDateInventory
AND M.Id_Article = vItemFk
) AS Historia

View File

@ -6,17 +6,17 @@ BEGIN
* DEPRECATED use vn.routeGressPriority
*/
UPDATE Tickets mt
JOIN (
SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad
from Tickets t
JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna
where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
AND tt.Id_Ruta = vRutaId
GROUP BY Id_Consigna
) sub ON sub.Id_Consigna = mt.Id_Consigna
SET mt.Prioridad = sub.Prioridad
WHERE mt.Id_Ruta = vRutaId;
UPDATE vn.ticket mt
JOIN (
SELECT tt.addressFk Id_Consigna, round(ifnull(avg(t.priority),0),0) as Prioridad
FROM vn.ticket t
JOIN vn.ticket tt on tt.addressFk = t.addressFk
WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
AND tt.routeFk = vRutaId
GROUP BY addressFk
) sub ON sub.Id_Consigna = mt.Id_Consigna
SET mt.priority = sub.Prioridad
WHERE mt.routeFk = vRutaId;
END$$
DELIMITER ;

View File

@ -5,17 +5,17 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket_list
(PRIMARY KEY (Id_Ticket))
ENGINE = MEMORY
SELECT t.Id_Ticket, c.Id_Cliente
FROM Tickets t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket
JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente
SELECT t.id Id_Ticket, c.Id_Cliente
FROM vn.ticket t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN Clientes c ON c.Id_Cliente = t.clientFk
WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND (
Fecha BETWEEN util.today() AND vEndingDate
OR (
ts.alertLevel < 3
AND t.Fecha >= vStartingDate
AND t.Fecha < util.today()
AND t.shipped >= vStartingDate
AND t.shipped < util.today()
)
);
END$$

View File

@ -33,14 +33,14 @@ BEGIN
CREATE TEMPORARY TABLE tmp.tickets_sin_facturar
(PRIMARY KEY (Id_Cliente))
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
JOIN Tickets t on m.Id_Ticket = t.Id_Ticket
JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente
JOIN vn.client cl ON cl.id = t.Id_Cliente
JOIN vn.ticket t on m.Id_Ticket = t.id
JOIN tmp.client_list c on c.Id_Cliente = t.clientFk
JOIN vn.client cl ON cl.id = t.clientFk
WHERE Factura IS NULL
AND Fecha BETWEEN startingDate AND endingDate
GROUP BY t.Id_Cliente;
GROUP BY t.clientFk;
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
CREATE TEMPORARY TABLE tmp.risk

View File

@ -1,17 +1,17 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`item_out`
AS SELECT `t`.`warehouse_id` AS `warehouse_id`,
`t`.`Fecha` AS `dat`,
AS SELECT `t`.`warehouseFk` AS `warehouse_id`,
`t`.`shipped` AS `dat`,
`m`.`Id_Article` AS `item_id`,
- `m`.`Cantidad` AS `amount`,
`m`.`OK` AS `ok`,
`m`.`Reservado` AS `Reservado`,
`t`.`Factura` AS `invoice`,
`t`.`refFk` AS `invoice`,
`m`.`Id_Movimiento` AS `saleFk`,
`m`.`Id_Ticket` AS `ticketFk`
FROM (
`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