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';
|
||||
|
||||
|
@ -134,19 +134,20 @@ BEGIN
|
|||
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