eat: Turn issues into calculated columns refs#7213
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
b1af625937
commit
f89ca786df
|
@ -8,6 +8,7 @@ BEGIN
|
||||||
/**
|
/**
|
||||||
* Check if the ticket is small based on the volume and amount parameters.
|
* Check if the ticket is small based on the volume and amount parameters.
|
||||||
*
|
*
|
||||||
|
* @param vSelf Id ticket
|
||||||
* @return BOOL
|
* @return BOOL
|
||||||
*/
|
*/
|
||||||
DECLARE vIsTooLittle TINYINT(1);
|
DECLARE vIsTooLittle TINYINT(1);
|
||||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Update column sale.problem with a problem code
|
* Update column sale.problem with a problem code
|
||||||
|
* @param vProblemCode Code to set or unset
|
||||||
* @table tmp.sale(saleFk, hasProblem)
|
* @table tmp.sale(saleFk, hasProblem)
|
||||||
*/
|
*/
|
||||||
UPDATE sale s
|
UPDATE sale s
|
||||||
|
|
|
@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblem`(
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Update column ticket.problem with a problem code
|
* Update column ticket.problem with a problem code
|
||||||
|
*
|
||||||
|
* @param vProblemCode Code to set or unset
|
||||||
* @table tmp.ticket(ticketFk, hasProblem)
|
* @table tmp.ticket(ticketFk, hasProblem)
|
||||||
*/
|
*/
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
|
|
|
@ -6,7 +6,7 @@ BEGIN
|
||||||
* Update the problem of tickets, depending on whether
|
* Update the problem of tickets, depending on whether
|
||||||
* the client taxDataCheched is verified or not
|
* the client taxDataCheched is verified or not
|
||||||
*
|
*
|
||||||
* @param vSelf Id ticket, if NULL ALL tickets
|
* @param vSelf Id ticket, if NULL all tickets
|
||||||
*/
|
*/
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(INDEX(ticketFk))
|
(INDEX(ticketFk))
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`tticket_setProblemTaxDataCheckedByClient`(
|
|
||||||
vClientFk INT
|
|
||||||
)
|
|
||||||
proc: BEGIN
|
|
||||||
/**
|
|
||||||
* Update the problem of tickets for a specific client, depending on whether
|
|
||||||
* the client taxDataCheched is verified or not
|
|
||||||
*
|
|
||||||
* @param vClientFk Id cliente
|
|
||||||
*/
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
|
||||||
(INDEX(ticketFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT t.id ticketFk, FALSE hasProblem
|
|
||||||
FROM ticket t
|
|
||||||
JOIN client c ON c.id = t.clientFk
|
|
||||||
WHERE t.shipped >= util.midnight()
|
|
||||||
AND c.id = vClientFk;
|
|
||||||
|
|
||||||
CALL ticket_getTaxDataCheckedProblem();
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,17 +1,17 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
||||||
vSelf INT)
|
vClientFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Update the risk for a client with pending tickets
|
* Update the risk for a client with pending tickets
|
||||||
*
|
*
|
||||||
* @param vSelf Id cliente
|
* @param vClientFk Id cliente
|
||||||
*/
|
*/
|
||||||
DECLARE vHasDebt BOOL;
|
DECLARE vHasDebt BOOL;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vHasDebt
|
SELECT COUNT(*) INTO vHasDebt
|
||||||
FROM `client`
|
FROM `client`
|
||||||
WHERE id = vSelf
|
WHERE id = vClientFk
|
||||||
AND typeFk = 'normal';
|
AND typeFk = 'normal';
|
||||||
|
|
||||||
IF vHasDebt THEN
|
IF vHasDebt THEN
|
||||||
|
@ -22,7 +22,7 @@ BEGIN
|
||||||
WITH ticket AS(
|
WITH ticket AS(
|
||||||
SELECT id ticketFk, companyFk, DATE(shipped) dated
|
SELECT id ticketFk, companyFk, DATE(shipped) dated
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
WHERE clientFk = vSelf
|
WHERE clientFk = vClientFk
|
||||||
AND refFk IS NULL
|
AND refFk IS NULL
|
||||||
AND NOT isDeleted
|
AND NOT isDeleted
|
||||||
AND totalWithoutVat <> 0
|
AND totalWithoutVat <> 0
|
||||||
|
@ -37,12 +37,12 @@ BEGIN
|
||||||
FROM (
|
FROM (
|
||||||
SELECT amount, companyFk
|
SELECT amount, companyFk
|
||||||
FROM vn.clientRisk
|
FROM vn.clientRisk
|
||||||
WHERE clientFk = vSelf
|
WHERE clientFk = vClientFk
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT -(SUM(amount) / 100) amount, tm.companyFk
|
SELECT -(SUM(amount) / 100) amount, tm.companyFk
|
||||||
FROM hedera.tpvTransaction t
|
FROM hedera.tpvTransaction t
|
||||||
JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk
|
JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk
|
||||||
WHERE clientFk = vSelf
|
WHERE clientFk = vClientFk
|
||||||
AND receiptFk IS NULL
|
AND receiptFk IS NULL
|
||||||
AND status = 'ok'
|
AND status = 'ok'
|
||||||
) sub
|
) sub
|
||||||
|
@ -52,14 +52,14 @@ BEGIN
|
||||||
SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount
|
SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN dated d
|
JOIN dated d
|
||||||
WHERE t.clientFk = vSelf
|
WHERE t.clientFk = vClientFk
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
AND t.shipped BETWEEN d.started AND d.ended
|
AND t.shipped BETWEEN d.started AND d.ended
|
||||||
GROUP BY t.companyFk, DATE(t.shipped)
|
GROUP BY t.companyFk, DATE(t.shipped)
|
||||||
), receipt AS(
|
), receipt AS(
|
||||||
SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount
|
SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount
|
||||||
FROM vn.receipt
|
FROM vn.receipt
|
||||||
WHERE clientFk = vSelf
|
WHERE clientFk = vClientFk
|
||||||
AND payed > util.VN_CURDATE()
|
AND payed > util.VN_CURDATE()
|
||||||
GROUP BY companyFk, DATE(payed)
|
GROUP BY companyFk, DATE(payed)
|
||||||
), risk AS(
|
), risk AS(
|
||||||
|
|
Loading…
Reference in New Issue