refactor: refs #6780 Changed dependences from vn2008 to vn #1987

Merged
guillermo merged 6 commits from 6780-changeViewDependencesVn2008 into dev 2024-02-02 11:44:59 +00:00
17 changed files with 30 additions and 404 deletions

View File

@ -47,7 +47,7 @@ BEGIN
LEFT JOIN vn.deliveryMethod dm ON dm.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.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna
LEFT JOIN vn2008.province p ON p.province_id = cs.province_id LEFT JOIN vn2008.province p ON p.province_id = cs.province_id
LEFT JOIN vn2008.warehouse w ON w.id = t.warehouse_id LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id
WHERE bt.fecha >= vLastMonth AND r.mercancia; WHERE bt.fecha >= vLastMonth AND r.mercancia;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -88,6 +88,7 @@ BEGIN
FROM vn.expeditionTruck FROM vn.expeditionTruck
WHERE eta < v3Month; WHERE eta < v3Month;
DELETE FROM XDiario WHERE FECHA < v3Month OR FECHA IS NULL;
-- borrar travels sin entradas -- borrar travels sin entradas
DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
CREATE TEMPORARY TABLE tmp.thermographToDelete CREATE TEMPORARY TABLE tmp.thermographToDelete

View File

@ -44,7 +44,7 @@ BEGIN
IF vCounter > 0 OR vASIEN > 0 THEN IF vCounter > 0 OR vASIEN > 0 THEN
UPDATE vn2008.XDiario x UPDATE vn.XDiario x
JOIN vn.ledgerConfig lc ON lc.lastBookEntry = x.ASIEN JOIN vn.ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
SET x.ASIEN = vASIEN; SET x.ASIEN = vASIEN;

View File

