hotfix: packaging ticket 199070 #2727

Merged
carlosap merged 2 commits from Hotfix-packaging-ticket-199070 into master 2024-07-12 11:36:41 +00:00
2 changed files with 19 additions and 14 deletions

View File

@ -19,21 +19,20 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(saleFk INT PRIMARY KEY)
SELECT
s.ticketFk,
s.id saleFk,
s.itemFk,
s.concept,
s.quantity,
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
b.packagingFk
SELECT s.ticketFk,
s.id saleFk,
s.itemFk,
s.concept,
s.quantity,
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk)
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemShelving ish ON ish.itemFk = s.itemFk
LEFT JOIN ( SELECT iss.itemShelvingFk,
LEFT JOIN ( SELECT iss.itemShelvingFk,
s.itemFk,
SUM(iss.quantity) reserve
FROM itemShelvingSale iss
@ -52,6 +51,8 @@ BEGIN
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id
LEFT JOIN packaging pa ON pa.id = b.packagingFk
JOIN packagingConfig pc
WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut)
<= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
AND NOT pb.problem

View File

@ -44,14 +44,14 @@ BEGIN
t.shipped,
IFNULL(a.hasDailyInvoice, co.hasDailyInvoice),
w.isManaged,
c.hasToInvoice
c.hasToInvoice
INTO vClientFk,
vIsTaxDataChecked,
vCompanyFk,
vShipped,
vHasDailyInvoice,
vWithPackage,
vHasToInvoice
vHasToInvoice
FROM ticket t
JOIN `client` c ON c.id = t.clientFk
JOIN province p ON p.id = c.provinceFk
@ -64,8 +64,12 @@ BEGIN
(SELECT vCurTicketFk, p.id, COUNT(*)
FROM expedition e
JOIN packaging p ON p.id = e.packagingFk
JOIN ticket t ON t.id = e.ticketFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
AND vWithPackage
AND NOT dm.`code`= 'PICKUP'
GROUP BY p.itemFk);
-- No retornables o no catalogados