fix: descuentos en bs.ventas refs #6974
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
fd903f27c0
commit
a40545264b
|
@ -34,37 +34,37 @@ BEGIN
|
|||
clientFk,
|
||||
companyFk,
|
||||
margin
|
||||
)WITH calculated AS(
|
||||
SELECT s.id saleFk,
|
||||
SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount,
|
||||
SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge,
|
||||
s.total pvp,
|
||||
DATE(t.shipped) dated,
|
||||
i.typeFk,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents
|
||||
FROM vn.ticket t
|
||||
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime
|
||||
AND s.quantity <> 0
|
||||
AND ic.merchandise
|
||||
GROUP BY s.id
|
||||
)SELECT saleFk,
|
||||
)WITH calculatedSales AS(
|
||||
SELECT s.id saleFk,
|
||||
SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount,
|
||||
SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge,
|
||||
s.total pvp,
|
||||
DATE(t.shipped) dated,
|
||||
i.typeFk,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents
|
||||
FROM vn.ticket t
|
||||
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime
|
||||
AND s.quantity <> 0
|
||||
AND ic.merchandise
|
||||
GROUP BY s.id
|
||||
)SELECT saleFk,
|
||||
amount,
|
||||
surcharge,
|
||||
dated,
|
||||
typeFk,
|
||||
clientFk,
|
||||
companyFk,
|
||||
marginComponents + amount + surcharge - pvp
|
||||
FROM calculated;
|
||||
marginComponents + amount + surcharge - pvp
|
||||
FROM calculatedSales;
|
||||
|
||||
SET vLoopDate = vLoopDate + INTERVAL 1 DAY;
|
||||
END WHILE;
|
||||
|
|
Loading…
Reference in New Issue