7213-Pasar-problemas-a-columnas-calculadas #2396
|
@ -8,6 +8,7 @@ BEGIN
|
|||
/**
|
||||
* Check if the ticket is small based on the volume and amount parameters.
|
||||
*
|
||||
* @param vSelf Id ticket
|
||||
* @return BOOL
|
||||
*/
|
||||
DECLARE vIsTooLittle TINYINT(1);
|
||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
|
|||
BEGIN
|
||||
/**
|
||||
* Update column sale.problem with a problem code
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.sale(saleFk, hasProblem)
|
||||
*/
|
||||
UPDATE sale s
|
||||
|
|
|
@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblem`(
|
|||
BEGIN
|
||||
/**
|
||||
* Update column ticket.problem with a problem code
|
||||
*
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.ticket(ticketFk, hasProblem)
|
||||
*/
|
||||
UPDATE ticket t
|
||||
|
|
|
@ -6,7 +6,7 @@ BEGIN
|
|||
* Update the problem of tickets, depending on whether
|
||||
* 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
|
||||
(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 $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
||||
vSelf INT)
|
||||
vClientFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the risk for a client with pending tickets
|
||||
*
|
||||
* @param vSelf Id cliente
|
||||
* @param vClientFk Id cliente
|
||||
*/
|
||||
DECLARE vHasDebt BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vHasDebt
|
||||
FROM `client`
|
||||
WHERE id = vSelf
|
||||
WHERE id = vClientFk
|
||||
AND typeFk = 'normal';
|
||||
|
||||
IF vHasDebt THEN
|
||||
|
@ -22,7 +22,7 @@ BEGIN
|
|||
WITH ticket AS(
|
||||
SELECT id ticketFk, companyFk, DATE(shipped) dated
|
||||
FROM vn.ticket t
|
||||
WHERE clientFk = vSelf
|
||||
WHERE clientFk = vClientFk
|
||||
AND refFk IS NULL
|
||||
AND NOT isDeleted
|
||||
AND totalWithoutVat <> 0
|
||||
|
@ -37,12 +37,12 @@ BEGIN
|
|||
FROM (
|
||||
SELECT amount, companyFk
|
||||
FROM vn.clientRisk
|
||||
WHERE clientFk = vSelf
|
||||
WHERE clientFk = vClientFk
|
||||
UNION ALL
|
||||
SELECT -(SUM(amount) / 100) amount, tm.companyFk
|
||||
FROM hedera.tpvTransaction t
|
||||
JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk
|
||||
WHERE clientFk = vSelf
|
||||
WHERE clientFk = vClientFk
|
||||
AND receiptFk IS NULL
|
||||
AND status = 'ok'
|
||||
) sub
|
||||
|
@ -52,14 +52,14 @@ BEGIN
|
|||
SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount
|
||||
FROM vn.ticket t
|
||||
JOIN dated d
|
||||
WHERE t.clientFk = vSelf
|
||||
WHERE t.clientFk = vClientFk
|
||||
AND t.refFk IS NULL
|
||||
AND t.shipped BETWEEN d.started AND d.ended
|
||||
GROUP BY t.companyFk, DATE(t.shipped)
|
||||
), receipt AS(
|
||||
SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount
|
||||
FROM vn.receipt
|
||||
WHERE clientFk = vSelf
|
||||
WHERE clientFk = vClientFk
|
||||
AND payed > util.VN_CURDATE()
|
||||
GROUP BY companyFk, DATE(payed)
|
||||
), risk AS(
|
||||
|
|
Loading…
Reference in New Issue