This commit is contained in:
parent
cb056ff789
commit
cfc5e32715
|
@ -44,7 +44,7 @@ BEGIN
|
|||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido')
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND NOT ce.isGreuge
|
||||
AND cs.code = 'resolved';
|
||||
|
||||
|
@ -86,20 +86,20 @@ BEGIN
|
|||
|
||||
-- Recobros
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTicketList
|
||||
(PRIMARY KEY (ticketFk))
|
||||
SELECT DISTINCT s.ticketFk
|
||||
FROM saleComponent sc
|
||||
JOIN sale s ON sc.saleFk = s.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN state st ON st.id = tt.stateFk
|
||||
JOIN alertLevel al ON al.id = st.alertLevel
|
||||
WHERE sc.componentFk = vDebtComponentType
|
||||
AND NOT sc.isGreuge
|
||||
AND t.shipped >= '2016-10-01'
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND al.code = 'DELIVERED';
|
||||
(PRIMARY KEY (ticketFk))
|
||||
SELECT DISTINCT s.ticketFk
|
||||
FROM saleComponent sc
|
||||
JOIN sale s ON sc.saleFk = s.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN state st ON st.id = tt.stateFk
|
||||
JOIN alertLevel al ON al.id = st.alertLevel
|
||||
WHERE sc.componentFk = vDebtComponentType
|
||||
AND NOT sc.isGreuge
|
||||
AND t.shipped >= '2016-10-01'
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND al.code = 'DELIVERED';
|
||||
|
||||
DELETE g.*
|
||||
FROM greuge g
|
||||
|
@ -133,20 +133,21 @@ BEGIN
|
|||
JOIN tTicketList tl ON tl.ticketFk = s.ticketFk
|
||||
SET sc.isGreuge = TRUE
|
||||
WHERE sc.componentFk = vDebtComponentType;
|
||||
|
||||
INSERT INTO claimRatio(
|
||||
|
||||
REPLACE claimRatio(
|
||||
clientFk,
|
||||
yearSale,
|
||||
claimAmount,
|
||||
claimingRate,
|
||||
priceIncreasing
|
||||
)
|
||||
SELECT cac.clientFk,
|
||||
SELECT c.id,
|
||||
12 * cac.invoiced,
|
||||
totalClaims,
|
||||
ROUND(totalClaims / (12 * cac.invoiced), 4),
|
||||
0
|
||||
FROM bs.clientAnnualConsumption cac
|
||||
FROM client c
|
||||
LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id
|
||||
LEFT JOIN (
|
||||
SELECT c.clientFk,
|
||||
ROUND(SUM(-1 * ((c.responsibility - 1) / 4) *
|
||||
|
@ -157,11 +158,11 @@ BEGIN
|
|||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido')
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND cs.code = 'resolved'
|
||||
AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||
GROUP BY c.clientFk
|
||||
) sub ON sub.clientFk = cac.clientFk;
|
||||
) sub ON sub.clientFk = c.id;
|
||||
|
||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||
UPDATE claimRatio cr
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
UPDATE IGNORE bs.nightTask
|
||||
SET `schema` = 'vn',
|
||||
`procedure` = 'claimRatio_add'
|
||||
WHERE `procedure` = 'claim_ratio_routine';
|
Loading…
Reference in New Issue