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