7631_testToMaster_2426 #2634

Merged
alexm merged 147 commits from 7631_testToMaster_2426 into master 2024-06-25 06:36:59 +00:00
2 changed files with 28 additions and 15 deletions
Showing only changes of commit c241189508 - Show all commits

View File

@ -146,13 +146,19 @@ proc: BEGIN
-- Líneas y volumen por ticket -- Líneas y volumen por ticket
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN ( JOIN (
SELECT tt.ticketFk, SELECT tt.ticketFk,
COUNT(*) `lines`, COUNT(*) `lines`,
SUM(sv.volume) m3, SUM(s.quantity * ic.cm3delivery / 1000000) m3,
IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate IFNULL(SUM(IF(s.isPicked,
FROM tmp.productionTicket tt (s.quantity * ic.cm3delivery / 1000000),
JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk 0)) / SUM(s.quantity * ic.cm3delivery / 1000000),
GROUP BY tt.ticketFk 0) rate
FROM tmp.productionTicket tt
JOIN sale s ON s.ticketFk = tt.ticketFk
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = vWarehouseFk
GROUP BY tt.ticketFk
) m ON m.ticketFk = pb.ticketFk ) m ON m.ticketFk = pb.ticketFk
SET pb.`lines` = m.`lines`, SET pb.`lines` = m.`lines`,
pb.m3 = m.m3, pb.m3 = m.m3,
@ -219,6 +225,8 @@ proc: BEGIN
AND ish.visible AND ish.visible
GROUP BY ish.itemFk, p.sectorFk; GROUP BY ish.itemFk, p.sectorFk;
CREATE INDEX idxItem ON tItemShelvingStock (itemFk);
INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
SELECT pb.ticketFk, COUNT(DISTINCT s.id) SELECT pb.ticketFk, COUNT(DISTINCT s.id)
FROM tmp.productionBuffer pb FROM tmp.productionBuffer pb

View File

@ -64,10 +64,15 @@ BEGIN
FROM tmp.sale_getProblems tp FROM tmp.sale_getProblems tp
JOIN ticket t ON t.id = tp.ticketFk JOIN ticket t ON t.id = tp.ticketFk
JOIN ( JOIN (
SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat SELECT t.addressFk,
SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros,
t.totalWithoutVat
FROM tmp.ticket_list tl FROM tmp.ticket_list tl
JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk
JOIN ticket t ON t.id = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk
JOIN sale s ON s.ticketFk = t.id
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
AND zc.dated = util.VN_CURDATE() AND zc.dated = util.VN_CURDATE()
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
@ -95,12 +100,12 @@ BEGIN
FROM ( FROM (
SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk
FROM tmp.ticket_list tl FROM tmp.ticket_list tl
JOIN vn.sale s ON s.ticketFk = tl.ticketFk JOIN sale s ON s.ticketFk = tl.ticketFk
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired
JOIN vn.ticket t ON t.id = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk
JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP')
AND s.quantity > 0 AND s.quantity > 0
GROUP BY s.id GROUP BY s.id