4515-addBuyCheck #1974
|
@ -74,6 +74,8 @@ BEGIN
|
||||||
WHERE b.id = vSelf;
|
WHERE b.id = vSelf;
|
||||||
|
|
||||||
END IF;
|
END IF;
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
|
||||||
|
SELECT vSelf id;
|
||||||
|
CALL buy_checkItem();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_checkItem`()
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Checks if the item has weightByPiece or size null on any buy.
|
||||||
|
*
|
||||||
|
* @param tmp.buysToCheck(id as INT).
|
||||||
|
*/
|
||||||
|
DECLARE hasVolumetricAgency INT;
|
||||||
|
|
||||||
|
SELECT a.hasWeightVolumetric INTO hasVolumetricAgency
|
||||||
|
FROM entry e
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
JOIN agencyMode a ON a.id = t.agencyModeFk
|
||||||
|
JOIN buy b ON b.entryFk = e.id
|
||||||
|
JOIN item i ON i.id = b.itemFk
|
||||||
|
JOIN tmp.buysToCheck bt ON bt.id = b.id
|
||||||
|
WHERE (i.weightByPiece IS NULL OR i.`size` IS NULL)
|
||||||
pablone marked this conversation as resolved
|
|||||||
|
AND a.hasWeightVolumetric
|
||||||
pablone marked this conversation as resolved
Outdated
jgallego
commented
estas segur que funciona be? estas segur que funciona be?
si el primer registre coincidira que hasWeightVolumetric es false, no miraria la resta.
Estas asumint que totes compres que et pasen son del mateix travel, pero jo posaria el a.hasWeightVolumetric en el where per a asegurar.
Altra cosa, en procesos com l'inventari, açò fara que vaja molt lento? el buy_upsert li tinguerem que posar la variable dentorno per ixe motiu
pablone
commented
bien visto, estaba realizando las pruebas con 1 sola buy bien visto, estaba realizando las pruebas con 1 sola buy
|
|||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.buysToCheck;
|
||||||
|
|
||||||
|
IF hasVolumetricAgency THEN
|
||||||
|
CALL util.throw('Some purchase line has an item without size or weight per stem in the volumetric agency.');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -41,8 +41,8 @@ trig:BEGIN
|
||||||
FROM genericAllocation ga
|
FROM genericAllocation ga
|
||||||
JOIN entry e ON e.id = NEW.entryFk
|
JOIN entry e ON e.id = NEW.entryFk
|
||||||
JOIN travel tr on tr.id = e.travelFk
|
JOIN travel tr on tr.id = e.travelFk
|
||||||
WHERE ga.itemFk = vGenericFk
|
WHERE ga.itemFk = vGenericFk
|
||||||
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
|
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
|
||||||
IF vGenericInDate THEN
|
IF vGenericInDate THEN
|
||||||
SET NEW.itemOriginalFk = NEW.itemFk;
|
SET NEW.itemOriginalFk = NEW.itemFk;
|
||||||
SET NEW.itemFk = vGenericFk;
|
SET NEW.itemFk = vGenericFk;
|
||||||
|
@ -64,5 +64,12 @@ trig:BEGIN
|
||||||
IF NEW.quantity < 0 THEN
|
IF NEW.quantity < 0 THEN
|
||||||
SET NEW.isIgnored = TRUE;
|
SET NEW.isIgnored = TRUE;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT (NEW.itemFk <=> OLD.itemFk) OR
|
||||||
|
NOT (OLD.entryFk <=> NEW.entryFk) THEN
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
|
||||||
|
SELECT NEW.id;
|
||||||
|
CALL buy_checkItem();
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -13,5 +13,15 @@ BEGIN
|
||||||
CALL travel_requestRecalc(OLD.travelFk);
|
CALL travel_requestRecalc(OLD.travelFk);
|
||||||
CALL travel_requestRecalc(NEW.travelFk);
|
CALL travel_requestRecalc(NEW.travelFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
|
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
|
||||||
|
SELECT b.id
|
||||||
|
FROM buy b
|
||||||
|
WHERE b.entryFk = NEW.id;
|
||||||
|
|
||||||
|
CALL buy_checkItem();
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -10,5 +10,18 @@ BEGIN
|
||||||
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
|
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
|
||||||
WHERE travelFk = NEW.id;
|
WHERE travelFk = NEW.id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT (NEW.agencyModeFk <=> OLD.agencyModeFk) THEN
|
||||||
|
IF (SELECT hasWeightVolumetric FROM agencyMode WHERE id = NEW.agencyModeFk) THEN
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
|
||||||
|
SELECT b.id
|
||||||
|
FROM entry e
|
||||||
|
JOIN buy b ON b.entryFk = e.id
|
||||||
|
JOIN item i ON i.id = b.itemFk
|
||||||
|
WHERE e.travelFk = NEW.id;
|
||||||
|
|
||||||
|
CALL buy_checkItem();
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -4,15 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
/*
|
|
||||||
IF ((NOT NEW.shipped <=> OLD.shipped )
|
|
||||||
OR (NOT NEW.landed <=> OLD.landed )
|
|
||||||
OR (NOT NEW.warehouseInFk <=> OLD.warehouseInFk )
|
|
||||||
OR (NOT NEW.warehouseOutFk <=> OLD.warehouseOutFk ))
|
|
||||||
AND (OLD.totalEntries AND OLD.landed < CURDATE()) THEN
|
|
||||||
CALL util.throw("Cannot past travels with entries");
|
|
||||||
END IF;
|
|
||||||
*/
|
|
||||||
IF NOT (NEW.landed <=> OLD.landed)
|
IF NOT (NEW.landed <=> OLD.landed)
|
||||||
OR NOT (NEW.shipped <=> OLD.shipped) THEN
|
OR NOT (NEW.shipped <=> OLD.shipped) THEN
|
||||||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||||
|
|
Loading…
Reference in New Issue
paréntesis se pueden quitar