feat #7181 Rollback creditInsurance_getRisk
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ccc9251d39
commit
eb9f81c81d
|
@ -0,0 +1,42 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`()
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve el riesgo de los clientes que estan asegurados
|
||||||
|
*/
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt
|
||||||
|
(PRIMARY KEY (clientFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT cc.client clientFk, ci.grade
|
||||||
|
FROM creditClassification cc
|
||||||
|
JOIN creditInsurance ci ON cc.id = ci.creditClassification
|
||||||
|
WHERE dateEnd IS NULL
|
||||||
|
ORDER BY ci.creationDate DESC
|
||||||
|
LIMIT 10000000000000000000) t1
|
||||||
|
GROUP BY clientFk;
|
||||||
|
|
||||||
|
CALL client_getDebt(util.VN_CURDATE());
|
||||||
|
|
||||||
|
SELECT c.id,
|
||||||
|
c.name,
|
||||||
|
c.credit clientCredit,
|
||||||
|
c.creditInsurance solunion,
|
||||||
|
CAST(r.risk AS DECIMAL(10,0)) risk,
|
||||||
|
CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive,
|
||||||
|
cac.invoiced billedAnnually,
|
||||||
|
c.dueDay,
|
||||||
|
cgd.grade,
|
||||||
|
c2.country
|
||||||
|
FROM tmp.clientGetDebt cgd
|
||||||
|
LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk
|
||||||
|
JOIN client c ON c.id = cgd.clientFk
|
||||||
|
JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk
|
||||||
|
JOIN country c2 ON c2.id = c.countryFk
|
||||||
|
GROUP BY c.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE
|
||||||
|
tmp.risk,
|
||||||
|
tmp.clientGetDebt;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -2,4 +2,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`()
|
||||||
BEGIN
|
BEGIN
|
||||||
END;
|
END;
|
||||||
|
|
||||||
GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss;
|
GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financial;
|
||||||
|
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`()
|
||||||
|
BEGIN
|
||||||
|
END;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON PROCEDURE vn.creditInsurance_getRisk TO financial;
|
||||||
|
|
Loading…
Reference in New Issue