fix: refs #6778 Fix and tested

This commit is contained in:
Guillermo Bonet 2024-02-14 12:12:40 +01:00
parent 18c10e2dd7
commit 35fc8930ce
9 changed files with 15 additions and 15 deletions

View File

@ -75,7 +75,7 @@ BEGIN
DELETE g.*
FROM vn.greuge g
JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket
WHERE t.greugeTypeFk = 2;
WHERE g.greugeTypeFk = 2;
INSERT INTO vn.greuge(clientFk, description, amount,shipped,
greugeTypeFk, ticketFk)

View File

@ -98,7 +98,7 @@ BEGIN
GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente
LEFT JOIN
(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 vn.invoiceOut io
JOIN vn2008.Clientes c ON c.Id_cliente = io.clientFk
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador

View File

@ -16,7 +16,7 @@ BEGIN
FROM (
SELECT DISTINCT t.Id_Ruta
FROM vn2008.scan_line sl
JOIN expeditions e ON e.id = sl.code
JOIN expedition e ON e.id = sl.code
JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk
WHERE sl.scan_id = vScanId
AND t.Id_Ruta

View File

@ -7,9 +7,9 @@ BEGIN
date_format(e.created,'%Y-%m-%d') as expeditionDate,
e.ticketFk,
t.routeFk as routeFk
FROM expeditions e
INNER JOIN vn.ticket t ON t.id = e.ticketFk
WHERE DATE(odbc_date) = util.VN_CURDATE();
FROM expedition e
INNER JOIN ticket t ON t.id = e.ticketFk
WHERE DATE(e.created) = util.VN_CURDATE();
END$$
DELIMITER ;

View File

@ -143,8 +143,8 @@ proc:BEGIN
CREATE TEMPORARY TABLE tmp.itemOutTime
SELECT *,SUM(amount) quantity
FROM
(SELECT item_id itemFk,
amount,
(SELECT io.itemFk,
io.quantity amount,
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes
FROM itemTicketOut io

View File

@ -47,7 +47,7 @@ BEGIN
UNION ALL
SELECT d.companyFk, io.clientFk Id_Cliente, - io.amount
SELECT io.companyFk, io.clientFk Id_Cliente, - io.amount
FROM vn.invoiceOut io
JOIN Clientes c ON c.Id_Cliente = io.clientFk
JOIN pay_met pm on pm.id = pay_met_id

View File

@ -13,9 +13,9 @@ SELECT Agencia,
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 ticketFk,count(*) AS ncajas FROM vn.expedition WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.Id_Ticket=sub1.ticketFk
LEFT JOIN (SELECT ticketFk,count(*) AS nbultos FROM vn.expedition WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.Id_Ticket=sub2.ticketFk
LEFT JOIN (SELECT ticketFk,count(*) AS notros FROM vn.expedition WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.Id_Ticket=sub3.ticketFk
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 ticketFk,count(*) AS nbultos FROM vn.expedition WHERE packagingFk IS NULL GROUP BY ticketFk) sub2 ON ti.Id_Ticket=sub2.ticketFk
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
WHERE ti.Fecha=util.VN_CURDATE() AND
ts.userFk=intId_Trabajador

View File

@ -69,7 +69,7 @@ proc: BEGIN
ENGINE = MEMORY
SELECT i.itemFk, vWarehouseLanding warehouseFk, i.shipped dated, i.quantity
FROM vn.itemTicketOut i
JOIN itemRangeLive ir ON ir.itemFK = i.item_id
JOIN itemRangeLive ir ON ir.itemFK = i.itemFk
WHERE i.shipped >= vDatedFrom
AND (ir.dated IS NULL OR i.shipped <= ir.dated)
AND i.warehouseFk = vWarehouseLanding

View File

@ -18,11 +18,11 @@ SELECT * FROM
WHERE Id_Cliente = vCustomer
AND Fechacobro >= '2017-01-01'
UNION ALL
SELECT vn.getDueDate(io.issued,c.Vencimiento), - Importe
SELECT vn.getDueDate(io.issued,c.Vencimiento), - io.amount
FROM vn.invoiceOut io
JOIN Clientes c ON io.clientFk = c.Id_Cliente
WHERE io.clientFk = vCustomer
AND Fecha >= '2017-01-01'
AND io.issued >= '2017-01-01'
UNION ALL
SELECT '2016-12-31', Debt
FROM bi.customerDebtInventory