primer prototipo #2205

Merged
pako merged 8 commits from 6358-boxPicking_YellowZebra into dev 2024-03-28 07:20:37 +00:00
1 changed files with 34 additions and 34 deletions
Showing only changes of commit c9431e605e - Show all commits

View File

@ -25,7 +25,7 @@ BEGIN
DECLARE vNewTicketFk INT;
DECLARE vParkingCode VARCHAR(10);
DECLARE vQuantity INT;
DECLARE vRest INT DEFAULT 0;
DECLARE vRemainder INT DEFAULT 0;
DECLARE vRestSaleFk INT;
DECLARE vShelving VARCHAR(10);
DECLARE vTicketFk INT;
@ -43,19 +43,19 @@ BEGIN
FROM sale s
WHERE s.id = vSaleFk;
IF vRest THEN
UPDATE sale SET quantity = quantity - vRest WHERE id = vSaleFk;
IF vRemainder THEN
UPDATE sale SET quantity = quantity - vRemainder WHERE id = vSaleFk;
INSERT INTO vn.sale(ticketFk, itemFk, quantity, price, discount, concept)
INSERT INTO sale(ticketFk, itemFk, quantity, price, discount, concept)
pako marked this conversation as resolved Outdated

sense vn.
Señale este pero hi ha mes.

sense vn. Señale este pero hi ha mes.
SELECT ticketFk, itemFk, vRest, price, discount, concept
FROM vn.sale
FROM sale
WHERE id = vSaleFk;
SET vRestSaleFk = LAST_INSERT_ID();
INSERT INTO vn.saleComponent(saleFk, componentFk, value)
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT vRestSaleFk, componentFk, value
FROM vn.saleComponent
FROM saleComponent
WHERE saleFk = vSaleFk;
END IF;
@ -65,16 +65,16 @@ w1: WHILE vQuantity >= vPacking DO
SELECT sub.id
INTO vItemShelvingFk
pako marked this conversation as resolved
Review

vItemShelvingFk = NULL