@ -7,19 +7,19 @@ BEGIN
group_concat(CONCAT(' Asiento: ', ASIEN, '- importe:', quadre) SEPARATOR ' \r\n ') group_concat(CONCAT(' Asiento: ', ASIEN, '- importe:', quadre) SEPARATOR ' \r\n ')
FROM ( FROM (
SELECT ASIEN, SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) quadre SELECT ASIEN, SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) quadre
FROM XDiario FROM vn.XDiario
WHERE enlazado = FALSE WHERE enlazado = FALSE
GROUP BY ASIEN GROUP BY ASIEN
HAVING ABS(SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0))) > 0.01 HAVING ABS(SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0))) > 0.01
) t ) t
HAVING count(*) > 0; HAVING count(*) > 0;
UPDATE XDiario XD UPDATE vn.XDiario XD
INNER JOIN( INNER JOIN(
SELECT XD.id, SUBCTA, Quadre FROM XDiario XD SELECT XD.id, SUBCTA, Quadre FROM vn.XDiario XD
INNER JOIN ( INNER JOIN (
SELECT ASIEN, SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) as Quadre SELECT ASIEN, SUM(IFNULL(ROUND(Eurodebe,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) as Quadre
FROM XDiario FROM vn.XDiario
WHERE enlazado = FALSE WHERE enlazado = FALSE
GROUP BY ASIEN GROUP BY ASIEN
HAVING Quadre != 0 HAVING Quadre != 0

View File

@ -23,7 +23,6 @@ proc: BEGIN
DELETE FROM cdr WHERE calldate < vDate18; DELETE FROM cdr WHERE calldate < vDate18;
DELETE FROM Monitoring WHERE ODBC_TIME < vDate; DELETE FROM Monitoring WHERE ODBC_TIME < vDate;
DELETE FROM Conteo WHERE Fecha < 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 mail WHERE DATE_ODBC < vDate;
DELETE FROM expeditions_deleted WHERE odbc_date < vDate26; DELETE FROM expeditions_deleted WHERE odbc_date < vDate26;
DELETE FROM Movimientos_mark WHERE odbc_date < vDate; DELETE FROM Movimientos_mark WHERE odbc_date < vDate;

View File

@ -25,7 +25,7 @@ BEGIN
FROM Clientes FROM Clientes
WHERE Id_Cliente = idCLI; WHERE Id_Cliente = idCLI;
CALL vn.ledger_next(max_asien); CALL vn.ledger_next(max_asien);
INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id) INSERT INTO vn.XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
SELECT max_asien,datFEC,SUBCTA,CONTRA,strCONCEPTO,EURODEBE,EUROHABER,idEMP SELECT max_asien,datFEC,SUBCTA,CONTRA,strCONCEPTO,EURODEBE,EUROHABER,idEMP
FROM(SELECT cuenta_banco SUBCTA, cuenta_cliente CONTRA, 0 EURODEBE, dblIMPORTE EUROHABER FROM(SELECT cuenta_banco SUBCTA, cuenta_cliente CONTRA, 0 EURODEBE, dblIMPORTE EUROHABER
UNION ALL UNION ALL

View File

@ -31,7 +31,7 @@ BEGIN
stock.available stock.available
FROM vn2008.Tickets t FROM vn2008.Tickets t
JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia
JOIN vn2008.warehouse wh ON wh.id = t.warehouse_id JOIN vn.warehouse wh ON wh.id = t.warehouse_id
JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket
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 vn2008.Tipos tp ON tp.tipo_id = i.tipo_id
@ -88,8 +88,8 @@ BEGIN
FROM vn2008.Compres c FROM vn2008.Compres c
JOIN vn2008.Entradas e ON e.Id_Entrada = c.Id_Entrada JOIN vn2008.Entradas e ON e.Id_Entrada = c.Id_Entrada
JOIN vn2008.travel tr ON tr.id = e.travel_id JOIN vn2008.travel tr ON tr.id = e.travel_id
JOIN vn2008.warehouse whi ON whi.id = tr.warehouse_id JOIN vn.warehouse whi ON whi.id = tr.warehouse_id
JOIN vn2008.warehouse who ON who.id = tr.warehouse_id_out JOIN vn.warehouse who ON who.id = tr.warehouse_id_out
JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article
JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id
JOIN vn.confectionType ct ON ct.id = tp.confeccion JOIN vn.confectionType ct ON ct.id = tp.confeccion

View File

@ -1,14 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Vehiculos`
AS SELECT `v`.`id` AS `Id_Vehiculo`,
`v`.`numberPlate` AS `Matricula`,
`v`.`tradeMark` AS `Marca`,
`v`.`model` AS `Modelo`,
`v`.`companyFk` AS `empresa_id`,
`v`.`warehouseFk` AS `warehouseFk`,
`v`.`description` AS `description`,
`v`.`m3` AS `m3`,
`v`.`isActive` AS `active`,
`v`.`deliveryPointFk` AS `deliveryPointFk`
FROM `vn`.`vehicle` `v`

View File

@ -1,56 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`XDiario`
AS SELECT `d`.`id` AS `id`,
`d`.`ASIEN` AS `ASIEN`,
`d`.`FECHA` AS `FECHA`,
`d`.`SUBCTA` AS `SUBCTA`,
`d`.`CONTRA` AS `CONTRA`,
`d`.`CONCEPTO` AS `CONCEPTO`,
`d`.`EURODEBE` AS `EURODEBE`,
`d`.`EUROHABER` AS `EUROHABER`,
`d`.`BASEEURO` AS `BASEEURO`,
`d`.`SERIE` AS `SERIE`,
`d`.`FACTURA` AS `FACTURA`,
`d`.`IVA` AS `IVA`,
`d`.`RECEQUIV` AS `RECEQUIV`,
`d`.`CLAVE` AS `CLAVE`,
`d`.`CAMBIO` AS `CAMBIO`,
`d`.`DEBEME` AS `DEBEME`,
`d`.`HABERME` AS `HABERME`,
`d`.`AUXILIAR` AS `AUXILIAR`,
`d`.`MONEDAUSO` AS `MONEDAUSO`,
`d`.`TIPOOPE` AS `TIPOOPE`,
`d`.`NFACTICK` AS `NFACTICK`,
`d`.`TERIDNIF` AS `TERIDNIF`,
`d`.`TERNIF` AS `TERNIF`,
`d`.`TERNOM` AS `TERNOM`,
`d`.`OPBIENES` AS `OPBIENES`,
`d`.`L340` AS `L340`,
`d`.`enlazado` AS `enlazado`,
`d`.`FECHA_EX` AS `FECHA_EX`,
`d`.`LRECT349` AS `LRECT349`,
`d`.`empresa_id` AS `empresa_id`,
`d`.`LDIFADUAN` AS `LDIFADUAN`,
`d`.`METAL` AS `METAL`,
`d`.`METALIMP` AS `METALIMP`,
`d`.`CLIENTE` AS `CLIENTE`,
`d`.`METALEJE` AS `METALEJE`,
`d`.`FECHA_OP` AS `FECHA_OP`,
`d`.`FACTURAEX` AS `FACTURAEX`,
`d`.`TIPOCLAVE` AS `TIPOCLAVE`,
`d`.`TIPOEXENCI` AS `TIPOEXENCI`,
`d`.`TIPONOSUJE` AS `TIPONOSUJE`,
`d`.`TIPOFACT` AS `TIPOFACT`,
`d`.`TIPORECTIF` AS `TIPORECTIF`,
`d`.`SERIE_RT` AS `SERIE_RT`,
`d`.`FACTU_RT` AS `FACTU_RT`,
`d`.`BASEIMP_RT` AS `BASEIMP_RT`,
`d`.`BASEIMP_RF` AS `BASEIMP_RF`,
`d`.`RECTIFICA` AS `RECTIFICA`,
`d`.`FECHA_RT` AS `FECHA_RT`,
`d`.`created` AS `created`,
`d`.`updated` AS `updated`,
`d`.`FECREGCON` AS `FECREGCON`,
`d`.`enlazadoSage` AS `enlazadoSage`
FROM `vn`.`XDiario` `d`

View File

@ -53,7 +53,7 @@ AS SELECT `TP`.`Id_Tipo` AS `Familia`,
`A`.`Color` AS `Color`, `A`.`Color` AS `Color`,
`A`.`Min` AS `Min`, `A`.`Min` AS `Min`,
`C`.`Costefijo` + `C`.`Embalajefijo` + `C`.`Comisionfija` + `C`.`Portefijo` AS `Coste`, `C`.`Costefijo` + `C`.`Embalajefijo` + `C`.`Comisionfija` + `C`.`Portefijo` AS `Coste`,
`W_OUT`.`fuente` AS `fuente`, `W_OUT`.`isFeedStock` AS `fuente`,
IF( IF(
`cb`.`Volumen` > 0, `cb`.`Volumen` > 0,
`cb`.`Volumen`, `cb`.`Volumen`,
@ -73,9 +73,9 @@ FROM (
) )
JOIN `vn2008`.`travel` `TR` ON(`TR`.`id` = `E`.`travel_id`) JOIN `vn2008`.`travel` `TR` ON(`TR`.`id` = `E`.`travel_id`)
) )
JOIN `vn2008`.`warehouse` `W_IN` ON(`W_IN`.`id` = `TR`.`warehouse_id`) JOIN `vn`.`warehouse` `W_IN` ON(`W_IN`.`id` = `TR`.`warehouse_id`)
) )
JOIN `vn2008`.`warehouse` `W_OUT` ON(`W_OUT`.`id` = `TR`.`warehouse_id_out`) JOIN `vn`.`warehouse` `W_OUT` ON(`W_OUT`.`id` = `TR`.`warehouse_id_out`)
) )
JOIN `vn2008`.`Articles` `A` ON(`C`.`Id_Article` = `A`.`Id_Article`) JOIN `vn2008`.`Articles` `A` ON(`C`.`Id_Article` = `A`.`Id_Article`)
) )
@ -85,6 +85,6 @@ FROM (
) )
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`) JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
) )
WHERE `W_IN`.`fuente` = 0 WHERE `W_IN`.`isFeedStock` = 0
AND `E`.`Inventario` = 0 AND `E`.`Inventario` = 0
AND `E`.`Redada` = 0 AND `E`.`Redada` = 0

View File

@ -1,68 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_ventes`
AS SELECT `Agencias`.`Agencia` AS `Agencia`,
`A`.`Categoria` AS `Categoria`,
`A`.`tipo_id` AS `tipo_id`,
`A`.`Medida` AS `Medida`,
`A`.`Article` AS `Article`,
`A`.`Color` AS `Color`,
`CS`.`Id_cliente` AS `Id_Cliente`,
`TP`.`Id_Tipo` AS `Tipo`,
`T`.`Factura` AS `Factura`,
`T`.`warehouse_id` AS `warehouse_id`,
`M`.`Id_Movimiento` AS `Id_Movimiento`,
`M`.`Id_Article` AS `Id_Article`,
`TP`.`Id_Tipo` AS `Familia`,
`M`.`Id_Ticket` AS `Id_Ticket`,
`M`.`Concepte` AS `Concepte`,
`M`.`Cantidad` AS `Cantidad`,
`M`.`quantity` AS `quantity`,
`M`.`Preu` AS `Preu`,
`M`.`Descuento` AS `Descuento`,
IF(
`T`.`Fecha` >= '2015-10-01',
`M`.`CostFixat`,
`M`.`Preu` * (100 - `M`.`Descuento`) / 100
) AS `CostFixat`,
`M`.`Reservado` AS `Reservado`,
`M`.`OK` AS `OK`,
`M`.`PrecioFijado` AS `PrecioFijado`,
`M`.`odbc_date` AS `odbc_date`,
cast(`T`.`Fecha` AS date) AS `Fecha`,
`T`.`Fecha` AS `FechaCompleta`,
`CS`.`consignatario` AS `Alias`,
`T`.`Id_Consigna` AS `Id_Consigna`,
`M`.`Cantidad` * `M`.`Preu` * (100 - `M`.`Descuento`) / 100 AS `Importe`,
`O`.`Origen` AS `Origen`,
`TP`.`reino_id` AS `reino_id`,
`C`.`invoice` AS `invoice`,
`A`.`producer_id` AS `producer_id`
FROM (
(
(
(
(
(
(
(
`vn2008`.`Movimientos` `M`
JOIN `vn2008`.`Tickets` `T` ON(`M`.`Id_Ticket` = `T`.`Id_Ticket`)
)
JOIN `vn2008`.`Consignatarios` `CS` ON(`CS`.`id_consigna` = `T`.`Id_Consigna`)
)
JOIN `vn2008`.`Clientes` `C` ON(`CS`.`Id_cliente` = `C`.`id_cliente`)
)
JOIN `vn2008`.`Articles` `A` ON(`M`.`Id_Article` = `A`.`Id_Article`)
)
JOIN `vn2008`.`Origen` `O` ON(`O`.`id` = `A`.`id_origen`)
)
JOIN `vn2008`.`Tipos` `TP` ON(`A`.`tipo_id` = `TP`.`tipo_id`)
)
JOIN `vn2008`.`reinos` `r` ON(`TP`.`reino_id` = `r`.`id`)
)
JOIN `vn2008`.`Agencias` ON(`Agencias`.`Id_Agencia` = `T`.`Id_Agencia`)
)
WHERE `T`.`Fecha` >= '2013-01-01'
AND `C`.`real` > 0
AND `r`.`id` <> 6

View File

@ -1,207 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_xsubcuentas`
AS SELECT `Clientes`.`Cuenta` AS `COD`,
`Clientes`.`razonSocial` AS `TITULO`,
concat(
IF(
`p`.`CEE` = 1
AND ascii(left(`Clientes`.`if`, 1)) < 58,
`p`.`Codigo`,
''
),
`Clientes`.`if`
) AS `NIF`,
`Clientes`.`domicilio` AS `DOMICILIO`,
`Clientes`.`poblacion` AS `POBLACION`,
`province`.`name` AS `PROVINCIA`,
`Clientes`.`codPostal` AS `CODPOSTAL`,
`p`.`Codigo` AS `country_code`,
sub.`empresa_id` AS `empresa_id`,
substr(
`Clientes`.`e-mail`,
1,
coalesce(nullif(locate(',', `Clientes`.`e-mail`), 0), 99) - 1
) AS `EMAIL`,
IF(
`p`.`CEE` = 0
OR `p`.`CEE` = 1
AND `Clientes`.`vies` = 0,
1,
IF(
`p`.`CEE` = 1
AND `Clientes`.`vies` <> 0,
2,
4
)
) AS `IDNIF`
FROM (
(
(
`vn2008`.`Clientes`
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`)
)
JOIN `vn2008`.`province` ON(
`Clientes`.`province_id` = `province`.`province_id`
)
)
GROUP BY `Clientes`.`id_cliente`,
sub.`empresa_id`
UNION ALL
SELECT `Proveedores`.`cuenta` AS `Cuenta`,
`Proveedores`.`Proveedor` AS `Proveedor`,
concat(
IF(
`p`.`CEE` = 1
AND ascii(left(`Proveedores`.`NIF`, 1)) < 58,
`p`.`Codigo`,
''
),
`Proveedores`.`NIF`
) AS `NIF`,
`Proveedores`.`Domicilio` AS `Domicilio`,
`Proveedores`.`Localidad` AS `Localidad`,
`prov`.`name` AS `Provincia`,
`Proveedores`.`codpos` AS `CP`,
`p`.`Codigo` AS `country_code`,
sub.`empresa_id` AS `empresa_id`,
substr(
`c`.`email`,
1,
coalesce(nullif(locate(',', `c`.`email`), 0), 99) - 1
) AS `EMAIL`,
IF(`p`.`CEE` = 0, 1, IF(`p`.`CEE` = 1, 2, 4)) AS `IDNIF`
FROM (
(
(
(
`vn2008`.`Proveedores`
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`)
)
LEFT JOIN `vn2008`.`province` `prov` ON(
`prov`.`province_id` = `Proveedores`.`province_id`
)
)
LEFT JOIN `vn`.`supplierContact` `c` ON(`c`.`supplierFk` = `Proveedores`.`Id_Proveedor`)
)
WHERE `Proveedores`.`oficial` <> 0
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`,
NULL AS `NULL`,
NULL AS `My_exp_NULL`,
NULL AS `My_exp_1_NULL`,
NULL AS `My_exp_2_NULL`,
NULL AS `My_exp_3_NULL`,
NULL AS `country_code`,
`e`.`id` AS `id`,
NULL AS `EMAIL`,
1 AS `IDNIF`
FROM (
`vn2008`.`Gastos`
JOIN `vn2008`.`empresa` `e` ON(`e`.`id` = 442)
)
UNION ALL
SELECT `Bancos`.`Cuenta` AS `Cuenta`,
`Bancos`.`Banco` AS `Banco`,
NULL AS `NULL`,
NULL AS `My_exp_NULL`,
NULL AS `My_exp_1_NULL`,
NULL AS `My_exp_2_NULL`,
NULL AS `My_exp_3_NULL`,
NULL AS `country_code`,
`e`.`id` AS `id`,
NULL AS `EMAIL`,
1 AS `IDNIF`
FROM (
`vn2008`.`Bancos`
JOIN `vn2008`.`empresa` `e` ON(`e`.`id` = 442)
)
UNION ALL
SELECT lpad(right(`Proveedores`.`cuenta`, 5), 10, '47510000') AS `Cuenta`,
`Proveedores`.`Proveedor` AS `Proveedor`,
`Proveedores`.`NIF` AS `NIF`,
`Proveedores`.`Domicilio` AS `Domicilio`,
`Proveedores`.`Localidad` AS `Localidad`,
`prov`.`name` AS `Provincia`,
`Proveedores`.`codpos` AS `CP`,
`p`.`Codigo` AS `country_code`,
sub.`empresa_id` AS `empresa_id`,
substr(
`c`.`email`,
1,
coalesce(nullif(locate(',', `c`.`email`), 0), 99) - 1
) AS `EMAIL`,
IF(`p`.`CEE` = 0, 1, IF(`p`.`CEE` = 1, 2, 4)) AS `IDNIF`
FROM (
(
(
(
`vn2008`.`Proveedores`
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`)
)
LEFT JOIN `vn2008`.`province` `prov` ON(
`prov`.`province_id` = `Proveedores`.`province_id`
)
)
LEFT JOIN `vn`.`supplierContact` `c` ON(`c`.`supplierFk` = `Proveedores`.`Id_Proveedor`)
)
WHERE (
`Proveedores`.`cuenta` LIKE '_____3____'
OR `Proveedores`.`cuenta` LIKE '_____2____'
)
AND `Proveedores`.`oficial` = 1
GROUP BY sub.`proveedor_id`,
sub.`empresa_id`

