Merge branch 'master' into test
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
854604368a
|
@ -31,50 +31,43 @@ BEGIN
|
||||||
INTO vManaFromDays, vManaToDays
|
INTO vManaFromDays, vManaToDays
|
||||||
FROM vn.salespersonConfig;
|
FROM vn.salespersonConfig;
|
||||||
|
|
||||||
SELECT MAX(dated)
|
SELECT MAX(dated) INTO vFromDated
|
||||||
INTO vFromDated
|
|
||||||
FROM vn.clientManaCache;
|
FROM vn.clientManaCache;
|
||||||
|
|
||||||
DELETE
|
DELETE FROM vn.clientManaCache
|
||||||
FROM vn.clientManaCache
|
|
||||||
WHERE dated = vFromDated;
|
WHERE dated = vFromDated;
|
||||||
|
|
||||||
SELECT MAX(dated)
|
SELECT MAX(dated) INTO vFromDated
|
||||||
INTO vFromDated
|
|
||||||
FROM vn.clientManaCache;
|
FROM vn.clientManaCache;
|
||||||
|
|
||||||
IF ISNULL(vFromDated) THEN
|
IF vFromDated IS NULL THEN
|
||||||
SELECT manaDateFrom
|
SELECT manaDateFrom
|
||||||
INTO vFromDated
|
INTO vFromDated
|
||||||
FROM vn.salespersonConfig;
|
FROM vn.salespersonConfig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||||
SELECT
|
SELECT vFromDated + INTERVAL vManaToDays DAY,
|
||||||
vFromDated + INTERVAL vManaToDays DAY,
|
|
||||||
vFromDated - INTERVAL vManaFromDays DAY
|
vFromDated - INTERVAL vManaFromDays DAY
|
||||||
INTO
|
INTO vToDated,
|
||||||
vToDated,
|
|
||||||
vForDeleteDated;
|
vForDeleteDated;
|
||||||
|
|
||||||
DELETE FROM vn.clientManaCache
|
DELETE FROM vn.clientManaCache
|
||||||
WHERE dated <= vForDeleteDated;
|
WHERE dated <= vForDeleteDated;
|
||||||
|
|
||||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||||
SELECT
|
SELECT Id_Cliente,
|
||||||
Id_Cliente,
|
|
||||||
SUM(mana),
|
SUM(mana),
|
||||||
vToDated
|
vToDated
|
||||||
FROM
|
FROM (
|
||||||
(
|
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
|
||||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
|
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.address a ON a.id = t.addressFk
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
JOIN vn.sale s on s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.saleComponent sc on sc.saleFk = s.id
|
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||||
AND t.shipped > vFromDated
|
AND t.shipped > vFromDated
|
||||||
AND date(t.shipped) <= vToDated
|
AND DATE(t.shipped) <= vToDated
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT clientFk, - amountPaid
|
SELECT clientFk, - amountPaid
|
||||||
FROM vn.receipt
|
FROM vn.receipt
|
||||||
|
|
Loading…
Reference in New Issue