refactor: refs #6778 Migrated views of vn2008 to vn #1996
|
@ -42,9 +42,9 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE maxInvoice
|
CREATE TEMPORARY TABLE maxInvoice
|
||||||
(PRIMARY KEY (Id_Cliente))
|
(PRIMARY KEY (Id_Cliente))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT DISTINCT Id_Cliente, max(Fecha) as maxFecha
|
SELECT DISTINCT clientFk Id_Cliente, max(issued) as maxFecha
|
||||||
FROM vn2008.Facturas
|
FROM vn.invoiceOut
|
||||||
GROUP BY Id_Cliente
|
GROUP BY clientFk
|
||||||
HAVING maxFecha < timestampadd(month,-2,datFEC);
|
HAVING maxFecha < timestampadd(month,-2,datFEC);
|
||||||
|
|
||||||
WHILE datFEC < util.VN_CURDATE() DO
|
WHILE datFEC < util.VN_CURDATE() DO
|
||||||
|
@ -53,10 +53,10 @@ BEGIN
|
||||||
|
|
||||||
SELECT Id_Cliente, datFEC as Fecha, Greuge, Ventas, 0
|
SELECT Id_Cliente, datFEC as Fecha, Greuge, Ventas, 0
|
||||||
FROM (
|
FROM (
|
||||||
SELECT Id_Cliente, sum(Importe) as Greuge
|
SELECT clientFk Id_Cliente, sum(amount) as Greuge
|
||||||
FROM vn2008.Greuges
|
FROM vn.greuge
|
||||||
where Fecha <= datFEC
|
where shipped <= datFEC
|
||||||
group by Id_Cliente
|
group by clientFk
|
||||||
) sub
|
) sub
|
||||||
RIGHT JOIN
|
RIGHT JOIN
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ BEGIN
|
||||||
|
|
||||||
-- Reclamaciones demasiado sensibles
|
-- Reclamaciones demasiado sensibles
|
||||||
|
|
||||||
INSERT INTO vn2008.Greuges(Fecha, Id_Cliente, Comentario,
|
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||||
Importe, Greuges_type_id,Id_Ticket)
|
amount, greugeTypeFk, ticketFk)
|
||||||
SELECT cm.Fecha
|
SELECT cm.Fecha
|
||||||
, cm.Id_Cliente
|
, cm.Id_Cliente
|
||||||
, concat('Claim ',cm.id,' : ', m.Concepte)
|
, concat('Claim ',cm.id,' : ', m.Concepte)
|
||||||
|
@ -29,8 +29,8 @@ BEGIN
|
||||||
|
|
||||||
-- Reclamaciones que pasan a Maná
|
-- Reclamaciones que pasan a Maná
|
||||||
|
|
||||||
INSERT INTO vn2008.Greuges(Fecha, Id_Cliente, Comentario,
|
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||||
Importe , Greuges_type_id,Id_Ticket)
|
amount, greugeTypeFk, ticketFk)
|
||||||
SELECT cm.Fecha
|
SELECT cm.Fecha
|
||||||
, cm.Id_Cliente
|
, cm.Id_Cliente
|
||||||
, concat('Claim_mana ',cm.id,' : ', m.Concepte)
|
, concat('Claim_mana ',cm.id,' : ', m.Concepte)
|
||||||
|
@ -73,12 +73,12 @@ BEGIN
|
||||||
AND s.alert_level >= 3;
|
AND s.alert_level >= 3;
|
||||||
|
|
||||||
DELETE g.*
|
DELETE g.*
|
||||||
FROM vn2008.Greuges g
|
FROM vn.greuge g
|
||||||
JOIN tmp.ticket_list t ON g.Id_Ticket = t.Id_Ticket
|
JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket
|
||||||
WHERE Greuges_type_id = 2;
|
WHERE g.greugeTypeFk = 2;
|
||||||
|
|
||||||
INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha,
|
INSERT INTO vn.greuge(clientFk, description, amount,shipped,
|
||||||
Greuges_type_id, Id_Ticket)
|
greugeTypeFk, ticketFk)
|
||||||
SELECT Id_Cliente
|
SELECT Id_Cliente
|
||||||
,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2)
|
,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2)
|
||||||
AS dif
|
AS dif
|
||||||
|
@ -130,10 +130,10 @@ BEGIN
|
||||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||||
UPDATE bi.claims_ratio cr
|
UPDATE bi.claims_ratio cr
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT Id_Cliente, IFNULL(SUM(Importe), 0) AS Greuge
|
SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge
|
||||||
FROM vn2008.Greuges
|
FROM vn.greuge
|
||||||
WHERE Fecha <= util.VN_CURDATE()
|
WHERE shipped <= util.VN_CURDATE()
|
||||||
GROUP BY Id_Cliente
|
GROUP BY clientFk
|
||||||
) g ON g.Id_Cliente = cr.Id_Cliente
|
) g ON g.Id_Cliente = cr.Id_Cliente
|
||||||
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
|
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
|
||||||
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
|
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
|
||||||
|
|
|
@ -14,8 +14,8 @@ BEGIN
|
||||||
WHERE hasChanged AND date = vDate;
|
WHERE hasChanged AND date = vDate;
|
||||||
|
|
||||||
DECLARE invoices CURSOR FOR
|
DECLARE invoices CURSOR FOR
|
||||||
SELECT Vencimiento, importe FROM vn2008.Facturas f
|
SELECT dued Vencimiento, amount importe FROM vn.invoiceOut
|
||||||
WHERE f.Fecha >= '2016-01-01' AND f.Id_Cliente = vClient ORDER BY f.Fecha DESC;
|
WHERE issued >= '2016-01-01' AND clientFk = vClient ORDER BY issued DESC;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ BEGIN
|
||||||
FROM
|
FROM
|
||||||
vn.ticket t
|
vn.ticket t
|
||||||
JOIN vn2008.Clientes cli ON cli.Id_cliente = t.clientFk
|
JOIN vn2008.Clientes cli ON cli.Id_cliente = t.clientFk
|
||||||
LEFT JOIN vn2008.expeditions e ON e.ticket_id = t.id
|
LEFT JOIN vn.expedition e ON e.ticketFk = t.id
|
||||||
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.EsBulto
|
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
|
||||||
JOIN vn.zone z ON t.zoneFk = z.id
|
JOIN vn.zone z ON t.zoneFk = z.id
|
||||||
WHERE
|
WHERE
|
||||||
t.shipped between datSTART AND datEND
|
t.shipped between datSTART AND datEND
|
||||||
|
@ -64,17 +64,17 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.dp_aux
|
CREATE TEMPORARY TABLE tmp.dp_aux
|
||||||
(PRIMARY KEY (ticketFk))
|
(PRIMARY KEY (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT dp.ticketFk, sum(Importe) Importe
|
SELECT dp.ticketFk, sum(g.amount) Importe
|
||||||
FROM tmp.dp
|
FROM tmp.dp
|
||||||
JOIN vn2008.Greuges g ON g.Id_Ticket = dp.ticketFk
|
JOIN vn.greuge g ON g.ticketFk = dp.ticketFk
|
||||||
WHERE Greuges_type_id = 1 -- dif_porte
|
WHERE g.greugeTypeFk = 1 -- dif_porte
|
||||||
GROUP BY dp.ticketFk;
|
GROUP BY dp.ticketFk;
|
||||||
|
|
||||||
UPDATE tmp.dp
|
UPDATE tmp.dp
|
||||||
JOIN tmp.dp_aux USING(ticketFk)
|
JOIN tmp.dp_aux USING(ticketFk)
|
||||||
SET greuge = IFNULL(Importe,0);
|
SET greuge = IFNULL(Importe,0);
|
||||||
|
|
||||||
INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha, Greuges_type_id, Id_Ticket)
|
INSERT INTO vn.greuge (clientFk,description,amount,shipped,greugeTypeFk,ticketFk)
|
||||||
SELECT dp.clientFk
|
SELECT dp.clientFk
|
||||||
, concat('dif_porte ', dp.ticketFk)
|
, concat('dif_porte ', dp.ticketFk)
|
||||||
, round(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) as Importe
|
, round(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) as Importe
|
||||||
|
|
|
@ -37,9 +37,9 @@ BEGIN
|
||||||
FROM
|
FROM
|
||||||
vn2008.Clientes c
|
vn2008.Clientes c
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(SELECT g.Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge
|
(SELECT g.clientFk Id_Cliente, CAST( SUM(g.amount) as DECIMAL(12,2)) AS Greuge
|
||||||
FROM vn2008.Greuges g
|
FROM vn.greuge g
|
||||||
JOIN vn.`client` c ON c.id = g.Id_Cliente
|
JOIN vn.`client` c ON c.id = g.clientFk
|
||||||
LEFT JOIN vn.worker w ON c.salesPersonFk = w.id
|
LEFT JOIN vn.worker w ON c.salesPersonFk = w.id
|
||||||
WHERE (c.salesPersonFk = vWorker OR w.bossFk = vWorker)
|
WHERE (c.salesPersonFk = vWorker OR w.bossFk = vWorker)
|
||||||
GROUP BY Id_Cliente
|
GROUP BY Id_Cliente
|
||||||
|
@ -98,9 +98,9 @@ BEGIN
|
||||||
GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente
|
GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(SELECT c.Id_Cliente,
|
(SELECT c.Id_Cliente,
|
||||||
IF(MAX(Fecha) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto
|
IF(MAX(io.issued) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto
|
||||||
FROM vn2008.Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN vn2008.Clientes c ON c.Id_cliente = f.Id_Cliente
|
JOIN vn2008.Clientes c ON c.Id_cliente = io.clientFk
|
||||||
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
|
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
|
||||||
WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
|
WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
|
||||||
GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente
|
GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente
|
||||||
|
|
|
@ -82,11 +82,11 @@ BEGIN
|
||||||
AND Fechacobro > vFromDated
|
AND Fechacobro > vFromDated
|
||||||
AND Fechacobro <= vToDated
|
AND Fechacobro <= vToDated
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT g.Id_Cliente, g.Importe
|
SELECT clientFk, amount
|
||||||
FROM vn2008.Greuges g
|
FROM vn.greuge
|
||||||
WHERE Greuges_type_id = vManaGreugeTypeId
|
WHERE greugeTypeFk = vManaGreugeTypeId
|
||||||
AND Fecha > vFromDated
|
AND shipped > vFromDated
|
||||||
AND Fecha <= vToDated
|
AND shipped <= vToDated
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT clientFk, mana
|
SELECT clientFk, mana
|
||||||
FROM vn.clientManaCache
|
FROM vn.clientManaCache
|
||||||
|
|
|
@ -23,9 +23,9 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT Id_Ticket
|
SELECT Id_Ticket
|
||||||
FROM vn2008.Tickets t
|
FROM vn2008.Tickets t
|
||||||
JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura
|
JOIN vn.invoiceOut io ON io.id = t.Factura
|
||||||
WHERE year(f.Fecha) = vYear
|
WHERE year(io.issued) = vYear
|
||||||
AND month(f.Fecha) = vMonth;
|
AND month(io.issued) = vMonth;
|
||||||
|
|
||||||
INSERT INTO bs.ventas_contables(year
|
INSERT INTO bs.ventas_contables(year
|
||||||
, month
|
, month
|
||||||
|
|
|
@ -13,9 +13,9 @@ BEGIN
|
||||||
(PRIMARY KEY (Id_Ticket))
|
(PRIMARY KEY (Id_Ticket))
|
||||||
SELECT Id_Ticket
|
SELECT Id_Ticket
|
||||||
FROM vn2008.Tickets t
|
FROM vn2008.Tickets t
|
||||||
JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura
|
JOIN vn.invoiceOut io ON io.id = t.Factura
|
||||||
WHERE year(f.Fecha) = vYear
|
WHERE year(io.issued) = vYear
|
||||||
AND month(f.Fecha) = vMonth;
|
AND month(io.issued) = vMonth;
|
||||||
|
|
||||||
SELECT vYear Año,
|
SELECT vYear Año,
|
||||||
vMonth Mes,
|
vMonth Mes,
|
||||||
|
|
|
@ -24,20 +24,20 @@ BEGIN
|
||||||
WHERE date BETWEEN @datSTART
|
WHERE date BETWEEN @datSTART
|
||||||
AND @datEND ) tm
|
AND @datEND ) tm
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(SELECT DISTINCT tm.yearMonth, f.Id_Cliente , 1 as Compra
|
(SELECT DISTINCT tm.yearMonth, io.clientFk Id_Cliente , 1 as Compra
|
||||||
FROM vn2008.Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN vn2008.time tm ON tm.date = f.Fecha
|
JOIN vn2008.time tm ON tm.date = io.issued
|
||||||
WHERE Fecha BETWEEN @datSTART
|
WHERE io.issued BETWEEN @datSTART
|
||||||
AND @datEND) f ON f.yearMonth = tm.yearMonth
|
AND @datEND) f ON f.yearMonth = tm.yearMonth
|
||||||
AND f.Id_Cliente = c.Id_Cliente;
|
AND f.Id_Cliente = c.Id_Cliente;
|
||||||
|
|
||||||
UPDATE tmp.VivosMuertos vm
|
UPDATE tmp.VivosMuertos vm
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT MIN(tm.yearMonth) firstMonth, f.Id_Cliente
|
(SELECT MIN(tm.yearMonth) firstMonth, io.clientFk Id_Cliente
|
||||||
FROM vn2008.Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN vn2008.time tm ON tm.date = f.Fecha
|
JOIN vn2008.time tm ON tm.date = io.issued
|
||||||
WHERE Fecha BETWEEN @datSTART AND @datEND
|
WHERE io.issued BETWEEN @datSTART AND @datEND
|
||||||
GROUP BY f.Id_Cliente ) fm ON fm.firstMonth = vm.yearMonth
|
GROUP BY io.clientFk) fm ON fm.firstMonth = vm.yearMonth
|
||||||
AND fm.Id_Cliente = vm.Id_Cliente
|
AND fm.Id_Cliente = vm.Id_Cliente
|
||||||
|
|
||||||
SET Nuevo = 1;
|
SET Nuevo = 1;
|
||||||
|
@ -46,11 +46,11 @@ BEGIN
|
||||||
|
|
||||||
UPDATE tmp.VivosMuertos vm
|
UPDATE tmp.VivosMuertos vm
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT MAX(tm.yearMonth) firstMonth, f.Id_Cliente
|
SELECT MAX(tm.yearMonth) firstMonth, io.clientFk Id_Cliente
|
||||||
FROM vn2008.Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN vn2008.time tm ON tm.date = f.Fecha
|
JOIN vn2008.time tm ON tm.date = io.issued
|
||||||
WHERE Fecha BETWEEN @datSTART AND @datEND
|
WHERE io.issued BETWEEN @datSTART AND @datEND
|
||||||
GROUP BY f.Id_Cliente ) fm ON fm.firstMonth = vm.yearMonth
|
GROUP BY io.clientFk) fm ON fm.firstMonth = vm.yearMonth
|
||||||
AND fm.Id_Cliente = vm.Id_Cliente
|
AND fm.Id_Cliente = vm.Id_Cliente
|
||||||
|
|
||||||
SET Muerto = 1
|
SET Muerto = 1
|
||||||
|
|
|
@ -16,8 +16,8 @@ BEGIN
|
||||||
FROM (
|
FROM (
|
||||||
SELECT DISTINCT t.Id_Ruta
|
SELECT DISTINCT t.Id_Ruta
|
||||||
FROM vn2008.scan_line sl
|
FROM vn2008.scan_line sl
|
||||||
JOIN vn2008.expeditions e ON e.expeditions_id = sl.code
|
JOIN expedition e ON e.id = sl.code
|
||||||
JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticket_id
|
JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk
|
||||||
WHERE sl.scan_id = vScanId
|
WHERE sl.scan_id = vScanId
|
||||||
AND t.Id_Ruta
|
AND t.Id_Ruta
|
||||||
) t1;
|
) t1;
|
||||||
|
|
|
@ -3,13 +3,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getDayExpeditions`(
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
e.expeditions_id as expeditionFk,
|
e.id as expeditionFk,
|
||||||
date_format(e.odbc_date,'%Y-%m-%d') as expeditionDate,
|
date_format(e.created,'%Y-%m-%d') as expeditionDate,
|
||||||
e.ticket_id as ticketFk,
|
e.ticketFk,
|
||||||
t.routeFk as routeFk
|
t.routeFk as routeFk
|
||||||
FROM vn2008.expeditions e
|
FROM expedition e
|
||||||
INNER JOIN vn.ticket t ON t.id = e.ticket_id
|
INNER JOIN ticket t ON t.id = e.ticketFk
|
||||||
WHERE DATE(odbc_date) = util.VN_CURDATE();
|
WHERE DATE(e.created) = util.VN_CURDATE();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -50,31 +50,30 @@ BEGIN
|
||||||
) alb ON alb.itemFk = i.id
|
) alb ON alb.itemFk = i.id
|
||||||
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
|
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as venta
|
||||||
FROM vn2008.item_out
|
FROM itemTicketOut
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseFk = vWarehouseFk
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) sale ON sale.item_id = i.id
|
) sale ON sale.item_id = i.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as compra
|
||||||
FROM vn2008.item_entry_in
|
FROM itemEntryIn
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
WHERE landed BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseInFk = vWarehouseFk
|
||||||
AND isVirtualStock = FALSE
|
AND isVirtualStock = FALSE
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) buy ON buy.item_id = i.id
|
) buy ON buy.item_id = i.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as traslado
|
||||||
FROM vn2008.item_entry_out
|
FROM itemEntryOut
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseOutFk = vWarehouseFk
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) mov ON mov.item_id = i.id
|
) mov ON mov.item_id = i.id
|
||||||
WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit)
|
WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit)
|
||||||
AND i.itemPackingTypeFk = 'H'
|
AND i.itemPackingTypeFk = 'H'
|
||||||
AND ic.shortLife
|
AND ic.shortLife;
|
||||||
;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -143,12 +143,12 @@ proc:BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.itemOutTime
|
CREATE TEMPORARY TABLE tmp.itemOutTime
|
||||||
SELECT *,SUM(amount) quantity
|
SELECT *,SUM(amount) quantity
|
||||||
FROM
|
FROM
|
||||||
(SELECT item_id itemFk,
|
(SELECT io.itemFk,
|
||||||
amount,
|
io.quantity amount,
|
||||||
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
|
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
|
||||||
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes
|
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes
|
||||||
FROM vn2008.item_out io
|
FROM itemTicketOut io
|
||||||
JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.item_id
|
JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.itemFk
|
||||||
JOIN vn.ticket t on t.id= io.ticketFk
|
JOIN vn.ticket t on t.id= io.ticketFk
|
||||||
JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk
|
JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk
|
||||||
JOIN vn.state s ON s.id = ts.stateFk
|
JOIN vn.state s ON s.id = ts.stateFk
|
||||||
|
@ -160,10 +160,10 @@ proc:BEGIN
|
||||||
) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
|
) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
|
||||||
WHERE t.warehouseFk = vWarehouseFk
|
WHERE t.warehouseFk = vWarehouseFk
|
||||||
AND s.isPicked = 0
|
AND s.isPicked = 0
|
||||||
AND NOT io.Reservado
|
AND NOT io.reserved
|
||||||
AND stPrevious.saleFk IS NULL
|
AND stPrevious.saleFk IS NULL
|
||||||
AND io.dat >= util.VN_CURDATE()
|
AND io.shipped >= util.VN_CURDATE()
|
||||||
AND io.dat < util.VN_CURDATE() + INTERVAL 1 DAY
|
AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY
|
||||||
) sub
|
) sub
|
||||||
GROUP BY itemFk, hours, minutes;
|
GROUP BY itemFk, hours, minutes;
|
||||||
|
|
||||||
|
|
|
@ -34,26 +34,26 @@ BEGIN
|
||||||
) fue ON fue.itemFk = i.id
|
) fue ON fue.itemFk = i.id
|
||||||
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
|
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as venta
|
||||||
FROM vn2008.item_out
|
FROM itemTicketOut
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
WHERE shipped BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseFk = vWarehouseFk
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) sale ON sale.item_id = i.id
|
) sale ON sale.item_id = i.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as compra
|
||||||
FROM vn2008.item_entry_in
|
FROM itemEntryIn
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
WHERE landed BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseInFk = vWarehouseFk
|
||||||
AND isVirtualStock = FALSE
|
AND isVirtualStock = FALSE
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) buy ON buy.item_id = i.id
|
) buy ON buy.item_id = i.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado
|
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as traslado
|
||||||
FROM vn2008.item_entry_out
|
FROM itemEntryOut
|
||||||
WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
WHERE shipped BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
|
||||||
AND warehouse_id = vWarehouseFk
|
AND warehouseOutFk = vWarehouseFk
|
||||||
GROUP BY item_id
|
GROUP BY itemFk
|
||||||
) mov ON mov.item_id = i.id
|
) mov ON mov.item_id = i.id
|
||||||
WHERE v.amount;
|
WHERE v.amount;
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,13 @@ BEGIN
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT empresa_id, Id_Cliente, - Importe
|
SELECT io.companyFk, io.clientFk Id_Cliente, - io.amount
|
||||||
FROM Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN Clientes c using(Id_Cliente)
|
JOIN Clientes c ON c.Id_Cliente = io.clientFk
|
||||||
JOIN pay_met pm on pm.id = pay_met_id
|
JOIN pay_met pm on pm.id = pay_met_id
|
||||||
WHERE f.Vencimiento > vFechaRemesa
|
WHERE io.dued > vFechaRemesa
|
||||||
AND pay_met_id = 4 AND pm.deudaviva
|
AND pay_met_id = 4 AND pm.deudaviva
|
||||||
AND Importe > 0
|
AND io.amount > 0
|
||||||
|
|
||||||
) risk ON c.Id_Cliente = risk.clientFk
|
) risk ON c.Id_Cliente = risk.clientFk
|
||||||
GROUP BY risk.companyFk, Id_Cliente
|
GROUP BY risk.companyFk, Id_Cliente
|
||||||
|
|
|
@ -13,9 +13,9 @@ SELECT Agencia,
|
||||||
FROM Tickets ti
|
FROM Tickets ti
|
||||||
INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
|
INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
|
||||||
INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia
|
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 ticketFk,count(*) AS ncajas FROM vn.expedition WHERE packagingFk=94 GROUP BY ticketFk) sub1 ON ti.Id_Ticket=sub1.ticketFk
|
||||||
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 ticketFk,count(*) AS nbultos FROM vn.expedition WHERE packagingFk IS NULL GROUP BY ticketFk) sub2 ON ti.Id_Ticket=sub2.ticketFk
|
||||||
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 ticketFk,count(*) AS notros FROM vn.expedition WHERE packagingFk >0 GROUP BY ticketFk) sub3 ON ti.Id_Ticket=sub3.ticketFk
|
||||||
INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
|
INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
|
||||||
WHERE ti.Fecha=util.VN_CURDATE() AND
|
WHERE ti.Fecha=util.VN_CURDATE() AND
|
||||||
ts.userFk=intId_Trabajador
|
ts.userFk=intId_Trabajador
|
||||||
|
|
|
@ -67,12 +67,12 @@ proc: BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.itemCalc
|
CREATE TEMPORARY TABLE tmp.itemCalc
|
||||||
(INDEX (itemFk,warehouseFk))
|
(INDEX (itemFk,warehouseFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT i.item_id itemFk, vWarehouseLanding warehouseFk, i.dat dated, i.amount quantity
|
SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity
|
||||||
FROM item_out i
|
FROM vn.itemTicketOut i
|
||||||
JOIN itemRangeLive ir ON ir.itemFK = i.item_id
|
JOIN itemRangeLive ir ON ir.itemFK = i.itemFk
|
||||||
WHERE i.dat >= vDatedFrom
|
WHERE i.shipped >= vDatedFrom
|
||||||
AND (ir.dated IS NULL OR i.dat <= ir.dated)
|
AND (ir.dated IS NULL OR i.shipped <= ir.dated)
|
||||||
AND i.warehouse_id = vWarehouseLanding
|
AND i.warehouseFk = vWarehouseLanding
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity
|
SELECT b.itemFk, vWarehouseLanding, t.landed, b.quantity
|
||||||
FROM vn.buy b
|
FROM vn.buy b
|
||||||
|
@ -86,12 +86,12 @@ proc: BEGIN
|
||||||
AND t.landed >= vDatedFrom
|
AND t.landed >= vDatedFrom
|
||||||
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT i.item_id, vWarehouseLanding, i.dat, i.amount
|
SELECT i.itemFk, vWarehouseLanding, i.shipped, i.quantity
|
||||||
FROM item_entry_out i
|
FROM vn.itemEntryOut i
|
||||||
JOIN itemRangeLive ir ON ir.itemFk = i.item_id
|
JOIN itemRangeLive ir ON ir.itemFk = i.itemFk
|
||||||
WHERE i.dat >= vDatedFrom
|
WHERE i.shipped >= vDatedFrom
|
||||||
AND (ir.dated IS NULL OR i.dat <= ir.dated)
|
AND (ir.dated IS NULL OR i.shipped <= ir.dated)
|
||||||
AND i.warehouse_id = vWarehouseLanding
|
AND i.warehouseOutFk = vWarehouseLanding
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.item_id, vWarehouseLanding, r.shipment, -r.amount
|
SELECT r.item_id, vWarehouseLanding, r.shipment, -r.amount
|
||||||
FROM hedera.order_row r
|
FROM hedera.order_row r
|
||||||
|
|
|
@ -122,9 +122,9 @@ BEGIN
|
||||||
-- Añadimos los gastos, para facilitar el formulario
|
-- Añadimos los gastos, para facilitar el formulario
|
||||||
UPDATE tmp.balance b
|
UPDATE tmp.balance b
|
||||||
JOIN vn2008.balance_nest_tree bnt on bnt.id = b.id
|
JOIN vn2008.balance_nest_tree bnt on bnt.id = b.id
|
||||||
JOIN (SELECT Id_Gasto, Gasto
|
JOIN (SELECT id Id_Gasto, name Gasto
|
||||||
FROM vn2008.Gastos
|
FROM vn.expense
|
||||||
GROUP BY Id_Gasto) g ON g.Id_Gasto = bnt.Id_Gasto COLLATE utf8_general_ci
|
GROUP BY id) g ON g.Id_Gasto = bnt.Id_Gasto COLLATE utf8_general_ci
|
||||||
SET b.Id_Gasto = g.Id_Gasto COLLATE utf8_general_ci
|
SET b.Id_Gasto = g.Id_Gasto COLLATE utf8_general_ci
|
||||||
, b.Gasto = g.Gasto COLLATE utf8_general_ci ;
|
, b.Gasto = g.Gasto COLLATE utf8_general_ci ;
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ SELECT * FROM
|
||||||
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(io.issued,c.Vencimiento), - io.amount
|
||||||
FROM Facturas f
|
FROM vn.invoiceOut io
|
||||||
JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente
|
JOIN Clientes c ON io.clientFk = c.Id_Cliente
|
||||||
WHERE f.Id_Cliente = vCustomer
|
WHERE io.clientFk = vCustomer
|
||||||
AND Fecha >= '2017-01-01'
|
AND io.issued >= '2017-01-01'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT '2016-12-31', Debt
|
SELECT '2016-12-31', Debt
|
||||||
FROM bi.customerDebtInventory
|
FROM bi.customerDebtInventory
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Facturas`
|
|
||||||
AS SELECT `io`.`id` AS `factura_id`,
|
|
||||||
`io`.`ref` AS `Id_Factura`,
|
|
||||||
`io`.`serial` AS `Serie`,
|
|
||||||
`io`.`issued` AS `Fecha`,
|
|
||||||
`io`.`amount` AS `Importe`,
|
|
||||||
`io`.`clientFk` AS `Id_Cliente`,
|
|
||||||
`io`.`created` AS `odbc_date`,
|
|
||||||
`io`.`companyFk` AS `empresa_id`,
|
|
||||||
`io`.`dued` AS `Vencimiento`,
|
|
||||||
`io`.`booked` AS `booked`,
|
|
||||||
`io`.`bankFk` AS `Id_Banco`,
|
|
||||||
`io`.`siiTypeInvoiceOutFk` AS `siiTypeInvoiceOutFk`,
|
|
||||||
`io`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,
|
|
||||||
`io`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,
|
|
||||||
`io`.`siiTrascendencyInvoiceOutFk` AS `siiTrascendencyInvoiceOutFk`,
|
|
||||||
`io`.`hasPdf` AS `pdf`
|
|
||||||
FROM `vn`.`invoiceOut` `io`
|
|
|
@ -1,7 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Gastos`
|
|
||||||
AS SELECT `e`.`id` AS `Id_Gasto`,
|
|
||||||
`e`.`name` AS `Gasto`,
|
|
||||||
`e`.`isWithheld` AS `isWithheld`
|
|
||||||
FROM `vn`.`expense` `e`
|
|
|
@ -1,12 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Greuges`
|
|
||||||
AS SELECT `g`.`Id` AS `Id`,
|
|
||||||
`g`.`clientFk` AS `Id_Cliente`,
|
|
||||||
`g`.`description` AS `Comentario`,
|
|
||||||
`g`.`amount` AS `Importe`,
|
|
||||||
`g`.`shipped` AS `Fecha`,
|
|
||||||
`g`.`created` AS `odbc_date`,
|
|
||||||
`g`.`greugeTypeFk` AS `Greuges_type_id`,
|
|
||||||
`g`.`ticketFk` AS `Id_Ticket`
|
|
||||||
FROM `vn`.`greuge` `g`
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Greuges_type`
|
|
||||||
AS SELECT `gt`.`id` AS `Greuges_type_id`,
|
|
||||||
`gt`.`name` AS `name`
|
|
||||||
FROM `vn`.`greugeType` `gt`
|
|
|
@ -1,8 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Intrastat`
|
|
||||||
AS SELECT `i`.`id` AS `Codintrastat`,
|
|
||||||
`i`.`description` AS `Definicion`,
|
|
||||||
`i`.`taxClassFk` AS `iva_group_id`,
|
|
||||||
`i`.`taxCodeFk` AS `iva_codigo_id`
|
|
||||||
FROM `vn`.`intrastat` `i`
|
|
|
@ -1,16 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`expeditions`
|
|
||||||
AS SELECT `e`.`id` AS `expeditions_id`,
|
|
||||||
`e`.`agencyModeFk` AS `agency_id`,
|
|
||||||
`e`.`ticketFk` AS `ticket_id`,
|
|
||||||
`e`.`freightItemFk` AS `EsBulto`,
|
|
||||||
`e`.`created` AS `odbc_date`,
|
|
||||||
`e`.`counter` AS `counter`,
|
|
||||||
`e`.`workerFk` AS `workerFk`,
|
|
||||||
`e`.`externalId` AS `externalId`,
|
|
||||||
`p`.`itemFk` AS `Id_article`
|
|
||||||
FROM (
|
|
||||||
`vn`.`expedition` `e`
|
|
||||||
LEFT JOIN `vn`.`packaging` `p` ON(`p`.`id` = `e`.`packagingFk`)
|
|
||||||
)
|
|
|
@ -1,16 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`gestdoc`
|
|
||||||
AS SELECT `d`.`id` AS `id`,
|
|
||||||
`d`.`dmsTypeFk` AS `gesttip_id`,
|
|
||||||
`d`.`file` AS `file`,
|
|
||||||
`d`.`contentType` AS `contentType`,
|
|
||||||
`d`.`workerFk` AS `trabajador_id`,
|
|
||||||
`d`.`warehouseFk` AS `warehouse_id`,
|
|
||||||
`d`.`companyFk` AS `emp_id`,
|
|
||||||
`d`.`hardCopyNumber` AS `orden`,
|
|
||||||
`d`.`hasFile` AS `original`,
|
|
||||||
`d`.`reference` AS `sref`,
|
|
||||||
`d`.`description` AS `brief`,
|
|
||||||
`d`.`created` AS `odbc_date`
|
|
||||||
FROM `vn`.`dms` `d`
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`gesttip`
|
|
||||||
AS SELECT `g`.`id` AS `id`,
|
|
||||||
`g`.`name` AS `tipo`,
|
|
||||||
`g`.`readRoleFk` AS `readRoleFk`,
|
|
||||||
`g`.`writeRoleFk` AS `writeRoleFk`,
|
|
||||||
`g`.`code` AS `code`
|
|
||||||
FROM `vn`.`dmsType` `g`
|
|
|
@ -1,13 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`intrastat_data`
|
|
||||||
AS SELECT `ii`.`id` AS `id`,
|
|
||||||
`ii`.`invoiceInFk` AS `recibida_id`,
|
|
||||||
`ii`.`net` AS `neto`,
|
|
||||||
`ii`.`intrastatFk` AS `intrastat_id`,
|
|
||||||
`ii`.`amount` AS `importe`,
|
|
||||||
`ii`.`stems` AS `unidades`,
|
|
||||||
`ii`.`countryFk` AS `Paises_Id`,
|
|
||||||
`ii`.`dated` AS `odbc_date`,
|
|
||||||
`ii`.`statisticalValue` AS `valorestadistico`
|
|
||||||
FROM `vn`.`invoiceInIntrastat` `ii`
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`invoiceCorrection`
|
|
||||||
AS SELECT `ic`.`correctingFk` AS `correctingFk`,
|
|
||||||
`ic`.`correctedFk` AS `correctedFk`,
|
|
||||||
`ic`.`cplusRectificationTypeFk` AS `cplusRectificationTypeFk`,
|
|
||||||
`ic`.`siiTypeInvoiceOutFk` AS `siiTypeInvoiceOutFk`,
|
|
||||||
`ic`.`invoiceCorrectionTypeFk` AS `invoiceCorrectionTypeFk`
|
|
||||||
FROM `vn`.`invoiceCorrection` `ic`
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`itemTag`
|
|
||||||
AS SELECT `i`.`id` AS `id`,
|
|
||||||
`i`.`itemFk` AS `itemFk`,
|
|
||||||
`i`.`tagFk` AS `tagFk`,
|
|
||||||
`i`.`value` AS `value`,
|
|
||||||
`i`.`priority` AS `priority`
|
|
||||||
FROM `vn`.`itemTag` `i`
|
|
|
@ -1,20 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`item_entry_in`
|
|
||||||
AS SELECT `t`.`warehouse_id` AS `warehouse_id`,
|
|
||||||
`t`.`warehouse_id_out` AS `warehouse_id_out`,
|
|
||||||
`t`.`landing` AS `dat`,
|
|
||||||
`m`.`Id_Article` AS `item_id`,
|
|
||||||
`m`.`Cantidad` AS `amount`,
|
|
||||||
`t`.`received` AS `received`,
|
|
||||||
`e`.`Redada` AS `isVirtualStock`,
|
|
||||||
`e`.`Id_Entrada` AS `entryFk`
|
|
||||||
FROM (
|
|
||||||
(
|
|
||||||
`vn2008`.`Compres` `m`
|
|
||||||
JOIN `vn2008`.`Entradas` `e` ON(`m`.`Id_Entrada` = `e`.`Id_Entrada`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`travel` `t` ON(`e`.`travel_id` = `t`.`id`)
|
|
||||||
)
|
|
||||||
WHERE `e`.`Inventario` = 0
|
|
||||||
AND `m`.`Cantidad` <> 0
|
|
|
@ -1,27 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`item_entry_out`
|
|
||||||
AS SELECT `t`.`warehouse_id_out` AS `warehouse_id`,
|
|
||||||
`t`.`shipment` AS `dat`,
|
|
||||||
`m`.`Id_Article` AS `item_id`,
|
|
||||||
- `m`.`Cantidad` AS `amount`,
|
|
||||||
`t`.`delivered` <> 0
|
|
||||||
OR IFNULL(`co`.`valor`, 0) AS `delivered`,
|
|
||||||
`e`.`Id_Entrada` AS `entryFk`
|
|
||||||
FROM (
|
|
||||||
(
|
|
||||||
(
|
|
||||||
`vn2008`.`Compres` `m`
|
|
||||||
JOIN `vn2008`.`Entradas` `e` ON(`m`.`Id_Entrada` = `e`.`Id_Entrada`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`travel` `t` ON(`e`.`travel_id` = `t`.`id`)
|
|
||||||
)
|
|
||||||
LEFT JOIN `vn2008`.`Compres_ok` `co` ON(
|
|
||||||
`co`.`Id_Compra` = `m`.`Id_Compra`
|
|
||||||
AND `co`.`Id_Accion` = 3
|
|
||||||
AND `co`.`valor` <> 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
WHERE `e`.`Inventario` = 0
|
|
||||||
AND `e`.`Redada` = 0
|
|
||||||
AND `m`.`Cantidad` <> 0
|
|
|
@ -1,17 +0,0 @@
|
||||||
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`,
|
|
||||||
`m`.`Id_Article` AS `item_id`,
|
|
||||||
- `m`.`Cantidad` AS `amount`,
|
|
||||||
`m`.`OK` AS `ok`,
|
|
||||||
`m`.`Reservado` AS `Reservado`,
|
|
||||||
`t`.`Factura` 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`)
|
|
||||||
)
|
|
||||||
WHERE `m`.`Cantidad` <> 0
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
REVOKE SELECT ON TABLE vn2008.expeditions FROM employee;
|
||||||
|
REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.Gastos FROM administrative;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Facturas FROM salesPerson;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Facturas FROM logistic;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Facturas FROM palletizer;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Facturas FROM hr;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.gestdoc FROM employee;
|
||||||
|
REVOKE INSERT, UPDATE ON TABLE vn2008.gestdoc FROM administrative;
|
||||||
|
REVOKE DELETE ON TABLE vn2008.gestdoc FROM hr;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.gesttip FROM employee;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Greuges FROM employee;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.Greuges_type FROM financial;
|
||||||
|
REVOKE SELECT ON TABLE vn2008.intrastat_data FROM buyer;
|
||||||
|
REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.intrastat_data FROM administrative;
|
||||||
|
REVOKE SELECT, INSERT ON TABLE vn2008.invoiceCorrection FROM administrative;
|
Loading…
Reference in New Issue