View File

@ -1,8 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`versiones`
AS SELECT `m`.`app` AS `programa`,
`m`.`version` AS `version`,
0 AS `critical`
FROM `vn`.`mdbVersion` `m`
WHERE `m`.`branchFk` = 'master'

View File

@ -1,21 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`warehouse`
AS SELECT `w`.`id` AS `id`,
`w`.`name` AS `name`,
`w`.`isInventory` AS `inventario`,
`w`.`isFeedStock` AS `fuente`,
`w`.`isComparative` AS `is_comparative`,
`w`.`hasComission` AS `comisionantes`,
`w`.`hasAvailable` AS `reserve`,
`w`.`isManaged` AS `isManaged`,
`w`.`isForTicket` AS `tpv`,
`w`.`hasStowaway` AS `hasStowaway`,
`w`.`hasDms` AS `hasDms`,
`w`.`addressName` AS `address_name`,
`w`.`delay` AS `delay`,
`w`.`countryFk` AS `Id_Paises`,
`w`.`labelZone` AS `zone_label`,
`w`.`valuatedInventory` AS `valuatedInventory`,
`w`.`hasConfectionTeam` AS `hasConfectionTeam`
FROM `vn`.`warehouse` `w`

View File

@ -1,8 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`workerDocument`
AS SELECT `vn`.`workerDocument`.`id` AS `id`,
`vn`.`workerDocument`.`worker` AS `worker`,
`vn`.`workerDocument`.`document` AS `document`,
`vn`.`workerDocument`.`isReadableByWorker` AS `isReadableByWorker`
FROM `vn`.`workerDocument`

