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';
@ -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';