diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 55489b99a..10cb717cf 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -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) diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 311b5fe2a..101173740 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -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 diff --git a/db/routines/vn/functions/isPalletHomogeneus.sql b/db/routines/vn/functions/isPalletHomogeneus.sql index d308e8ed3..b38fdcc5e 100644 --- a/db/routines/vn/functions/isPalletHomogeneus.sql +++ b/db/routines/vn/functions/isPalletHomogeneus.sql @@ -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 diff --git a/db/routines/vn/procedures/getDayExpeditions.sql b/db/routines/vn/procedures/getDayExpeditions.sql index 535dfde4a..b708c8b0e 100644 --- a/db/routines/vn/procedures/getDayExpeditions.sql +++ b/db/routines/vn/procedures/getDayExpeditions.sql @@ -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 ; diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql index 624451677..c89a190ae 100644 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ b/db/routines/vn/procedures/itemShelvingRadar.sql @@ -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 diff --git a/db/routines/vn2008/procedures/CalculoRemesas.sql b/db/routines/vn2008/procedures/CalculoRemesas.sql index 3819130ee..a4c191a80 100644 --- a/db/routines/vn2008/procedures/CalculoRemesas.sql +++ b/db/routines/vn2008/procedures/CalculoRemesas.sql @@ -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 diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index e0b48bc5e..ce99916ee 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -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 diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql index 4ac5e3209..a3d2c8bea 100644 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ b/db/routines/vn2008/procedures/availableTraslate.sql @@ -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 diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index df857462c..b9763b985 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -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