View File

@ -1,7 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`workerTeam`
AS SELECT `wt`.`team` AS `team`,
`wt`.`id` AS `id`,
`wt`.`workerFk` AS `user`
FROM `vn`.`workerTeam` `wt`

View File

@ -0,0 +1,15 @@
REVOKE UPDATE ON TABLE vn2008.Vehiculos FROM officeBoss;
REVOKE SELECT ON TABLE vn2008.Vehiculos FROM claimManager;
REVOKE SELECT, INSERT, UPDATE ON TABLE vn2008.Vehiculos FROM deliveryAssistant;
REVOKE SELECT ON TABLE vn2008.versiones FROM employee;
REVOKE INSERT ON TABLE vn2008.XDiario FROM financial;
REVOKE SELECT, INSERT, UPDATE ON TABLE vn2008.XDiario FROM buyer;
REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.XDiario FROM administrative;
REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.XDiario FROM hr;
REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLE vn2008.XDiario FROM buyerBoss;
REVOKE SELECT, INSERT ON TABLE vn2008.workerDocument FROM hr;
REVOKE SELECT ON TABLE vn2008.warehouse FROM guest;
REVOKE SELECT ON TABLE vn2008.warehouse FROM employee;
REVOKE SELECT, INSERT, UPDATE ON TABLE vn2008.workerTeam FROM salesAssistant;
REVOKE DELETE ON TABLE vn2008.workerTeam FROM salesBoss;
REVOKE SELECT ON TABLE vn2008.v_compres FROM administrative;