vItemShelvingFk = NULL
FROM vn.productionConfig pc
FROM productionConfig pc
JOIN (
SELECT ish.id,
ish.visible - ifnull(SUM(iss.quantity),0) available,
ish.visible - IFNULL(SUM(iss.quantity),0) available,
pako marked this conversation as resolved Outdated

IFNULL

IFNULL
p.pickingOrder,
ish.created
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
LEFT JOIN vn.itemShelvingSale iss
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemShelvingSale iss
ON iss.itemShelvingFk = ish.id
AND iss.created >= CURDATE()
AND iss.isPicked = FALSE
@ -86,7 +86,7 @@ w1: WHILE vQuantity >= vPacking DO
LIMIT 1;
IF vItemShelvingFk THEN
INSERT INTO vn.itemShelvingSale
INSERT INTO itemShelvingSale
SET itemShelvingFk = vItemShelvingFk,
saleFk = vSaleFk,
quantity = vPacking,
@ -95,7 +95,7 @@ w1: WHILE vQuantity >= vPacking DO
SET vItemShelvingSaleFk = LAST_INSERT_ID();
UPDATE vn.sale SET isPicked = FALSE WHERE id = vSaleFk;
UPDATE sale SET isPicked = FALSE WHERE id = vSaleFk;
ELSE
LEAVE w1;
END IF;
@ -103,10 +103,10 @@ w1: WHILE vQuantity >= vPacking DO
SET vNewTicketFk = NULL;
SELECT MAX(t.id) INTO vNewTicketFk
FROM vn.ticket t
JOIN vn.ticketLastState tls ON tls.ticketFk = t.id
FROM ticket t
JOIN ticketLastState tls ON tls.ticketFk = t.id
JOIN (SELECT addressFk, clientFk, date(shipped) shipped, warehouseFk
FROM vn.ticket
FROM ticket
WHERE id = vTicketFk) tt
ON tt.addressFk = t.addressFk
AND tt.clientFk = t.clientFk
@ -115,7 +115,7 @@ w1: WHILE vQuantity >= vPacking DO
WHERE tls.name = 'Encajado' ;
IF ISNULL(vNewTicketFk) THEN
INSERT INTO vn.ticket( clientFk,
INSERT INTO ticket( clientFk,
shipped,
addressFk,
agencyModeFk,
@ -145,7 +145,7 @@ w1: WHILE vQuantity >= vPacking DO
priority,
hasPriority,
id
FROM vn.ticket
FROM ticket
WHERE id = vTicketFk;
SET vNewTicketFk = LAST_INSERT_ID();
@ -175,16 +175,16 @@ w1: WHILE vQuantity >= vPacking DO
SET vItemShelvingSaleFk_old = NULL;
SELECT MAX(id) INTO vItemShelvingSaleFk_old
FROM vn.itemShelvingSale
FROM itemShelvingSale
WHERE itemShelvingFk = vItemShelvingFk
AND saleFk = vNewSaleFk;
IF vItemShelvingSaleFk_old THEN
UPDATE vn.itemShelvingSale
UPDATE itemShelvingSale
SET quantity = quantity + vPacking
WHERE id = vItemShelvingSaleFk_old;
DELETE FROM vn.itemShelvingSale
DELETE FROM itemShelvingSale
WHERE id = vItemShelvingSaleFk;
SET vItemShelvingSaleFk = vItemShelvingSaleFk_old;
@ -194,16 +194,16 @@ w1: WHILE vQuantity >= vPacking DO
WHERE id = vItemShelvingSaleFk;
END IF;
ELSE
INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, discount, price)
INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price)
SELECT vNewTicketFk, itemFk, concept, vPacking, discount, price
FROM vn.sale
FROM sale
WHERE id = vSaleFk;
SET vNewSaleFk = LAST_INSERT_ID();
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
SELECT vNewSaleFk, componentFk, value, isGreuge
FROM vn.saleComponent
FROM saleComponent
WHERE saleFk = vSaleFk;
UPDATE itemShelvingSale
@ -211,16 +211,16 @@ w1: WHILE vQuantity >= vPacking DO
WHERE id = vItemShelvingSaleFk;
END IF;
INSERT IGNORE INTO vn.saleTracking(saleFk, isChecked, workerFk, stateFk)
INSERT IGNORE INTO saleTracking(saleFk, isChecked, workerFk, stateFk)
SELECT vNewSaleFk, TRUE, vUserFk, id
FROM vn.state
FROM state
WHERE code = 'PREPARED';
SELECT agencyModeFk INTO vAgencyModeFk
FROM ticket
WHERE id = vNewTicketFk;
INSERT INTO vn.expedition(
INSERT INTO expedition(
agencyModeFk,
ticketFk,
freightItemFk,
@ -242,8 +242,8 @@ w1: WHILE vQuantity >= vPacking DO
h.code,
vPackingSiteFk,
ps.monitorId,
IFNULL(vLastExpeditionTimeStamp, Now()),
Now()
IFNULL(vLastExpeditionTimeStamp, NOW()),
pako marked this conversation as resolved Outdated

NOW

NOW
NOW()
FROM packingSite ps
JOIN host h ON h.id = ps.hostFk
JOIN item i ON i.name = 'Shipping cost'
@ -252,7 +252,7 @@ w1: WHILE vQuantity >= vPacking DO
SET vExpeditionFk = LAST_INSERT_ID();
SET vLastExpeditionTimeStamp = Now();
SET vLastExpeditionTimeStamp = NOW();
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
@ -274,7 +274,7 @@ w1: WHILE vQuantity >= vPacking DO
street = RIGHT(street, vMAxStreetLength)
WHERE expeditionFk = vExpeditionFk;
DELETE FROM vn.sale
DELETE FROM sale
WHERE quantity = 0
AND id = vSaleFk;
END WHILE;