This commit is contained in:
parent
ca6afb9c10
commit
7579e15fcc
|
@ -147,10 +147,16 @@ proc: BEGIN
|
||||||
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,
|
||||||
|
(s.quantity * ic.cm3delivery / 1000000),
|
||||||
|
0)) / SUM(s.quantity * ic.cm3delivery / 1000000),
|
||||||
|
0) rate
|
||||||
FROM tmp.productionTicket tt
|
FROM tmp.productionTicket tt
|
||||||
JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk
|
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
|
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`,
|
||||||
|
@ -218,6 +224,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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue