diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql deleted file mode 100644 index 439eba5ad..000000000 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ /dev/null @@ -1,100 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`emailYesterdayPurchasesByConsigna`(IN v_Date DATE, IN v_Client_Id INT) -BEGIN - - DECLARE MyIdTicket BIGINT; - DECLARE MyAlias VARCHAR(50); - DECLARE MyDomicilio VARCHAR(255); - DECLARE MyPoblacion VARCHAR(25); - DECLARE MyImporte DOUBLE; - DECLARE MyMailTo VARCHAR(250); - DECLARE MyMailReplyTo VARCHAR(250); - DECLARE done INT DEFAULT FALSE; - DECLARE emptyList INT DEFAULT 0; - DECLARE txt TEXT; - - DECLARE rs CURSOR FOR - 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 ( - 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; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; - - SET v_Date = IFNULL(v_Date, util.yesterday()); - - OPEN rs; - - FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion; - - SET emptyList = done; - - SET txt = CONCAT('

', - '

Relación de envíos.

', - '

Dia: ', v_Date, '

'); - - WHILE NOT done DO - - SET txt = CONCAT(txt, '

', - ' - - - - - - -
- Ticket ', MyIdTicket,' ', MyImporte, ' €
' - , ' ', MyAlias, '
' - , ' ', MyDomicilio, '(', MyPoblacion, ')'); - - FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion; - - END WHILE; - - SET txt = CONCAT( - txt, - '', - '', - '
', - '

Puede acceder al detalle de los albaranes haciendo click sobre el número de Ticket', - '

Muchas gracias por su confianza

', - '

'); - - -- Envío del email - IF emptyList = 0 THEN - - SELECT CONCAT(`e-mail`,',pako@verdnatura.es') INTO MyMailTo - FROM Clientes - WHERE Id_Cliente = v_Client_Id AND `e-mail`>''; - - IF v_Client_Id = 7818 THEN -- LOEWE - SET MyMailTo = 'isabel@elisabethblumen.com,emunozca@loewe.es,pako@verdnatura.es'; - END IF; - - CALL vn.mail_insert( - IFNULL(MyMailTo,'pako.natek@gmail.com'), - 'pako@verdnatura.es', - 'Resumen de pedidos preparados', - txt - ); - - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql deleted file mode 100644 index c414cf1c4..000000000 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql +++ /dev/null @@ -1,27 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`emailYesterdayPurchasesLauncher`() -BEGIN - -DECLARE done INT DEFAULT 0; -DECLARE vMyClientId INT; - -DECLARE rs CURSOR FOR -SELECT Id_Cliente -FROM Clientes -WHERE EYPBC != 0; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; - -OPEN rs; - -FETCH rs INTO vMyClientId; - -WHILE NOT done DO - - CALL emailYesterdayPurchasesByConsigna(util.yesterday(), vMyClientId); - - FETCH rs INTO vMyClientId; - -END WHILE; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql deleted file mode 100644 index b20e44c79..000000000 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ /dev/null @@ -1,51 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN) -BEGIN - -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; - -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 - -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 - -join Articles a using(Id_Article) -group by Id_Article; - -end if; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql deleted file mode 100644 index c49d1b88a..000000000 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ /dev/null @@ -1,78 +0,0 @@ -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 - - 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 - -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; - -END$$ -DELIMITER ; diff --git a/db/versions/10918-wheatRose/00-firstScript.sql b/db/versions/10918-wheatRose/00-firstScript.sql new file mode 100644 index 000000000..5d0fb1c32 --- /dev/null +++ b/db/versions/10918-wheatRose/00-firstScript.sql @@ -0,0 +1,2 @@ +DELETE FROM bs.nightTask + WHERE `procedure` = 'emailYesterdayPurchasesLauncher';