feat: restricciones AWB para travel y entry refs #6960
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
625d19e88c
commit
b9e774cea0
|
@ -1489,8 +1489,8 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF
|
||||||
|
|
||||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
||||||
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
||||||
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
|
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
|
||||||
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`travel_hasUniqueAwb`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
RETURNS BOOL
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba que el travel pasado tiene un AWB lógico,
|
||||||
|
* no se pueden tener varios AWB asociados al mismo DUA
|
||||||
|
*
|
||||||
|
* @param vSelf Id del travel
|
||||||
|
*/
|
||||||
|
DECLARE vHasUniqueAwb BOOL DEFAULT TRUE;
|
||||||
|
|
||||||
|
SELECT NOT COUNT(t2.awbFk) INTO vHasUniqueAwb
|
||||||
|
FROM entry e
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
|
JOIN duaEntry de2 ON de2.duaFk = de.duaFk
|
||||||
|
JOIN entry e2 ON e2.id = de2.entryFk
|
||||||
|
JOIN travel t2 ON t2.id = e2.travelFk
|
||||||
|
WHERE t.id = vSelf
|
||||||
|
AND t2.awbFk <> t.awbFk;
|
||||||
|
|
||||||
|
RETURN vHasUniqueAwb;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -7,6 +7,8 @@ BEGIN
|
||||||
CALL supplier_checkIsActive(NEW.supplierFk);
|
CALL supplier_checkIsActive(NEW.supplierFk);
|
||||||
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
||||||
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
|
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
|
||||||
|
IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
|
||||||
|
CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -9,6 +9,12 @@ BEGIN
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
|
IF NOT(NEW.travelFk <=> OLD.travelFk) THEN
|
||||||
|
|
||||||
|
IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
|
||||||
|
CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto');
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF !(NEW.travelFk <=> OLD.travelFk) THEN
|
IF !(NEW.travelFk <=> OLD.travelFk) THEN
|
||||||
SELECT COUNT(*) > 0 INTO vIsVirtual
|
SELECT COUNT(*) > 0 INTO vIsVirtual
|
||||||
FROM entryVirtual WHERE entryFk = NEW.id;
|
FROM entryVirtual WHERE entryFk = NEW.id;
|
||||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate`
|
||||||
BEGIN
|
BEGIN
|
||||||
CALL stock.log_add('travel', NEW.id, OLD.id);
|
CALL stock.log_add('travel', NEW.id, OLD.id);
|
||||||
|
|
||||||
IF !(NEW.shipped <=> OLD.shipped) THEN
|
IF NOT(NEW.shipped <=> OLD.shipped) THEN
|
||||||
UPDATE entry
|
UPDATE entry
|
||||||
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
|
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
|
||||||
WHERE travelFk = NEW.id;
|
WHERE travelFk = NEW.id;
|
||||||
|
@ -23,5 +23,9 @@ BEGIN
|
||||||
CALL buy_checkItem();
|
CALL buy_checkItem();
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
|
||||||
|
CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -8,5 +8,9 @@ BEGIN
|
||||||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||||
|
|
||||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||||
|
|
||||||
|
IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
|
||||||
|
CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue