diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index bd330597d..04f9b6483 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`() BEGIN DECLARE vLastMonth DATE; @@ -32,7 +32,7 @@ BEGIN tm.year AS Año, tm.month AS Mes, tm.week AS Semana, - v.vista AS Vista, + dm.description AS Vista, bt.importe AS Importe FROM bs.ventas bt LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id @@ -44,10 +44,10 @@ BEGIN 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 vn2008.Vistas v ON v.vista_id = a.Vista + 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 vn2008.warehouse w ON w.id = t.warehouse_id WHERE bt.fecha >= vLastMonth AND r.mercancia; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/views/expeditionPallet_Print.sql b/db/routines/vn/views/expeditionPallet_Print.sql index 0a41c95da..4e9e8cb0e 100644 --- a/db/routines/vn/views/expeditionPallet_Print.sql +++ b/db/routines/vn/views/expeditionPallet_Print.sql @@ -31,7 +31,7 @@ FROM ( ) JOIN `vn`.`route` `r` ON(`r`.`id` = `t`.`routeFk`) ) - LEFT JOIN `vn2008`.`Rutas_monitor` `rm` ON(`rm`.`Id_Ruta` = `r`.`id`) + LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`) ) LEFT JOIN `vn`.`expeditionTruck` `et2` ON(`et2`.`id` = `rm`.`expeditionTruckFk`) ) diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index c2d2e34a0..f63edc80a 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -20,14 +20,12 @@ proc: BEGIN SET vDate2000 = util.VN_CURDATE() + INTERVAL (2000 - YEAR(util.VN_CURDATE())) YEAR; SET vRangeDeleteTicket = 60; - DELETE FROM Rutas_monitor WHERE fecha < vDate; DELETE FROM cdr WHERE calldate < vDate18; DELETE FROM Monitoring WHERE ODBC_TIME < vDate; DELETE FROM Conteo WHERE Fecha < vDate; DELETE FROM XDiario WHERE FECHA < vDate3 OR FECHA IS NULL; DELETE FROM mail WHERE DATE_ODBC < vDate; DELETE FROM expeditions_deleted WHERE odbc_date < vDate26; - DELETE FROM sms WHERE DATE_ODBC < vDate18; DELETE FROM Movimientos_mark WHERE odbc_date < vDate; DELETE FROM Splits WHERE Fecha < vDate18; @@ -47,8 +45,6 @@ proc: BEGIN JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate; DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; - DELETE FROM sharingcart where datEND < vDate; - DELETE FROM sharingclient where datEND < vDate; DELETE tt.* FROM Tickets_turno tt diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index bde90cf7b..439eba5ad 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -17,7 +17,20 @@ BEGIN SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION FROM Tickets t JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna - JOIN v_ticket_amount v ON v.Id_Ticket = t.Id_Ticket + JOIN ( + SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, + sum( + `Movimientos`.`Cantidad` * `Movimientos`.`Preu` * (100 - `Movimientos`.`Descuento`) / 100 + ) AS `amount` + FROM ( + `vn2008`.`Movimientos` + JOIN `vn2008`.`Tickets` ON( + `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket` + ) + ) + WHERE `Tickets`.`Fecha` >= `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; diff --git a/db/routines/vn2008/views/Rutas_Master b/db/routines/vn2008/views/Rutas_Master deleted file mode 100644 index 03b9cfc21..000000000 --- a/db/routines/vn2008/views/Rutas_Master +++ /dev/null @@ -1,24 +0,0 @@ - -CREATE OR REPLACE DEFINER = `root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas_Master` -AS SELECT - `rm`.`id` AS `id`, - `rm`.`warehoseFk` AS `warehouse_id`, - `rm`.`km` AS `km`, - `rm`.`packages` AS `bultos`, - `rm`.`vehicleCost` AS `vehiculos_coste`, - `rm`.`staffCost` AS `personal_coste`, - `rm`.`vehicle` AS `vehiculos_numero`, - `rm`.`staff` AS `personal_numero`, - `rm`.`fuel` AS `gasoil`, - `rm`.`freelancers` AS `autonomos`, - `rm`.`year` AS `año`, - `rm`.`mounth` AS `mes`, - `rm`.`expense` AS `gastos`, - `rm`.`freelancersPackages` AS `bultos_autonomos`, - `rm`.`kmCost` AS `coste_km`, - `rm`.`packageCost` AS `coste_bulto`, - `rm`.`freelancerPackageCost` AS `coste_bulto_autonomo` , - `rm`.`created` AS `odbc_date` - FROM `vn`.`routeMaster` `rm` \ No newline at end of file diff --git a/db/routines/vn2008/views/Rutas_Master.sql b/db/routines/vn2008/views/Rutas_Master.sql deleted file mode 100644 index cdc2bedef..000000000 --- a/db/routines/vn2008/views/Rutas_Master.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas_Master` -AS SELECT `rm`.`id` AS `id`, - `rm`.`warehouseFk` AS `warehouse_id`, - `rm`.`km` AS `km`, - `rm`.`packages` AS `bultos`, - `rm`.`vehicleCost` AS `vehiculos_coste`, - `rm`.`staffCost` AS `personal_coste`, - `rm`.`vehicle` AS `vehiculos_numero`, - `rm`.`staff` AS `personal_numero`, - `rm`.`fuel` AS `gasoil`, - `rm`.`freelancers` AS `autonomos`, - `rm`.`year` AS `año`, - `rm`.`month` AS `mes`, - `rm`.`expense` AS `gastos`, - `rm`.`freelancersPackages` AS `bultos_autonomos`, - `rm`.`kmCost` AS `coste_km`, - `rm`.`packageCost` AS `coste_bulto`, - `rm`.`freelancerPackageCost` AS `coste_bulto_autonomo`, - `rm`.`created` AS `odbc_date` -FROM `vn`.`routeMaster` `rm` diff --git a/db/routines/vn2008/views/Rutas_monitor.sql b/db/routines/vn2008/views/Rutas_monitor.sql deleted file mode 100644 index bd6daab4c..000000000 --- a/db/routines/vn2008/views/Rutas_monitor.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas_monitor` -AS SELECT `vn`.`routesMonitor`.`routeFk` AS `Id_Ruta`, - `vn`.`routesMonitor`.`name` AS `name`, - `vn`.`routesMonitor`.`beachFk` AS `Ubicacion`, - `vn`.`routesMonitor`.`ticketPacked` AS `pedidosEncajados`, - `vn`.`routesMonitor`.`ticketFree` AS `pedidosLibres`, - `vn`.`routesMonitor`.`ticketProduction` AS `pedidosProduccion`, - `vn`.`routesMonitor`.`packages` AS `bultos`, - `vn`.`routesMonitor`.`note` AS `notas`, - `vn`.`routesMonitor`.`dated` AS `fecha`, - `vn`.`routesMonitor`.`dockFk` AS `dockFk`, - `vn`.`routesMonitor`.`m3` AS `m3`, - `vn`.`routesMonitor`.`priority` AS `priority`, - `vn`.`routesMonitor`.`etd` AS `etd`, - `vn`.`routesMonitor`.`expeditionTruckFk` AS `expeditionTruckFk` -FROM `vn`.`routesMonitor` diff --git a/db/routines/vn2008/views/VerEspionaje.sql b/db/routines/vn2008/views/VerEspionaje.sql deleted file mode 100644 index d32687b23..000000000 --- a/db/routines/vn2008/views/VerEspionaje.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`VerEspionaje` -AS SELECT `Trabajadores`.`CodigoTrabajador` AS `CodigoTrabajador`, - `vn2008`.`Espionajes`.`Fecha` AS `Fecha`, - `vn2008`.`Espionajes`.`HoraEntrada` AS `HoraEntrada`, - `vn2008`.`Espionajes`.`HoraSalida` AS `HoraSalida`, - `vn2008`.`Espionajes`.`Id_Equipo` AS `Id_Equipo`, - `Trabajadores`.`Id_Trabajador` AS `Id_Trabajador` -FROM ( - `vn2008`.`Espionajes` - JOIN `vn2008`.`Trabajadores` ON( - `vn2008`.`Espionajes`.`Id_Trabajador` = `Trabajadores`.`Id_Trabajador` - ) - ) -ORDER BY `Trabajadores`.`CodigoTrabajador`, - `vn2008`.`Espionajes`.`Fecha` diff --git a/db/routines/vn2008/views/Vistas.sql b/db/routines/vn2008/views/Vistas.sql deleted file mode 100644 index 4bff8fd11..000000000 --- a/db/routines/vn2008/views/Vistas.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Vistas` -AS SELECT `dm`.`id` AS `vista_id`, - `dm`.`code` AS `code`, - `dm`.`description` AS `vista` -FROM `vn`.`deliveryMethod` `dm` diff --git a/db/routines/vn2008/views/sharingcart.sql b/db/routines/vn2008/views/sharingcart.sql deleted file mode 100644 index b59977b8f..000000000 --- a/db/routines/vn2008/views/sharingcart.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`sharingcart` -AS SELECT `sc`.`id` AS `id`, - `sc`.`workerFk` AS `Id_Trabajador`, - `sc`.`started` AS `datSTART`, - `sc`.`ended` AS `datEND`, - `sc`.`workerSubstitute` AS `Id_Suplente`, - `sc`.`created` AS `odbc_date` -FROM `vn`.`sharingCart` `sc` diff --git a/db/routines/vn2008/views/sharingclient.sql b/db/routines/vn2008/views/sharingclient.sql deleted file mode 100644 index 970132c80..000000000 --- a/db/routines/vn2008/views/sharingclient.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`sharingclient` -AS SELECT `sc`.`id` AS `id`, - `sc`.`workerFk` AS `Id_Trabajador`, - `sc`.`started` AS `datSTART`, - `sc`.`ended` AS `datEND`, - `sc`.`clientFk` AS `Id_Cliente` -FROM `vn`.`sharingClient` `sc` diff --git a/db/routines/vn2008/views/sms.sql b/db/routines/vn2008/views/sms.sql deleted file mode 100644 index abaea40a2..000000000 --- a/db/routines/vn2008/views/sms.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`sms` -AS SELECT `t`.`id` AS `id`, - `t`.`senderFk` AS `Id_trabajador`, - `t`.`sender` AS `from`, - `t`.`destination` AS `to`, - `t`.`message` AS `text`, - `t`.`statusCode` AS `sent`, - `t`.`status` AS `response`, - `t`.`created` AS `DATE_ODBC` -FROM `vn`.`sms` `t` diff --git a/db/routines/vn2008/views/tarifas.sql b/db/routines/vn2008/views/tarifas.sql deleted file mode 100644 index 8b836d60a..000000000 --- a/db/routines/vn2008/views/tarifas.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifas` -AS SELECT `r`.`id` AS `tarifa_id`, - `r`.`dated` AS `fecha`, - `r`.`warehouseFk` AS `warehouse_id`, - `r`.`rate0` AS `t0`, - `r`.`rate1` AS `t1`, - `r`.`rate2` AS `t2`, - `r`.`rate3` AS `t3` -FROM `vn`.`rate` `r` diff --git a/db/routines/vn2008/views/ticketCreationData.sql b/db/routines/vn2008/views/ticketCreationData.sql deleted file mode 100644 index 5de86375d..000000000 --- a/db/routines/vn2008/views/ticketCreationData.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`ticketCreationData` -AS SELECT dayname(`h`.`confirm_date`) AS `DiadelaSemana`, - HOUR(`h`.`confirm_date`) AS `Hora`, - cast(`h`.`confirm_date` AS date) AS `Fecha`, - `h`.`source_app` AS `Dispositivo` -FROM `hedera`.`order` `h` -WHERE `h`.`confirm_date` <> 0 diff --git a/db/routines/vn2008/views/ticketMRW.sql b/db/routines/vn2008/views/ticketMRW.sql deleted file mode 100644 index 1173c5180..000000000 --- a/db/routines/vn2008/views/ticketMRW.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`ticketMRW` -AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, - `Tickets`.`empresa_id` AS `empresa_id`, - `Consignatarios`.`consignatario` AS `Consignatario`, - `Consignatarios`.`domicilio` AS `DOMICILIO`, - `Consignatarios`.`poblacion` AS `POBLACION`, - `Consignatarios`.`codPostal` AS `CODPOSTAL`, - `Consignatarios`.`telefono` AS `telefono`, - `Consignatarios`.`movil` AS `movil`, - `Clientes`.`if` AS `IF`, - `Tickets`.`Id_Ticket` AS `Id_Ticket`, - `Tickets`.`warehouse_id` AS `warehouse_id`, - `Consignatarios`.`id_consigna` AS `Id_Consigna`, - `Paises`.`Codigo` AS `CodigoPais`, - `Tickets`.`Fecha` AS `Fecha`, - `province`.`province_id` AS `province_id`, - `Tickets`.`landing` AS `landing` -FROM ( - ( - ( - ( - `vn2008`.`Clientes` - JOIN `vn2008`.`Consignatarios` ON( - `Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente` - ) - ) - JOIN `vn2008`.`Tickets` ON( - `Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna` - ) - ) - JOIN `vn2008`.`province` ON( - `Consignatarios`.`province_id` = `province`.`province_id` - ) - ) - JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ) diff --git a/db/routines/vn2008/views/v_price_fixed_group.sql b/db/routines/vn2008/views/v_price_fixed_group.sql deleted file mode 100644 index d9add16ae..000000000 --- a/db/routines/vn2008/views/v_price_fixed_group.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_price_fixed_group` -AS SELECT `pf`.`warehouse_id` AS `warehouse_id`, - `pf`.`item_id` AS `item_id`, - `pf`.`rate_0` AS `rate_0`, - `pf`.`rate_1` AS `rate_1`, - `pf`.`rate_2` AS `rate_2`, - `pf`.`rate_3` AS `rate_3`, - `pf`.`date_start` AS `date_start`, - `pf`.`date_end` AS `date_end`, - `pf`.`bonus` AS `bonus`, - `pf`.`grouping` AS `grouping`, - `pf`.`Packing` AS `Packing`, - `pf`.`caja` AS `caja` -FROM `vn2008`.`v_price_fixed` `pf` -GROUP BY `pf`.`warehouse_id`, - `pf`.`item_id`, - `pf`.`date_start`, - `pf`.`date_end` diff --git a/db/routines/vn2008/views/v_ticket_amount.sql b/db/routines/vn2008/views/v_ticket_amount.sql deleted file mode 100644 index 142bec74d..000000000 --- a/db/routines/vn2008/views/v_ticket_amount.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_ticket_amount` -AS SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, - sum( - `Movimientos`.`Cantidad` * `Movimientos`.`Preu` * (100 - `Movimientos`.`Descuento`) / 100 - ) AS `amount` -FROM ( - `vn2008`.`Movimientos` - JOIN `vn2008`.`Tickets` ON( - `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket` - ) - ) -WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH -GROUP BY `Movimientos`.`Id_Ticket` diff --git a/db/routines/vn2008/views/v_warehouse.sql b/db/routines/vn2008/views/v_warehouse.sql deleted file mode 100644 index fd17b6a06..000000000 --- a/db/routines/vn2008/views/v_warehouse.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_warehouse` -AS SELECT `warehouse`.`id` AS `id`, - `warehouse`.`name` AS `almacen` -FROM `vn2008`.`warehouse` -UNION ALL -SELECT 1000 + `warehouse_alias`.`warehouse_alias_id` AS `warehouse_alias_id`, - concat(`warehouse_alias`.`alias`, '(G)') AS `concat(alias, '(G)')` -FROM `vn2008`.`warehouse_alias` diff --git a/db/routines/vn2008/views/v_xsubclien.sql b/db/routines/vn2008/views/v_xsubclien.sql deleted file mode 100644 index bbe5803e0..000000000 --- a/db/routines/vn2008/views/v_xsubclien.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_xsubclien` -AS SELECT DISTINCT `Facturas`.`Id_Cliente` AS `Id_Cliente`, - `Facturas`.`empresa_id` AS `empresa_id` -FROM `vn2008`.`Facturas` -WHERE `Facturas`.`Fecha` > `util`.`VN_CURDATE`() + INTERVAL -2 MONTH -UNION -SELECT `Recibos`.`Id_Cliente` AS `Id_Cliente`, - `Recibos`.`empresa_id` AS `empresa_id` -FROM `vn2008`.`Recibos` -WHERE `Recibos`.`Fechacobro` > `util`.`VN_CURDATE`() + INTERVAL -2 MONTH diff --git a/db/routines/vn2008/views/v_xsubcuentas.sql b/db/routines/vn2008/views/v_xsubcuentas.sql index 79f26216c..a200e4ad9 100644 --- a/db/routines/vn2008/views/v_xsubcuentas.sql +++ b/db/routines/vn2008/views/v_xsubcuentas.sql @@ -17,7 +17,7 @@ AS SELECT `Clientes`.`Cuenta` AS `COD`, `province`.`name` AS `PROVINCIA`, `Clientes`.`codPostal` AS `CODPOSTAL`, `p`.`Codigo` AS `country_code`, - `v_xsubclien`.`empresa_id` AS `empresa_id`, + sub.`empresa_id` AS `empresa_id`, substr( `Clientes`.`e-mail`, 1, @@ -39,8 +39,18 @@ FROM ( ( ( `vn2008`.`Clientes` - JOIN `vn2008`.`v_xsubclien` ON( - `Clientes`.`id_cliente` = `v_xsubclien`.`Id_Cliente` + JOIN ( + SELECT DISTINCT `Facturas`.`Id_Cliente` AS `Id_Cliente`, + `Facturas`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`Facturas` + WHERE `Facturas`.`Fecha` > `util`.`VN_CURDATE`() + INTERVAL -2 MONTH + UNION + SELECT `Recibos`.`Id_Cliente` AS `Id_Cliente`, + `Recibos`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`Recibos` + WHERE `Recibos`.`Fechacobro` > `util`.`VN_CURDATE`() + INTERVAL -2 MONTH + ) sub ON( + `Clientes`.`id_cliente` = sub.`Id_Cliente` ) ) LEFT JOIN `vn2008`.`Paises` `p` ON(`p`.`Id` = `Clientes`.`Id_Pais`) @@ -50,7 +60,7 @@ FROM ( ) ) GROUP BY `Clientes`.`id_cliente`, - `v_xsubclien`.`empresa_id` + sub.`empresa_id` UNION ALL SELECT `Proveedores`.`cuenta` AS `Cuenta`, `Proveedores`.`Proveedor` AS `Proveedor`, @@ -68,7 +78,7 @@ SELECT `Proveedores`.`cuenta` AS `Cuenta`, `prov`.`name` AS `Provincia`, `Proveedores`.`codpos` AS `CP`, `p`.`Codigo` AS `country_code`, - `v_xsubprov`.`empresa_id` AS `empresa_id`, + sub.`empresa_id` AS `empresa_id`, substr( `c`.`email`, 1, @@ -80,8 +90,22 @@ FROM ( ( ( `vn2008`.`Proveedores` - JOIN `vn2008`.`v_xsubprov` ON( - `Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id` + JOIN ( + SELECT `recibida`.`proveedor_id` AS `proveedor_id`, + `recibida`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`recibida` + WHERE `recibida`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH + GROUP BY `recibida`.`proveedor_id`, + `recibida`.`empresa_id` + UNION ALL + SELECT `pago`.`id_proveedor` AS `id_proveedor`, + `pago`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`pago` + WHERE `pago`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH + GROUP BY `pago`.`id_proveedor`, + `pago`.`empresa_id` + ) sub ON( + `Proveedores`.`Id_Proveedor` = sub.`proveedor_id` ) ) LEFT JOIN `vn2008`.`Paises` `p` ON(`p`.`Id` = `Proveedores`.`pais_id`) @@ -93,8 +117,8 @@ FROM ( LEFT JOIN `vn`.`supplierContact` `c` ON(`c`.`supplierFk` = `Proveedores`.`Id_Proveedor`) ) WHERE `Proveedores`.`oficial` <> 0 -GROUP BY `v_xsubprov`.`proveedor_id`, - `v_xsubprov`.`empresa_id` +GROUP BY sub.`proveedor_id`, + sub.`empresa_id` UNION ALL SELECT `Gastos`.`Id_Gasto` COLLATE utf8mb3_unicode_ci AS `Id_Gasto`, `Gastos`.`Gasto` COLLATE utf8mb3_unicode_ci AS `Gasto`, @@ -136,7 +160,7 @@ SELECT lpad(right(`Proveedores`.`cuenta`, 5), 10, '47510000') AS `Cuenta`, `prov`.`name` AS `Provincia`, `Proveedores`.`codpos` AS `CP`, `p`.`Codigo` AS `country_code`, - `v_xsubprov`.`empresa_id` AS `empresa_id`, + sub.`empresa_id` AS `empresa_id`, substr( `c`.`email`, 1, @@ -148,8 +172,22 @@ FROM ( ( ( `vn2008`.`Proveedores` - JOIN `vn2008`.`v_xsubprov` ON( - `Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id` + JOIN ( + SELECT `recibida`.`proveedor_id` AS `proveedor_id`, + `recibida`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`recibida` + WHERE `recibida`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH + GROUP BY `recibida`.`proveedor_id`, + `recibida`.`empresa_id` + UNION ALL + SELECT `pago`.`id_proveedor` AS `id_proveedor`, + `pago`.`empresa_id` AS `empresa_id` + FROM `vn2008`.`pago` + WHERE `pago`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH + GROUP BY `pago`.`id_proveedor`, + `pago`.`empresa_id` + ) sub ON( + `Proveedores`.`Id_Proveedor` = sub.`proveedor_id` ) ) LEFT JOIN `vn2008`.`Paises` `p` ON(`p`.`Id` = `Proveedores`.`pais_id`) @@ -165,5 +203,5 @@ WHERE ( OR `Proveedores`.`cuenta` LIKE '_____2____' ) AND `Proveedores`.`oficial` = 1 -GROUP BY `v_xsubprov`.`proveedor_id`, - `v_xsubprov`.`empresa_id` +GROUP BY sub.`proveedor_id`, + sub.`empresa_id` diff --git a/db/routines/vn2008/views/v_xsubprov.sql b/db/routines/vn2008/views/v_xsubprov.sql deleted file mode 100644 index abbedbe5e..000000000 --- a/db/routines/vn2008/views/v_xsubprov.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`v_xsubprov` -AS SELECT `recibida`.`proveedor_id` AS `proveedor_id`, - `recibida`.`empresa_id` AS `empresa_id` -FROM `vn2008`.`recibida` -WHERE `recibida`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH -GROUP BY `recibida`.`proveedor_id`, - `recibida`.`empresa_id` -UNION ALL -SELECT `pago`.`id_proveedor` AS `id_proveedor`, - `pago`.`empresa_id` AS `empresa_id` -FROM `vn2008`.`pago` -WHERE `pago`.`fecha` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH -GROUP BY `pago`.`id_proveedor`, - `pago`.`empresa_id` diff --git a/db/routines/vn2008/views/vnCreditClassification.sql b/db/routines/vn2008/views/vnCreditClassification.sql deleted file mode 100644 index 4dcc590e4..000000000 --- a/db/routines/vn2008/views/vnCreditClassification.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`vnCreditClassification` -AS SELECT `vn`.`creditClassification`.`id` AS `id`, - `vn`.`creditClassification`.`client` AS `client`, - `vn`.`creditClassification`.`dateStart` AS `dateStart`, - `vn`.`creditClassification`.`dateEnd` AS `dateEnd` -FROM `vn`.`creditClassification` diff --git a/db/routines/vn2008/views/vnCreditInsurance.sql b/db/routines/vn2008/views/vnCreditInsurance.sql deleted file mode 100644 index 305ff2f4b..000000000 --- a/db/routines/vn2008/views/vnCreditInsurance.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`vnCreditInsurance` -AS SELECT `vn`.`creditInsurance`.`id` AS `id`, - `vn`.`creditInsurance`.`creditClassification` AS `creditClassification`, - `vn`.`creditInsurance`.`credit` AS `credit`, - `vn`.`creditInsurance`.`creationDate` AS `creationDate`, - `vn`.`creditInsurance`.`grade` AS `grade` -FROM `vn`.`creditInsurance` diff --git a/db/routines/vn2008/views/vnSolunionCAP.sql b/db/routines/vn2008/views/vnSolunionCAP.sql deleted file mode 100644 index 65bd2470d..000000000 --- a/db/routines/vn2008/views/vnSolunionCAP.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`vnSolunionCAP` -AS SELECT `vn`.`solunionCAP`.`creditInsurance` AS `creditInsurance`, - `vn`.`solunionCAP`.`dateStart` AS `dateStart`, - `vn`.`solunionCAP`.`dateEnd` AS `dateEnd`, - `vn`.`solunionCAP`.`dateLeaving` AS `dateLeaving` -FROM `vn`.`solunionCAP` diff --git a/db/routines/vn2008/views/warehouse_alias.sql b/db/routines/vn2008/views/warehouse_alias.sql deleted file mode 100644 index 9a151c9d5..000000000 --- a/db/routines/vn2008/views/warehouse_alias.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`warehouse_alias` -AS SELECT `wa`.`id` AS `warehouse_alias_id`, - `wa`.`name` AS `alias` -FROM `vn`.`warehouseAlias` `wa` diff --git a/db/routines/vn2008/views/workcenter_holiday.sql b/db/routines/vn2008/views/workcenter_holiday.sql deleted file mode 100644 index 55ce6618c..000000000 --- a/db/routines/vn2008/views/workcenter_holiday.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`workcenter_holiday` -AS SELECT `wh`.`workCenterFk` AS `workcenter_id`, - `wh`.`days` AS `day`, - `wh`.`year` AS `year` -FROM `vn`.`workCenterHoliday` `wh` diff --git a/db/routines/vn2008/views/zoneNickname.sql b/db/routines/vn2008/views/zoneNickname.sql deleted file mode 100644 index 67a126851..000000000 --- a/db/routines/vn2008/views/zoneNickname.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`zoneNickname` -AS SELECT `ap`.`warehouse_id` AS `warehouse_id`, - `ap`.`agency_id` AS `agency_id`, - `ap`.`zona` AS `zona`, - concat( - 'ZONA ', - `ap`.`zona`, - ' ', - IF(`ap`.`zona` = 20, 'Madrid', `p`.`name`) - ) AS `alias` -FROM ( - `vn2008`.`Agencias_province` `ap` - JOIN `vn2008`.`province` `p` ON(`p`.`province_id` = `ap`.`province_id`) - ) -GROUP BY `ap`.`zona`, - `ap`.`warehouse_id`, - `ap`.`agency_id` diff --git a/db/versions/10858-yellowPaniculata/00-firstScript.sql b/db/versions/10858-yellowPaniculata/00-firstScript.sql new file mode 100644 index 000000000..b6642ed66 --- /dev/null +++ b/db/versions/10858-yellowPaniculata/00-firstScript.sql @@ -0,0 +1,4 @@ +REVOKE SELECT, INSERT, UPDATE ON TABLE vn2008.Rutas_Master FROM productionAssi; +REVOKE SELECT ON TABLE vn2008.Rutas_monitor FROM employee; +REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.tarifas FROM buyer; +REVOKE SELECT, UPDATE ON TABLE vn2008.tarifas FROM buyerBoss; \ No newline at end of file diff --git a/db/versions/10861-turquoiseChico/00-firstScript.sql b/db/versions/10861-turquoiseChico/00-firstScript.sql new file mode 100644 index 000000000..4358fc852 --- /dev/null +++ b/db/versions/10861-turquoiseChico/00-firstScript.sql @@ -0,0 +1 @@ +REVOKE SELECT ON TABLE vn2008.Vistas FROM employee;