4515-addBuyCheck #1974
|
@ -74,6 +74,8 @@ BEGIN
|
|||
WHERE b.id = vSelf;
|
||||
|
||||
END IF;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
|
||||
SELECT vSelf id;
|
||||
CALL buy_checkItem();
|
||||
END$$
|
||||
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
|
||||
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
|
||||
JOIN entry e ON e.id = NEW.entryFk
|
||||
JOIN travel tr on tr.id = e.travelFk
|
||||
WHERE ga.itemFk = vGenericFk
|
||||
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
|
||||
WHERE ga.itemFk = vGenericFk
|
||||
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
|
||||
IF vGenericInDate THEN
|
||||
SET NEW.itemOriginalFk = NEW.itemFk;
|
||||
SET NEW.itemFk = vGenericFk;
|
||||
|
@ -64,5 +64,12 @@ trig:BEGIN
|
|||
IF NEW.quantity < 0 THEN
|
||||
SET NEW.isIgnored = TRUE;
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -13,5 +13,15 @@ BEGIN
|
|||
CALL travel_requestRecalc(OLD.travelFk);
|
||||
CALL travel_requestRecalc(NEW.travelFk);
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -10,5 +10,18 @@ BEGIN
|
|||
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
|
||||
WHERE travelFk = NEW.id;
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -4,15 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate`
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
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)
|
||||
OR NOT (NEW.shipped <=> OLD.shipped) THEN
|
||||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||
|
|
Loading…
Reference in New Issue
paréntesis se pueden quitar