feat: refs #6371 cleanTablesFix #2011
|
@ -1,16 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `bi`.`nz`(vData DOUBLE)
|
|
||||||
RETURNS double
|
|
||||||
DETERMINISTIC
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Devuelve 0, si el parámetro es NULL:
|
|
||||||
*/
|
|
||||||
DECLARE vResult DOUBLE;
|
|
||||||
|
|
||||||
SET vResult = IFNULL(vData,0);
|
|
||||||
|
|
||||||
RETURN vResult;
|
|
||||||
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -130,13 +130,13 @@ BEGIN
|
||||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||||
UPDATE bi.claims_ratio cr
|
UPDATE bi.claims_ratio cr
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT Id_Cliente, nz(SUM(Importe)) AS Greuge
|
SELECT Id_Cliente, IFNULL(SUM(Importe), 0) AS Greuge
|
||||||
FROM vn2008.Greuges
|
FROM vn2008.Greuges
|
||||||
WHERE Fecha <= util.VN_CURDATE()
|
WHERE Fecha <= util.VN_CURDATE()
|
||||||
GROUP BY Id_Cliente
|
GROUP BY Id_Cliente
|
||||||
) g ON g.Id_Cliente = cr.Id_Cliente
|
) g ON g.Id_Cliente = cr.Id_Cliente
|
||||||
SET recobro = GREATEST(0,round(nz(Greuge) /
|
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
|
||||||
(nz(Consumo) * vMonthToRefund / 12 ) ,3));
|
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
|
||||||
|
|
||||||
-- Protección neonatos
|
-- Protección neonatos
|
||||||
UPDATE bi.claims_ratio cr
|
UPDATE bi.claims_ratio cr
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`nz`(vQuantity DOUBLE)
|
|
||||||
RETURNS double
|
|
||||||
DETERMINISTIC
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
DECLARE vResult DOUBLE;
|
|
||||||
|
|
||||||
SET vResult = IFNULL(vQuantity,0);
|
|
||||||
|
|
||||||
RETURN vResult;
|
|
||||||
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -48,7 +48,7 @@ BEGIN
|
||||||
SELECT lc.companyFk,
|
SELECT lc.companyFk,
|
||||||
c.id,
|
c.id,
|
||||||
0,
|
0,
|
||||||
- (NZ(lc.credit) - NZ(lc.debit))
|
- (IFNULL(lc.credit, 0) - IFNULL(lc.debit, 0))
|
||||||
FROM tmp.ledgerComparative lc
|
FROM tmp.ledgerComparative lc
|
||||||
JOIN client c ON c.accountingAccount = lc.account
|
JOIN client c ON c.accountingAccount = lc.account
|
||||||
WHERE lc.`date` BETWEEN vDateFrom AND vDateTo
|
WHERE lc.`date` BETWEEN vDateFrom AND vDateTo
|
||||||
|
|
|
@ -60,7 +60,7 @@ BEGIN
|
||||||
SELECT lc.companyFk,
|
SELECT lc.companyFk,
|
||||||
s.id,
|
s.id,
|
||||||
0,
|
0,
|
||||||
- (NZ(lc.debit) - NZ(lc.credit))
|
- (IFNULL(lc.debit, 0) - IFNULL(lc.credit, 0))
|
||||||
FROM tmp.ledgerComparative lc
|
FROM tmp.ledgerComparative lc
|
||||||
JOIN supplier s ON s.account = lc.account
|
JOIN supplier s ON s.account = lc.account
|
||||||
WHERE lc.`date` BETWEEN vDateFrom AND vDateTo
|
WHERE lc.`date` BETWEEN vDateFrom AND vDateTo
|
||||||
|
|
|
@ -4,22 +4,22 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE intcounter INT;
|
DECLARE intcounter INT;
|
||||||
DECLARE vShipFk INT;
|
DECLARE vShipFk INT;
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NEW.freightItemFk IS NOT NULL THEN
|
IF NEW.freightItemFk IS NOT NULL THEN
|
||||||
|
|
||||||
UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
|
UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk;
|
||||||
|
|
||||||
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
|
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
|
||||||
FROM expedition e
|
FROM expedition e
|
||||||
INNER JOIN ticket t1 ON e.ticketFk = t1.id
|
INNER JOIN ticket t1 ON e.ticketFk = t1.id
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
|
||||||
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
|
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
|
||||||
AND t1.warehouseFk = t2.warehouseFk
|
AND t1.warehouseFk = t2.warehouseFk
|
||||||
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
|
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
|
||||||
AND t1.agencyModeFk = t2.agencyModeFk;
|
AND t1.agencyModeFk = t2.agencyModeFk;
|
||||||
|
|
||||||
SET NEW.`counter` = intcounter;
|
SET NEW.`counter` = intcounter;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn2008`.`nz`(dblCANTIDAD DOUBLE)
|
|
||||||
RETURNS double
|
|
||||||
DETERMINISTIC
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
DECLARE dblRESULT DOUBLE;
|
|
||||||
|
|
||||||
SET dblRESULT = IFNULL(dblCANTIDAD,0);
|
|
||||||
|
|
||||||
RETURN dblRESULT;
|
|
||||||
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
Loading…
Reference in New Issue