feat: refs #6701 Fix error
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-06-13 13:11:50 +02:00
parent cb056ff789
commit cfc5e32715
2 changed files with 26 additions and 21 deletions

View File

@ -44,7 +44,7 @@ BEGIN
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
JOIN claim c ON c.id = ce.claimFk JOIN claim c ON c.id = ce.claimFk
JOIN claimState cs ON cs.id = c.claimStateFk 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 NOT ce.isGreuge
AND cs.code = 'resolved'; AND cs.code = 'resolved';
@ -86,20 +86,20 @@ BEGIN
-- Recobros -- Recobros
CREATE OR REPLACE TEMPORARY TABLE tTicketList CREATE OR REPLACE TEMPORARY TABLE tTicketList
(PRIMARY KEY (ticketFk)) (PRIMARY KEY (ticketFk))
SELECT DISTINCT s.ticketFk SELECT DISTINCT s.ticketFk
FROM saleComponent sc FROM saleComponent sc
JOIN sale s ON sc.saleFk = s.id JOIN sale s ON sc.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN ticketLastState ts ON ts.ticketFk = t.id JOIN ticketLastState ts ON ts.ticketFk = t.id
JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk
JOIN state st ON st.id = tt.stateFk JOIN state st ON st.id = tt.stateFk
JOIN alertLevel al ON al.id = st.alertLevel JOIN alertLevel al ON al.id = st.alertLevel
WHERE sc.componentFk = vDebtComponentType WHERE sc.componentFk = vDebtComponentType
AND NOT sc.isGreuge AND NOT sc.isGreuge
AND t.shipped >= '2016-10-01' AND t.shipped >= '2016-10-01'
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
AND al.code = 'DELIVERED'; AND al.code = 'DELIVERED';
DELETE g.* DELETE g.*
FROM greuge g FROM greuge g
@ -134,19 +134,20 @@ BEGIN
SET sc.isGreuge = TRUE SET sc.isGreuge = TRUE
WHERE sc.componentFk = vDebtComponentType; WHERE sc.componentFk = vDebtComponentType;
INSERT INTO claimRatio( REPLACE claimRatio(
clientFk, clientFk,
yearSale, yearSale,
claimAmount, claimAmount,
claimingRate, claimingRate,
priceIncreasing priceIncreasing
) )
SELECT cac.clientFk, SELECT c.id,
12 * cac.invoiced, 12 * cac.invoiced,
totalClaims, totalClaims,
ROUND(totalClaims / (12 * cac.invoiced), 4), ROUND(totalClaims / (12 * cac.invoiced), 4),
0 0
FROM bs.clientAnnualConsumption cac FROM client c
LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id
LEFT JOIN ( LEFT JOIN (
SELECT c.clientFk, SELECT c.clientFk,
ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * ROUND(SUM(-1 * ((c.responsibility - 1) / 4) *
@ -157,11 +158,11 @@ BEGIN
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
JOIN claim c ON c.id = ce.claimFk JOIN claim c ON c.id = ce.claimFk
JOIN claimState cs ON cs.id = c.claimStateFk 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 cs.code = 'resolved'
AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR
GROUP BY c.clientFk 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 -- Calculamos el porcentaje del recobro para añadirlo al precio de venta
UPDATE claimRatio cr UPDATE claimRatio cr

View File

@ -0,0 +1,4 @@
UPDATE IGNORE bs.nightTask
SET `schema` = 'vn',
`procedure` = 'claimRatio_add'
WHERE `procedure` = 'claim_ratio_routine';