7383-testToMaster #2445

Merged
alexm merged 233 commits from 7383-testToMaster into master 2024-05-14 05:44:13 +00:00
1 changed files with 25 additions and 25 deletions
Showing only changes of commit a40545264b - Show all commits

View File

@ -34,29 +34,29 @@ BEGIN
clientFk, clientFk,
companyFk, companyFk,
margin margin
)WITH calculated AS( )WITH calculatedSales AS(
SELECT s.id saleFk, SELECT s.id saleFk,
SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount, SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount,
SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge, SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge,
s.total pvp, s.total pvp,
DATE(t.shipped) dated, DATE(t.shipped) dated,
i.typeFk, i.typeFk,
t.clientFk, t.clientFk,
t.companyFk, t.companyFk,
SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents
FROM vn.ticket t FROM vn.ticket t
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk
JOIN vn.saleComponent sc ON sc.saleFk = s.id JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime
AND s.quantity <> 0 AND s.quantity <> 0
AND ic.merchandise AND ic.merchandise
GROUP BY s.id GROUP BY s.id
)SELECT saleFk, )SELECT saleFk,
amount, amount,
surcharge, surcharge,
dated, dated,
@ -64,7 +64,7 @@ BEGIN
clientFk, clientFk,
companyFk, companyFk,
marginComponents + amount + surcharge - pvp marginComponents + amount + surcharge - pvp
FROM calculated; FROM calculatedSales;
SET vLoopDate = vLoopDate + INTERVAL 1 DAY; SET vLoopDate = vLoopDate + INTERVAL 1 DAY;
END WHILE; END WHILE;