From 01512c7d36f2cdce1fa36010ecd79460316626d5 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 5 Feb 2024 13:52:28 +0100 Subject: [PATCH 01/14] feat: refs #6777 change dependecies vn2008 to vn --- .../bi/procedures/Greuge_Evolution_Add.sql | 10 ++-- .../bi/procedures/analisis_ventas_update.sql | 52 +++++++++---------- .../bi/procedures/claim_ratio_routine.sql | 24 ++++----- db/routines/bi/procedures/comparativa_add.sql | 10 ++-- .../bi/procedures/comparativa_add_manual.sql | 10 ++-- .../bs/procedures/comercialesCompleto.sql | 18 +++---- .../bs/procedures/manaCustomerUpdate.sql | 8 +-- .../bs/procedures/ventas_contables_add.sql | 20 +++---- .../ventas_contables_por_cliente.sql | 30 +++++------ .../vn/functions/getAlert3StateTest.sql | 14 ++--- .../vn/functions/isPalletHomogeneus.sql | 6 +-- .../vn/functions/ticketPositionInPath.sql | 6 +-- .../vn/procedures/invoiceFromAddress.sql | 11 ++-- .../vn2008/procedures/availableTraslate.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 12 ++--- .../procedures/confection_control_source.sql | 26 +++++----- .../vn2008/procedures/historico_multiple.sql | 2 +- db/routines/vn2008/views/Tickets_state.sql | 7 --- db/routines/vn2008/views/Tickets_turno.sql | 6 --- 19 files changed, 132 insertions(+), 142 deletions(-) delete mode 100644 db/routines/vn2008/views/Tickets_state.sql delete mode 100644 db/routines/vn2008/views/Tickets_turno.sql diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql index 83033cbf8..36491cbab 100644 --- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql +++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql @@ -92,12 +92,12 @@ BEGIN UPDATE bi.Greuge_Evolution ge JOIN ( SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento - WHERE t.Fecha >= datFEC - AND t.Fecha < datFEC_TOMORROW + WHERE t.shipped >= datFEC + AND t.shipped < datFEC_TOMORROW AND mc.Id_Componente = 17 -- Recobro GROUP BY cs.Id_Cliente ) sub using(Id_Cliente) diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index 4f6a448ed..228660d07 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -10,18 +10,18 @@ BEGIN OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); INSERT INTO analisis_ventas ( - Familia, - Reino, - Comercial, - Comprador, - Provincia, - almacen, - Año, - Mes, - Semana, - Vista, - Importe - ) + Familia, + Reino, + Comercial, + Comprador, + Provincia, + almacen, + Año, + Mes, + Semana, + Vista, + Importe + ) SELECT tp.Tipo AS Familia, r.reino AS Reino, @@ -35,19 +35,19 @@ BEGIN dm.description AS Vista, bt.importe AS Importe FROM bs.ventas bt - LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id - LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador - LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador - JOIN vn2008.time tm ON tm.date = bt.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento - LEFT JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista - LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn2008.province p ON p.province_id = cs.province_id - LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id - WHERE bt.fecha >= vLastMonth AND r.mercancia; + LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador + LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador + JOIN vn2008.time tm ON tm.date = bt.fecha + JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento + LEFT JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista + LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk + LEFT JOIN vn2008.province p ON p.province_id = cs.province_id + LEFT JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE bt.fecha >= vLastMonth AND r.mercancia; END$$ DELIMITER ; diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 4616bcb9e..dce098e2d 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,18 +59,18 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.Id_Ticket + SELECT DISTINCT t.id FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Tickets_state ts ON ts.Id_Ticket = t.Id_Ticket - JOIN vn.ticketTracking tt ON tt.id = ts.inter_id - JOIN vn2008.state s ON s.id = tt.stateFk + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn.ticketLastState ts ON ts.ticketFk = t.id + JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN vn.state s ON s.id = tt.stateFk WHERE mc.Id_Componente = 17 AND mc.greuge = 0 - AND t.Fecha >= '2016-10-01' - AND t.Fecha < util.VN_CURDATE() - AND s.alert_level >= 3; + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND s.alertLevel >= 3; DELETE g.* FROM vn2008.Greuges g @@ -82,15 +82,15 @@ BEGIN SELECT Id_Cliente ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif - ,date(t.Fecha) + ,date(t.shipped) , 2 ,tt.Id_Ticket FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc ON mc.Id_Movimiento = m.Id_Movimiento AND mc.Id_Componente = 17 - GROUP BY t.Id_Ticket + GROUP BY t.id HAVING ABS(dif) > 1; UPDATE vn2008.Movimientos_componentes mc diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql index 4297c8aff..ac06798db 100644 --- a/db/routines/bi/procedures/comparativa_add.sql +++ b/db/routines/bi/procedures/comparativa_add.sql @@ -15,17 +15,17 @@ BEGIN IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3 - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END IF; END$$ diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql index 281e15b23..2b05b1277 100644 --- a/db/routines/bi/procedures/comparativa_add_manual.sql +++ b/db/routines/bi/procedures/comparativa_add_manual.sql @@ -25,16 +25,16 @@ BEGIN WHERE Periodo BETWEEN periodStart AND periodEnd; INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN periodStart AND periodEnd - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 323d5cd00..8f519b6ca 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,23 +70,23 @@ BEGIN AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT t.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + (SELECT t.clientFk, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND t.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) + AND t.shipped BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente LEFT JOIN - (SELECT MAX(t.Fecha) LastTicket, c.Id_Cliente - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente + (SELECT MAX(t.shipped) LastTicket, c.Id_Cliente + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_cliente = t.clientFk LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente + GROUP BY t.clientFk) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente LEFT JOIN ( SELECT SUM(importe) peso, c.Id_Cliente diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index 1e9cb8429..7a4ee6dba 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -68,13 +68,13 @@ BEGIN FROM ( SELECT cs.Id_Cliente, Cantidad * Valor as mana - FROM vn2008.Tickets t + FROM vn.ticket t JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) - AND t.Fecha > vFromDated - AND date(t.Fecha) <= vToDated + AND t.shipped > vFromDated + AND date(t.shipped) <= vToDated UNION ALL SELECT r.Id_Cliente, - Entregado FROM vn2008.Recibos r diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index d8e963e3e..554972e4c 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -19,11 +19,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) + (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk WHERE year(f.Fecha) = vYear AND month(f.Fecha) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , 7000000000 + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,12 +54,12 @@ BEGIN ) * 1000000 + tp.reino_id * 10000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t on t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn2008.Articles a on m.Id_Article = a.Id_Article - JOIN vn2008.empresa e on e.id = t.empresa_id + JOIN vn2008.empresa e on e.id = t.companyFk LEFT JOIN vn2008.empresa e2 on e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp on tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 9f1399025..26da1b870 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,38 +10,38 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura - WHERE year(f.Fecha) = vYear - AND month(f.Fecha) = vMonth; - + (PRIMARY KEY (id)) + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk + WHERE year(f.shipped) = vYear + AND month(f.shipped) = vMonth; + SELECT vYear Año, vMonth Mes, - t.Id_Cliente, + t.clientFk, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, IF(e2.empresa_grupo,2,0)) AS grupo, - t.empresa_id empresa + t.companyFk empresa FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c ON c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt ON tt.id = t.id JOIN vn2008.Articles a ON m.Id_Article = a.Id_Article - JOIN vn2008.empresa e ON e.id = t.empresa_id + JOIN vn2008.empresa e ON e.id = t.companyFk LEFT JOIN vn2008.empresa e2 ON e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != 188 - GROUP BY t.Id_Cliente, grupo,t.empresa_id; + GROUP BY t.clientFk, grupo,t.companyFk; DROP TEMPORARY TABLE tmp.ticket_list; - + END$$ DELIMITER ; diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index 6a14d80d4..beba0948c 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -11,9 +11,9 @@ BEGIN SELECT a.Vista INTO vDeliveryType - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - WHERE Id_Ticket = vTicket; + FROM ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + WHERE id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS @@ -23,11 +23,11 @@ BEGIN SET vCode = 'ON_DELIVERY'; ELSE -- MERCADO, OTROS - SELECT t.warehouse_id <> w.warehouse_id INTO isWaitingForPickUp - FROM vn2008.Tickets t + SELECT t.warehouseFk <> w.warehouse_id INTO isWaitingForPickUp + FROM ticket t LEFT JOIN vn2008.warehouse_pickup w - ON w.agency_id = t.Id_Agencia AND w.warehouse_id = t.warehouse_id - WHERE t.Id_Ticket = vTicket; + ON w.agency_id = t.agencyModeFk AND w.warehouse_id = t.warehouseFk + WHERE t.id = vTicket; IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; diff --git a/db/routines/vn/functions/isPalletHomogeneus.sql b/db/routines/vn/functions/isPalletHomogeneus.sql index 39c6461ae..05c20a71b 100644 --- a/db/routines/vn/functions/isPalletHomogeneus.sql +++ b/db/routines/vn/functions/isPalletHomogeneus.sql @@ -14,12 +14,12 @@ BEGIN SELECT COUNT(*) INTO vDistinctRoutesInThePallet FROM ( - SELECT DISTINCT t.Id_Ruta + SELECT DISTINCT t.routeFk FROM vn2008.scan_line sl JOIN vn2008.expeditions e ON e.expeditions_id = sl.code - JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticket_id + JOIN ticket t ON t.id = e.ticket_id WHERE sl.scan_id = vScanId - AND t.Id_Ruta + AND t.routeFk ) t1; RETURN vDistinctRoutesInThePallet = 1; diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 9bd2c110e..9a3bb4a0e 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -28,10 +28,10 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) SELECT (ag.`name` = 'VN_VALENCIA') INTO vIsValenciaPath - FROM vn2008.Rutas r - JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia + FROM `route` r + JOIN vn2008.Agencias a on a.Id_Agencia = r.agencyModeFk JOIN vn2008.agency ag on ag.agency_id = a.agency_id - WHERE r.Id_Ruta = vMyPath; + WHERE r.id = vMyPath; IF vIsValenciaPath THEN -- Rutas Valencia diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bde7afd8c..bea49e747 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -10,10 +10,13 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets WHERE (Fecha BETWEEN vMinDateTicket - AND vMaxTicketDate) AND Id_Consigna = vAddress - AND Factura IS NULL AND empresa_id = vCompany; + ENGINE = MEMORY + SELECT id id + FROM ticket + WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) + AND addressFk = vAddress + AND refFk IS NULL + AND companyFk = vCompany; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql index 6328560c8..399302d7b 100644 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ b/db/routines/vn2008/procedures/availableTraslate.sql @@ -18,7 +18,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT inventoried INTO vDatedInventory FROM vn.config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index bd8a324c6..dba4799d9 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -34,8 +34,8 @@ proc: BEGIN WHERE t.Fecha < vDate; DELETE tobs - FROM ticket_observation tobs - JOIN Tickets t ON tobs.Id_Ticket = t.Id_Ticket + FROM ticketObservation tobs + JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket WHERE t.Fecha < vDate; DELETE tobs @@ -45,10 +45,10 @@ proc: BEGIN DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; - DELETE tt.* - FROM Tickets_turno tt - LEFT JOIN Movimientos m USING(Id_Ticket) - WHERE m.Id_Article IS NULL; + DELETE tw.* + FROM vn.ticketWeekly tw + LEFT JOIN vn.sale s USING(ticketFk) + WHERE s.Id_Article IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 77b4df5f3..2951e9c38 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -11,33 +11,33 @@ BEGIN CREATE TEMPORARY TABLE tmp.production_buffer ENGINE = MEMORY SELECT - date(t.Fecha) as Fecha, - hour(t.Fecha) as Hora, - hour(t.Fecha) as Departure, - t.Id_Ticket, + date(t.shipped) as Fecha, + hour(t.shipped) as Hora, + hour(t.shipped) as Departure, + t.id, m.Id_Movimiento, m.Cantidad, m.Concepte, ABS(m.Reservado) Reservado, i.Categoria, tp.Tipo, - t.Alias as Cliente, + t.nickname as Cliente, wh.name as Almacen, - t.warehouse_id, + t.warehouseFk, cs.province_id, a.agency_id, ct.description as Taller, stock.visible, stock.available - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - JOIN vn.warehouse wh ON wh.id = t.warehouse_id - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + JOIN vn.warehouse wh ON wh.id = t.warehouseFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id JOIN vn.confectionType ct ON ct.id = tp.confeccion - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN ( SELECT item_id, sum(visible) visible, sum(available) available @@ -61,7 +61,7 @@ BEGIN WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam - AND t.Fecha BETWEEN vDated AND vEndingDate + AND t.shipped BETWEEN vDated AND vEndingDate AND m.Cantidad > 0; -- Entradas diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index ae4045a34..c68fbf2ad 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -4,7 +4,7 @@ BEGIN DECLARE vDateInventory DATETIME; - SELECT Fechainventario INTO vDateInventory FROM tblContadores; + SELECT inventoried INTO vDateInventory FROM vn.config; SET @a = 0; diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql deleted file mode 100644 index be59a750f..000000000 --- a/db/routines/vn2008/views/Tickets_state.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_state` -AS SELECT `t`.`ticketFk` AS `Id_Ticket`, - `t`.`ticketTrackingFk` AS `inter_id`, - `t`.`name` AS `state_name` -FROM `vn`.`ticketLastState` `t` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql deleted file mode 100644 index 28bc2d55f..000000000 --- a/db/routines/vn2008/views/Tickets_turno.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_turno` -AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, - `tw`.`weekDay` AS `weekDay` -FROM `vn`.`ticketWeekly` `tw` -- 2.40.1 From 350088614991bee0909b1ba54af10b14ff72ff6d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 08:37:28 +0100 Subject: [PATCH 02/14] feat: refs #6777 tabulacion --- .../procedures/confection_control_source.sql | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 2951e9c38..6833cd29d 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -15,31 +15,31 @@ BEGIN hour(t.shipped) as Hora, hour(t.shipped) as Departure, t.id, - m.Id_Movimiento, + m.Id_Movimiento, m.Cantidad, m.Concepte, - ABS(m.Reservado) Reservado, + ABS(m.Reservado) Reservado, i.Categoria, - tp.Tipo, + tp.Tipo, t.nickname as Cliente, wh.name as Almacen, t.warehouseFk, cs.province_id, a.agency_id, - ct.description as Taller, - stock.visible, - stock.available + ct.description as Taller, + stock.visible, + stock.available FROM vn.ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk JOIN vn.warehouse wh ON wh.id = t.warehouseFk JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id - JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article + JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id - JOIN vn.confectionType ct ON ct.id = tp.confeccion + JOIN vn.confectionType ct ON ct.id = tp.confeccion JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - LEFT JOIN - ( + LEFT JOIN + ( SELECT item_id, sum(visible) visible, sum(available) available FROM ( @@ -57,12 +57,12 @@ BEGIN where cc.cache_id IN (2,8) and cc.params IN ("1","44") ) sub GROUP BY item_id - ) stock ON stock.item_id = m.Id_Article + ) stock ON stock.item_id = m.Id_Article WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam AND t.shipped BETWEEN vDated AND vEndingDate - AND m.Cantidad > 0; + AND m.Cantidad > 0; -- Entradas @@ -74,9 +74,9 @@ BEGIN Categoria, Cliente, Almacen, - Taller + Taller ) - SELECT + SELECT tr.shipment AS Fecha, e.Id_Entrada AS Id_Ticket, c.Cantidad, @@ -96,10 +96,7 @@ BEGIN WHERE who.hasConfectionTeam AND tp.confeccion AND tr.shipment BETWEEN vDated AND vEndingDate; - - - SELECT * FROM tmp.production_buffer; - + SELECT * FROM tmp.production_buffer; END$$ DELIMITER ; -- 2.40.1 From c598e62d1ecc50e77ef0662840ca1afff3d5acdc Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:03:33 +0100 Subject: [PATCH 03/14] feat: refs #6777 change dependencies vn2008 to vn part7 --- db/routines/bi/views/v_ventas_contables.sql | 10 +- db/routines/vn/views/ticketMRW.sql | 16 +-- .../procedures/ListaTicketsEncajados.sql | 36 ++--- db/routines/vn2008/procedures/clean.sql | 19 +-- .../procedures/customerDebtEvolution.sql | 32 ++--- .../emailYesterdayPurchasesByConsigna.sql | 16 +-- .../vn2008/procedures/embalajes_stocks.sql | 74 +++++----- .../procedures/embalajes_stocks_detalle.sql | 135 +++++++++--------- .../vn2008/procedures/historico_absoluto.sql | 20 +-- .../vn2008/procedures/historico_multiple.sql | 12 +- .../vn2008/procedures/preOrdenarRuta.sql | 24 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 12 +- .../vn2008/procedures/risk_vs_client_list.sql | 10 +- db/routines/vn2008/views/item_out.sql | 8 +- 14 files changed, 213 insertions(+), 211 deletions(-) diff --git a/db/routines/bi/views/v_ventas_contables.sql b/db/routines/bi/views/v_ventas_contables.sql index 373fcdd3f..82bbeeaac 100644 --- a/db/routines/bi/views/v_ventas_contables.sql +++ b/db/routines/bi/views/v_ventas_contables.sql @@ -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` diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index d612c8742..2677b41e7 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -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( diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index 3d3318c63..e220cd9ad 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -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 ; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index dba4799d9..00279c090 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -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 ; diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index e5d23f0ef..f6f81e2b0 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -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 diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 439eba5ad..2a753157d 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -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; diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index b20e44c79..f6b0d9b9a 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -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 ; diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index c49d1b88a..0319e0f75 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -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 ; diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 1a7e1dbfa..55f33ee89 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -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; diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index c68fbf2ad..fbec7bb1d 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -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 diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index b5fd2b24b..9bcf853bd 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -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 ; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index e407a91b7..07cff3ff5 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -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$$ diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index 92f94eb9f..bb3c1028c 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -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 diff --git a/db/routines/vn2008/views/item_out.sql b/db/routines/vn2008/views/item_out.sql index 57353a6d6..a1e714cb6 100644 --- a/db/routines/vn2008/views/item_out.sql +++ b/db/routines/vn2008/views/item_out.sql @@ -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 -- 2.40.1 From 714cd3c2c37f71bb4d83ccf07e83ac122f3f268c Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:55:20 +0100 Subject: [PATCH 04/14] feat: refs #6777 --- db/routines/bi/procedures/claim_ratio_routine.sql | 2 +- db/routines/bs/procedures/comercialesCompleto.sql | 2 +- db/routines/bs/procedures/ventas_contables_por_cliente.sql | 6 +++--- db/routines/vn/procedures/invoiceFromAddress.sql | 2 +- db/routines/vn2008/procedures/confection_control_source.sql | 2 +- db/routines/vn2008/procedures/customerDebtEvolution.sql | 2 +- .../vn2008/procedures/emailYesterdayPurchasesByConsigna.sql | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index dce098e2d..d7adbaba1 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,7 +59,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id + SELECT DISTINCT t.id Id_Ticket FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento JOIN vn.ticket t ON t.id = m.Id_Ticket diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 8f519b6ca..72b54656a 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,7 +70,7 @@ BEGIN AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT t.clientFk, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + (SELECT t.clientFk Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur FROM vn.ticket t JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26da1b870..31e93adb7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -14,12 +14,12 @@ BEGIN SELECT id FROM vn.ticket t JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk - WHERE year(f.shipped) = vYear - AND month(f.shipped) = vMonth; + WHERE year(f.Fecha) = vYear + AND month(f.Fecha) = vMonth; SELECT vYear Año, vMonth Mes, - t.clientFk, + t.clientFk Id_Cliente, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bea49e747..bf657a731 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -11,7 +11,7 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY - SELECT id id + SELECT id FROM ticket WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) AND addressFk = vAddress diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 6833cd29d..4b60b041e 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -23,7 +23,7 @@ BEGIN tp.Tipo, t.nickname as Cliente, wh.name as Almacen, - t.warehouseFk, + t.warehouseFk warehouse_id, cs.province_id, a.agency_id, ct.description as Taller, diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index f6f81e2b0..fad1a8a59 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -28,7 +28,7 @@ SELECT * FROM FROM bi.customerDebtInventory WHERE Id_Cliente = vCustomer UNION ALL - SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) + SELECT t.shipped Fecha, - 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 diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 2a753157d..7da510afa 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,7 +14,7 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, 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 ( -- 2.40.1 From 747dabd1544a3f22492129591a63f4768682e2ed Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:41:22 +0100 Subject: [PATCH 05/14] feat: refs #6777 --- .../bi/procedures/claim_ratio_routine.sql | 2 +- .../bs/procedures/ventas_contables_add.sql | 2 +- .../vn/procedures/invoiceFromAddress.sql | 2 +- .../procedures/ListaTicketsEncajados.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 18 ++---------------- .../procedures/confection_control_source.sql | 2 +- .../emailYesterdayPurchasesByConsigna.sql | 4 ++-- .../vn2008/procedures/embalajes_stocks.sql | 8 ++++---- .../procedures/embalajes_stocks_detalle.sql | 10 +++++----- .../vn2008/procedures/historico_absoluto.sql | 2 +- .../vn2008/procedures/historico_multiple.sql | 6 +++--- .../vn2008/procedures/preOrdenarRuta.sql | 4 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 2 +- .../vn2008/procedures/risk_vs_client_list.sql | 4 ++-- 14 files changed, 27 insertions(+), 41 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index d7adbaba1..833a1153a 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -79,7 +79,7 @@ BEGIN INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha, Greuges_type_id, Id_Ticket) - SELECT Id_Cliente + SELECT t.clientFk ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif ,date(t.shipped) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 554972e4c..955356d4e 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -86,7 +86,7 @@ BEGIN ) as grupo , NULL , NULL - , t.companyFk + , t.companyFk empresa_id , 7050000000 FROM vn.ticketService ts JOIN vn.ticket t ON ts.ticketFk = t.id diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bf657a731..2879460ce 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -8,7 +8,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; - CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY SELECT id diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index e220cd9ad..6a9838da3 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -10,7 +10,7 @@ BEGIN IFNULL(nbultos,0) AS nbultos, IFNULL(notros,0) AS notros, ts.code AS Estado - FROM Tickets ti + FROM vn.ticket 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 diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index 00279c090..0ae70d648 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -22,19 +22,12 @@ proc: BEGIN DELETE FROM cdr WHERE calldate < vDate18; DELETE FROM Monitoring WHERE ODBC_TIME < vDate; - DELETE FROM Conteo WHERE Fecha < vDate; DELETE FROM mail WHERE DATE_ODBC < vDate; - DELETE FROM expeditions_deleted WHERE odbc_date < vDate26; DELETE FROM Movimientos_mark WHERE odbc_date < vDate; DELETE FROM Splits WHERE Fecha < vDate18; - DELETE ts - FROM Tickets_stack ts - JOIN vn.ticket t ON ts.Id_Ticket = t.id - WHERE t.shipped < vDate; - DELETE tobs - FROM ticketObservation tobs + FROM vn.ticketObservation tobs JOIN vn.ticket t ON tobs.ticketFk = t.id WHERE t.shipped < vDate; @@ -49,7 +42,7 @@ proc: BEGIN DELETE tw.* FROM vn.ticketWeekly tw LEFT JOIN vn.sale s USING(ticketFk) - WHERE s.Id_Article IS NULL; + WHERE s.id IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; @@ -65,13 +58,6 @@ proc: BEGIN JOIN travel t ON t.id = e.travel_id WHERE t.landing <= vDate; - DELETE co - FROM Compres_ok co JOIN Compres c ON c.Id_Compra = co.Id_Compra - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - JOIN travel t ON t.id = e.travel_id - WHERE t.landing <= vDate; - DELETE FROM scan WHERE odbc_date < vDate6 AND id <> 1; - IF v_full THEN CREATE OR REPLACE TEMPORARY TABLE tTicketDelete SELECT DISTINCT tl.originFk ticketFk diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 4b60b041e..84126bc8c 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -14,7 +14,7 @@ BEGIN date(t.shipped) as Fecha, hour(t.shipped) as Hora, hour(t.shipped) as Departure, - t.id, + t.id Id_Ticket, m.Id_Movimiento, m.Cantidad, m.Concepte, diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 7da510afa..be2f01d1f 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,9 +14,9 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, nickname 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 Consignatarios cs ON t.addressFk = cs.Id_Consigna JOIN ( SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, sum( diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index f6b0d9b9a..6479b19f8 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -8,8 +8,8 @@ BEGIN 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) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk WHERE cs.Id_Cliente = idPEOPLE AND Tipo = 'Contenedores' AND t.shipped > '2010-01-01' @@ -35,8 +35,8 @@ BEGIN 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 vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND reino_id = 6 diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index 0319e0f75..2992e6029 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -17,10 +17,10 @@ BEGIN , abbreviation Empresa FROM Movimientos m JOIN Articles a using(Id_Article) - JOIN ticket t ON t.id = m.Id_Ticket + JOIN vn.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 vn.warehouse w ON w.id = t.warehouseFk + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente WHERE cs.Id_Cliente = idPEOPLE AND m.Id_Article = idARTICLE @@ -65,8 +65,8 @@ BEGIN , t.warehouseFk warehouse_id , Preu FROM Movimientos m - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND Id_Article = idARTICLE diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 55f33ee89..e11fb64d5 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -59,7 +59,7 @@ BEGIN t.id Id_Ticket, t.isPrinted PedidoImpreso FROM Movimientos M - INNER JOIN ticket t USING (Id_Ticket) + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket JOIN Clientes C ON C.Id_Cliente = t.clientFk WHERE t.shipped >= '2001-01-01' AND M.Id_Article = idART diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index fbec7bb1d..b3ddc208a 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -69,19 +69,19 @@ BEGIN SELECT t.shipped as Fecha, NULL as Entrada, M.Cantidad as Salida, - warehouse_id as wh, + t.warehouseFk as wh, (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 ticket t ON t.id = M.Id_Ticket + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket WHERE t.shipped >= vDateInventory AND M.Id_Article = vItemFk ) AS Historia - INNER JOIN warehouse ON warehouse.id = Historia.wh + INNER JOIN vn.warehouse ON warehouse.id = Historia.wh ORDER BY Fecha, Entrada DESC, OK DESC; diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index 9bcf853bd..d3e1862f6 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -13,8 +13,8 @@ BEGIN 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 + GROUP BY t.addressFk + ) sub ON sub.Id_Consigna = mt.addressFk SET mt.priority = sub.Prioridad WHERE mt.routeFk = vRutaId; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index 07cff3ff5..ea1dc8e7d 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -11,7 +11,7 @@ BEGIN JOIN Clientes c ON c.Id_Cliente = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( - Fecha BETWEEN util.today() AND vEndingDate + t.shipped BETWEEN util.today() AND vEndingDate OR ( ts.alertLevel < 3 AND t.shipped >= vStartingDate diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index bb3c1028c..148379a64 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -38,8 +38,8 @@ BEGIN 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 + WHERE t.refFk IS NULL + AND t.shipped BETWEEN startingDate AND endingDate GROUP BY t.clientFk; DROP TEMPORARY TABLE IF EXISTS tmp.risk; -- 2.40.1 From be4403819da7c94d8514b48e859422483b3175d2 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:45:14 +0100 Subject: [PATCH 06/14] feat: refs #6777 --- db/routines/bs/procedures/ventas_contables_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 955356d4e..7c8063e56 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, t.companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month -- 2.40.1 From 311401daba314635241aa7eed2513db509e767f5 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 08:59:25 +0100 Subject: [PATCH 07/14] fix: refs #6777 ticketMRW --- db/routines/vn/views/ticketMRW.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index 2677b41e7..26b928ac4 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -44,4 +44,4 @@ FROM ( ) ) JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ) + ); -- 2.40.1 From 624c214178c1c7671df2515388187b545f7c66da Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 10:46:08 +0100 Subject: [PATCH 08/14] fix: refs #6777 Fixed version --- .../10921-bronzeAralia/00-firstScript.sql | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql new file mode 100644 index 000000000..55aa03dca --- /dev/null +++ b/db/versions/10921-bronzeAralia/00-firstScript.sql @@ -0,0 +1,49 @@ +-- Para evitar el error al hacer myt run +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Clientes` +AS SELECT `c`.`id` AS `id_cliente`, + `c`.`name` AS `cliente`, + `c`.`fi` AS `if`, + `c`.`socialName` AS `razonSocial`, + `c`.`contact` AS `contacto`, + `c`.`street` AS `domicilio`, + `c`.`city` AS `poblacion`, + `c`.`postcode` AS `codPostal`, + `c`.`phone` AS `telefono`, + `c`.`mobile` AS `movil`, + `c`.`isRelevant` AS `real`, + `c`.`email` AS `e-mail`, + `c`.`iban` AS `iban`, + `c`.`dueDay` AS `vencimiento`, + `c`.`accountingAccount` AS `Cuenta`, + `c`.`isEqualizated` AS `RE`, + `c`.`provinceFk` AS `province_id`, + `c`.`hasToInvoice` AS `invoice`, + `c`.`credit` AS `credito`, + `c`.`countryFk` AS `Id_Pais`, + `c`.`isActive` AS `activo`, + `c`.`gestdocFk` AS `gestdoc_id`, + `c`.`quality` AS `calidad`, + `c`.`payMethodFk` AS `pay_met_id`, + `c`.`created` AS `created`, + `c`.`isToBeMailed` AS `mail`, + `c`.`contactChannelFk` AS `chanel_id`, + `c`.`hasSepaVnl` AS `sepaVnl`, + `c`.`hasCoreVnl` AS `coreVnl`, + `c`.`hasCoreVnh` AS `coreVnh`, + `c`.`hasLcr` AS `hasLcr`, + `c`.`defaultAddressFk` AS `default_address`, + `c`.`riskCalculated` AS `risk_calculated`, + `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, + `c`.`isTaxDataChecked` AS `contabilizado`, + `c`.`isFreezed` AS `congelado`, + `c`.`creditInsurance` AS `creditInsurance`, + `c`.`isCreatedAsServed` AS `isCreatedAsServed`, + `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, + `c`.`salesPersonFk` AS `Id_Trabajador`, + `c`.`isVies` AS `vies`, + `c`.`eypbc` AS `EYPBC`, + `c`.`bankEntityFk` AS `bankEntityFk`, + `c`.`typeFk` AS `typeFk` +FROM `vn`.`client` `c`; \ No newline at end of file -- 2.40.1 From c2a2a86f355aa30ffb225cdf9d311bacfcdc289b Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 10 Apr 2024 09:42:55 +0200 Subject: [PATCH 09/14] feat: refs #6777 ultima comprobacion --- .../bs/procedures/ventas_contables_add.sql | 16 +++--- .../ventas_contables_por_cliente.sql | 14 +++--- db/routines/vn2008/views/Rutas.sql | 19 ------- db/routines/vn2008/views/state.sql | 13 ----- db/routines/vn2008/views/tag.sql | 10 ---- .../vn2008/views/tarifa_componentes.sql | 10 ---- .../views/tarifa_componentes_series.sql | 7 --- db/routines/vn2008/views/tblContadores.sql | 39 --------------- db/routines/vn2008/views/thermograph.sql | 6 --- .../vn2008/views/ticket_observation.sql | 8 --- db/routines/vn2008/views/tickets_gestdoc.sql | 6 --- .../10921-bronzeAralia/00-firstScript.sql | 49 ------------------- 12 files changed, 15 insertions(+), 182 deletions(-) delete mode 100644 db/routines/vn2008/views/Rutas.sql delete mode 100644 db/routines/vn2008/views/state.sql delete mode 100644 db/routines/vn2008/views/tag.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql delete mode 100644 db/routines/vn2008/views/tblContadores.sql delete mode 100644 db/routines/vn2008/views/thermograph.sql delete mode 100644 db/routines/vn2008/views/ticket_observation.sql delete mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql delete mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index abb4be25d..ad4e80a06 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -21,9 +21,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.`ref` = t.Factura + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.`ref` = t.refFk WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , a.expenseFk + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,8 +54,8 @@ BEGIN ) * 100000 + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn2008.Articles a on m.Id_Article = a.Id_Article @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26ba670b1..ed3773cf7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,13 +10,13 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + (PRIMARY KEY (id)) + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.id = t.refFk WHERE year(io.issued) = vYear - AND month(io.issued) = vMonth; - + AND month(io.issued) = vMonth; + SELECT vYear Año, vMonth Mes, t.clientFk Id_Cliente, @@ -40,7 +40,7 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != 188 GROUP BY t.clientFk, grupo,t.companyFk; - + DROP TEMPORARY TABLE tmp.ticket_list; END$$ diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql deleted file mode 100644 index 78b3bb471..000000000 --- a/db/routines/vn2008/views/Rutas.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas` -AS SELECT `r`.`id` AS `Id_Ruta`, - `r`.`workerFk` AS `Id_Trabajador`, - `r`.`created` AS `Fecha`, - `r`.`vehicleFk` AS `Id_Vehiculo`, - `r`.`agencyModeFk` AS `Id_Agencia`, - `r`.`time` AS `Hora`, - `r`.`isOk` AS `ok`, - `r`.`kmStart` AS `km_start`, - `r`.`kmEnd` AS `km_end`, - `r`.`started` AS `date_start`, - `r`.`finished` AS `date_end`, - `r`.`gestdocFk` AS `gestdoc_id`, - `r`.`cost` AS `cost`, - `r`.`m3` AS `m3`, - `r`.`description` AS `description` -FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql deleted file mode 100644 index 63f6589af..000000000 --- a/db/routines/vn2008/views/state.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`state` -AS SELECT `s`.`id` AS `id`, - `s`.`name` AS `name`, - `s`.`order` AS `order`, - `s`.`alertLevel` AS `alert_level`, - `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, - `s`.`nextStateFk` AS `nextStateFk`, - `s`.`isPreviousPreparable` AS `isPreviousPreparable`, - `s`.`isPicked` AS `isPicked` -FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql deleted file mode 100644 index 25b3ab82e..000000000 --- a/db/routines/vn2008/views/tag.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tag` -AS SELECT `t`.`id` AS `id`, - `t`.`name` AS `name`, - `t`.`isFree` AS `isFree`, - `t`.`isQuantitatif` AS `isQuantitatif`, - `t`.`sourceTable` AS `sourceTable`, - `t`.`unit` AS `unit` -FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql deleted file mode 100644 index bec53abd9..000000000 --- a/db/routines/vn2008/views/tarifa_componentes.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes` -AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, - `tarifa_componentes`.`Componente` AS `Componente`, - `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, - `tarifa_componentes`.`tax` AS `tax`, - `tarifa_componentes`.`is_renewable` AS `is_renewable` -FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql deleted file mode 100644 index a1d188709..000000000 --- a/db/routines/vn2008/views/tarifa_componentes_series.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes_series` -AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes_series`.`Serie` AS `Serie`, - `tarifa_componentes_series`.`base` AS `base` -FROM `bi`.`tarifa_componentes_series` diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql deleted file mode 100644 index 129d3ce8b..000000000 --- a/db/routines/vn2008/views/tblContadores.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tblContadores` -AS SELECT `c`.`id` AS `id`, - `c`.`ochoa` AS `ochoa`, - `c`.`invoiceOutFk` AS `nfactura`, - `c`.`inventoried` AS `FechaInventario`, - `c`.`itemLog` AS `HistoricoArticulo`, - `c`.`weekGoal` AS `week_goal`, - `c`.`photosPath` AS `Rutafotos`, - `c`.`cashBoxNumber` AS `numCaja`, - `c`.`redCode` AS `CodigoRojo`, - `c`.`TabletTime` AS `Tablet_Hora`, - `c`.`t0` AS `t0`, - `c`.`t1` AS `t1`, - `c`.`t2` AS `t2`, - `c`.`t3` AS `t3`, - `c`.`cc` AS `cc`, - `c`.`palet` AS `palet`, - `c`.`campaign` AS `campaign`, - `c`.`campaignLife` AS `campaign_life`, - `c`.`truckDays` AS `truck_days`, - `c`.`transportCharges` AS `tasa_transporte`, - `c`.`escanerPath` AS `escaner_path`, - `c`.`printedTurn` AS `turnoimpreso`, - `c`.`truckLength` AS `truck_length`, - `c`.`fuelConsumption` AS `fuel_consumption`, - `c`.`petrol` AS `petrol`, - `c`.`maintenance` AS `maintenance`, - `c`.`hourPrice` AS `hour_price`, - `c`.`meterPrice` AS `meter_price`, - `c`.`kmPrice` AS `km_price`, - `c`.`routeOption` AS `route_option`, - `c`.`dbproduccion` AS `dbproduccion`, - `c`.`mdbServer` AS `mdbServer`, - `c`.`fakeEmail` AS `fakeEmail`, - `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, - `c`.`ASIEN` AS `ASIEN` -FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql deleted file mode 100644 index f51b83d24..000000000 --- a/db/routines/vn2008/views/thermograph.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`thermograph` -AS SELECT `t`.`id` AS `thermograph_id`, - `t`.`model` AS `model` -FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql deleted file mode 100644 index deb85e4b6..000000000 --- a/db/routines/vn2008/views/ticket_observation.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`ticket_observation` -AS SELECT `to`.`id` AS `ticket_observation_id`, - `to`.`ticketFk` AS `Id_Ticket`, - `to`.`observationTypeFk` AS `observation_type_id`, - `to`.`description` AS `text` -FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql deleted file mode 100644 index a8682db57..000000000 --- a/db/routines/vn2008/views/tickets_gestdoc.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tickets_gestdoc` -AS SELECT `td`.`ticketFk` AS `Id_Ticket`, - `td`.`dmsFk` AS `gestdoc_id` -FROM `vn`.`ticketDms` `td` diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql deleted file mode 100644 index 55aa03dca..000000000 --- a/db/versions/10921-bronzeAralia/00-firstScript.sql +++ /dev/null @@ -1,49 +0,0 @@ --- Para evitar el error al hacer myt run -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Clientes` -AS SELECT `c`.`id` AS `id_cliente`, - `c`.`name` AS `cliente`, - `c`.`fi` AS `if`, - `c`.`socialName` AS `razonSocial`, - `c`.`contact` AS `contacto`, - `c`.`street` AS `domicilio`, - `c`.`city` AS `poblacion`, - `c`.`postcode` AS `codPostal`, - `c`.`phone` AS `telefono`, - `c`.`mobile` AS `movil`, - `c`.`isRelevant` AS `real`, - `c`.`email` AS `e-mail`, - `c`.`iban` AS `iban`, - `c`.`dueDay` AS `vencimiento`, - `c`.`accountingAccount` AS `Cuenta`, - `c`.`isEqualizated` AS `RE`, - `c`.`provinceFk` AS `province_id`, - `c`.`hasToInvoice` AS `invoice`, - `c`.`credit` AS `credito`, - `c`.`countryFk` AS `Id_Pais`, - `c`.`isActive` AS `activo`, - `c`.`gestdocFk` AS `gestdoc_id`, - `c`.`quality` AS `calidad`, - `c`.`payMethodFk` AS `pay_met_id`, - `c`.`created` AS `created`, - `c`.`isToBeMailed` AS `mail`, - `c`.`contactChannelFk` AS `chanel_id`, - `c`.`hasSepaVnl` AS `sepaVnl`, - `c`.`hasCoreVnl` AS `coreVnl`, - `c`.`hasCoreVnh` AS `coreVnh`, - `c`.`hasLcr` AS `hasLcr`, - `c`.`defaultAddressFk` AS `default_address`, - `c`.`riskCalculated` AS `risk_calculated`, - `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, - `c`.`isTaxDataChecked` AS `contabilizado`, - `c`.`isFreezed` AS `congelado`, - `c`.`creditInsurance` AS `creditInsurance`, - `c`.`isCreatedAsServed` AS `isCreatedAsServed`, - `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, - `c`.`salesPersonFk` AS `Id_Trabajador`, - `c`.`isVies` AS `vies`, - `c`.`eypbc` AS `EYPBC`, - `c`.`bankEntityFk` AS `bankEntityFk`, - `c`.`typeFk` AS `typeFk` -FROM `vn`.`client` `c`; \ No newline at end of file -- 2.40.1 From 067e71e3ce0ff545cc1a38e8b97148e9438dcf31 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 07:48:45 +0200 Subject: [PATCH 10/14] feat: refs #6777 puppeteer --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index d700ce1f9..bfe31fc60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,7 @@ pipeline { stage('Back') { steps { sh 'pnpm install --prefer-offline' + sh 'node node_modules/puppeteer/install.mjs' } } stage('Print') { -- 2.40.1 From fb17a54ebd3ac6cf431acd648b37b396dcedc1c0 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 10:53:03 +0200 Subject: [PATCH 11/14] feat: refs #6777 resotre view --- db/routines/vn2008/views/tblContadores.sql | 39 +++++++++++++++++++ db/routines/vn2008/views/thermograph.sql | 6 +++ .../vn2008/views/ticket_observation.sql | 8 ++++ db/routines/vn2008/views/tickets_gestdoc.sql | 6 +++ 4 files changed, 59 insertions(+) create mode 100644 db/routines/vn2008/views/tblContadores.sql create mode 100644 db/routines/vn2008/views/thermograph.sql create mode 100644 db/routines/vn2008/views/ticket_observation.sql create mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql new file mode 100644 index 000000000..129d3ce8b --- /dev/null +++ b/db/routines/vn2008/views/tblContadores.sql @@ -0,0 +1,39 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tblContadores` +AS SELECT `c`.`id` AS `id`, + `c`.`ochoa` AS `ochoa`, + `c`.`invoiceOutFk` AS `nfactura`, + `c`.`inventoried` AS `FechaInventario`, + `c`.`itemLog` AS `HistoricoArticulo`, + `c`.`weekGoal` AS `week_goal`, + `c`.`photosPath` AS `Rutafotos`, + `c`.`cashBoxNumber` AS `numCaja`, + `c`.`redCode` AS `CodigoRojo`, + `c`.`TabletTime` AS `Tablet_Hora`, + `c`.`t0` AS `t0`, + `c`.`t1` AS `t1`, + `c`.`t2` AS `t2`, + `c`.`t3` AS `t3`, + `c`.`cc` AS `cc`, + `c`.`palet` AS `palet`, + `c`.`campaign` AS `campaign`, + `c`.`campaignLife` AS `campaign_life`, + `c`.`truckDays` AS `truck_days`, + `c`.`transportCharges` AS `tasa_transporte`, + `c`.`escanerPath` AS `escaner_path`, + `c`.`printedTurn` AS `turnoimpreso`, + `c`.`truckLength` AS `truck_length`, + `c`.`fuelConsumption` AS `fuel_consumption`, + `c`.`petrol` AS `petrol`, + `c`.`maintenance` AS `maintenance`, + `c`.`hourPrice` AS `hour_price`, + `c`.`meterPrice` AS `meter_price`, + `c`.`kmPrice` AS `km_price`, + `c`.`routeOption` AS `route_option`, + `c`.`dbproduccion` AS `dbproduccion`, + `c`.`mdbServer` AS `mdbServer`, + `c`.`fakeEmail` AS `fakeEmail`, + `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, + `c`.`ASIEN` AS `ASIEN` +FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql new file mode 100644 index 000000000..f51b83d24 --- /dev/null +++ b/db/routines/vn2008/views/thermograph.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`thermograph` +AS SELECT `t`.`id` AS `thermograph_id`, + `t`.`model` AS `model` +FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql new file mode 100644 index 000000000..deb85e4b6 --- /dev/null +++ b/db/routines/vn2008/views/ticket_observation.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`ticket_observation` +AS SELECT `to`.`id` AS `ticket_observation_id`, + `to`.`ticketFk` AS `Id_Ticket`, + `to`.`observationTypeFk` AS `observation_type_id`, + `to`.`description` AS `text` +FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql new file mode 100644 index 000000000..a8682db57 --- /dev/null +++ b/db/routines/vn2008/views/tickets_gestdoc.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tickets_gestdoc` +AS SELECT `td`.`ticketFk` AS `Id_Ticket`, + `td`.`dmsFk` AS `gestdoc_id` +FROM `vn`.`ticketDms` `td` -- 2.40.1 From e601310d3e347281535d2031ce0b9e9ecdd372e2 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:27:54 +0200 Subject: [PATCH 12/14] feat: refs #6777 restore view --- db/routines/vn2008/views/Rutas.sql | 19 +++++++++++++++++++ db/routines/vn2008/views/Tickets_turno.sql | 6 ++++++ db/routines/vn2008/views/state.sql | 13 +++++++++++++ db/routines/vn2008/views/tag.sql | 10 ++++++++++ .../vn2008/views/tarifa_componentes.sql | 10 ++++++++++ .../views/tarifa_componentes_series.sql | 7 +++++++ 6 files changed, 65 insertions(+) create mode 100644 db/routines/vn2008/views/Rutas.sql create mode 100644 db/routines/vn2008/views/Tickets_turno.sql create mode 100644 db/routines/vn2008/views/state.sql create mode 100644 db/routines/vn2008/views/tag.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql new file mode 100644 index 000000000..78b3bb471 --- /dev/null +++ b/db/routines/vn2008/views/Rutas.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Rutas` +AS SELECT `r`.`id` AS `Id_Ruta`, + `r`.`workerFk` AS `Id_Trabajador`, + `r`.`created` AS `Fecha`, + `r`.`vehicleFk` AS `Id_Vehiculo`, + `r`.`agencyModeFk` AS `Id_Agencia`, + `r`.`time` AS `Hora`, + `r`.`isOk` AS `ok`, + `r`.`kmStart` AS `km_start`, + `r`.`kmEnd` AS `km_end`, + `r`.`started` AS `date_start`, + `r`.`finished` AS `date_end`, + `r`.`gestdocFk` AS `gestdoc_id`, + `r`.`cost` AS `cost`, + `r`.`m3` AS `m3`, + `r`.`description` AS `description` +FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql new file mode 100644 index 000000000..28bc2d55f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_turno.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_turno` +AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, + `tw`.`weekDay` AS `weekDay` +FROM `vn`.`ticketWeekly` `tw` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql new file mode 100644 index 000000000..63f6589af --- /dev/null +++ b/db/routines/vn2008/views/state.sql @@ -0,0 +1,13 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`state` +AS SELECT `s`.`id` AS `id`, + `s`.`name` AS `name`, + `s`.`order` AS `order`, + `s`.`alertLevel` AS `alert_level`, + `s`.`code` AS `code`, + `s`.`sectorProdPriority` AS `sectorProdPriority`, + `s`.`nextStateFk` AS `nextStateFk`, + `s`.`isPreviousPreparable` AS `isPreviousPreparable`, + `s`.`isPicked` AS `isPicked` +FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql new file mode 100644 index 000000000..25b3ab82e --- /dev/null +++ b/db/routines/vn2008/views/tag.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tag` +AS SELECT `t`.`id` AS `id`, + `t`.`name` AS `name`, + `t`.`isFree` AS `isFree`, + `t`.`isQuantitatif` AS `isQuantitatif`, + `t`.`sourceTable` AS `sourceTable`, + `t`.`unit` AS `unit` +FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql new file mode 100644 index 000000000..bec53abd9 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes` +AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, + `tarifa_componentes`.`Componente` AS `Componente`, + `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, + `tarifa_componentes`.`tax` AS `tax`, + `tarifa_componentes`.`is_renewable` AS `is_renewable` +FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql new file mode 100644 index 000000000..a1d188709 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes_series.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes_series` +AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes_series`.`Serie` AS `Serie`, + `tarifa_componentes_series`.`base` AS `base` +FROM `bi`.`tarifa_componentes_series` -- 2.40.1 From 5b027a88fa20d99329cf42cc4a7b654bb982884a Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:33:33 +0200 Subject: [PATCH 13/14] feat: refs #6777 restore view --- db/routines/vn2008/views/Tickets_state.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/routines/vn2008/views/Tickets_state.sql diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql new file mode 100644 index 000000000..be59a750f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_state.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_state` +AS SELECT `t`.`ticketFk` AS `Id_Ticket`, + `t`.`ticketTrackingFk` AS `inter_id`, + `t`.`name` AS `state_name` +FROM `vn`.`ticketLastState` `t` -- 2.40.1 From b88dff0d997e66e1ad6295a23d7a3eb01b426141 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 22 Apr 2024 10:48:37 +0200 Subject: [PATCH 14/14] feat: refs #6777 --- db/routines/vn/functions/getAlert3StateTest.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index beba0948c..f1a8ac4cc 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -13,7 +13,7 @@ BEGIN INTO vDeliveryType FROM ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk - WHERE id = vTicket; + WHERE t.id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS -- 2.40.1