Compare commits

...

13 Commits

Author SHA1 Message Date
Javi Gallego 53673f43b8 Merge branch 'dev' into 7821-entryIsBooked
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-11-21 16:20:25 +01:00
Javi Gallego 0ecbef0c9f Merge branch 'dev' into 7821-entryIsBooked 2024-11-21 16:15:10 +01:00
Carlos Andrés 770ace0f8e Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details
2024-11-21 16:11:42 +01:00
Carlos Andrés 2563d1f0e4 Merge pull request 'refs#8087 Redadas en travel test' (!3232) from travelisRaidTest into test
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3232
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-21 14:55:07 +00:00
Carlos Andrés 0870a1c3d6 refs#8087 Redadas en travel test
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-21 15:09:58 +01:00
Carlos Andrés dbf71b981e Merge pull request 'refactor: refs #8210 ticket_splitItemPackingType' (!3217) from 8210-RefactorTicket_splitItemPackingType into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3217
Reviewed-by: Pako Natek <pako@verdnatura.es>
2024-11-21 12:39:34 +00:00
Carlos Andrés 762d4b9955 Merge branch 'dev' into 8210-RefactorTicket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-21 11:53:59 +00:00
Sergio De la torre 07201f6448 Merge pull request 'fix: refs #7920 refs#7920 itemShelvingLog' (!3231) from 7920-itemShelvingLogs into test
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3231
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
2024-11-21 10:59:52 +00:00
Sergio De la torre 512b4a54df fix: refs #7920 refs#7920 itemShelvingLog
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-21 11:28:25 +01:00
Carlos Andrés 031c4398ae refactor: refs #8210 ticket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-20 19:19:03 +01:00
Carlos Andrés 43abb52efc refactor: refs #8210 ticket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-19 16:58:15 +01:00
Carlos Andrés a7ab8696ac refactor: refs #8210 ticket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-19 11:07:19 +01:00
Carlos Andrés 43e121a2f3 refactor: refs #8210 ticket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-19 11:04:16 +01:00
7 changed files with 118 additions and 110 deletions

View File

@ -1505,6 +1505,19 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `isRaid`, `daysInForward`)
VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, FALSE, FALSE, NULL),
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, FALSE, NULL),
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, FALSE, NULL),
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, FALSE, FALSE, NULL),
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, FALSE, FALSE, NULL),
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, FALSE, FALSE,NULL),
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, TRUE, TRUE, 2),
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, FALSE, NULL),
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, TRUE, 2),
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, FALSE, NULL),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, FALSE, NULL);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
VALUES
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, '', 'packaging'),
@ -1519,19 +1532,6 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, '', 'product'),
(99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99', 0, '', 'product');
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`)
VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL),
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL),
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL),
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL),
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL),
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL),
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2),
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL),
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2),
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL);
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
VALUES (2, 4, 1);
@ -4025,11 +4025,12 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c
(10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
VALUES (19, '1169'),
(8, '1183');
INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
VALUES ('saysimle-url-mock', 1320);INSERT INTO vn.workerIrpf (workerFk,spouseNif,geographicMobilityDate)
VALUES
(1106,'26493101E','2019-09-20');
VALUES ('saysimle-url-mock', 1320);
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
VALUES (1106,'26493101E','2019-09-20');

View File

@ -22,7 +22,7 @@ BEGIN
ic.url,
ish.available,
ish.buyFk,
sh.shelvingFk
ish.shelvingFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON s.id = ish.shelvingFk

View File

@ -5,122 +5,122 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
)
BEGIN
/**
* Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
* Respeta el id inicial para el tipo propuesto.
* Separa en diferentes tickets según el tipo de empaquetado
* El ticket original conserva las líneas del tipo de empaquetado especificado
* Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto.
*
* @param vSelf Id ticket
* @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
* @param vSelf Id del ticket original
* @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
DECLARE vIsDone BOOLEAN DEFAULT FALSE;
DECLARE vCurrentPackingType VARCHAR(1);
DECLARE vDefaultPackingType VARCHAR(1);
DECLARE vHasOriginalPackingType BOOLEAN;
DECLARE vNewTicketFk INT;
DECLARE vPackingTypesToSplit INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vTicketFk INT;
DECLARE vSaleGroup CURSOR FOR
SELECT itemPackingTypeFk
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
DECLARE vItemPackingTypes CURSOR FOR
SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
START TRANSACTION;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
SELECT id
FROM sale
WHERE ticketFk = vSelf
AND NOT quantity
FOR UPDATE;
DELETE FROM sale
WHERE NOT quantity
AND ticketFk = vSelf;
CREATE OR REPLACE TEMPORARY TABLE tSale
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
FROM sale s
JOIN item i ON i.id = s.itemFk
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = vSelf;
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
ENGINE = MEMORY
SELECT itemPackingTypeFk, SUM(litros) totalLitros
FROM tSale
GROUP BY itemPackingTypeFk;
SELECT COUNT(*) INTO vPackingTypesToSplit
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
ticketFk INT,
saleFk INT,
itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY;
CASE vPackingTypesToSplit
WHEN 0 THEN
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vSelf, vItemPackingTypeFk);
WHEN 1 THEN
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
SELECT vSelf, itemPackingTypeFk
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
ELSE
OPEN vSaleGroup;
FETCH vSaleGroup INTO vItemPackingTypeFk;
SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
FROM vn.sale s
JOIN item i ON i.id = s.itemFk
LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
WHERE s.ticketFk = vSelf
GROUP BY s.ticketFk;
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vSelf, vItemPackingTypeFk);
SELECT EXISTS (
SELECT TRUE
FROM sale s
JOIN item i ON i.id = s.itemFk
WHERE s.ticketFk = vSelf
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk
) INTO vHasOriginalPackingType;
IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN
SET vOriginalItemPackingTypeFk = vDefaultPackingType;
END IF;
START TRANSACTION;
SELECT t.id INTO vTicketFk
FROM ticket t
JOIN sale s ON s.id = t.id
WHERE t.id = vSelf
FOR UPDATE;
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
SELECT s.id, i.itemPackingTypeFk
FROM sale s
JOIN item i ON i.id = s.itemFk
WHERE s.ticketFk = vSelf
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
OPEN vItemPackingTypes;
l: LOOP
SET vDone = FALSE;
FETCH vSaleGroup INTO vItemPackingTypeFk;
SET vIsDone = FALSE;
FETCH vItemPackingTypes INTO vCurrentPackingType;
IF vDone THEN
IF vIsDone THEN
LEAVE l;
END IF;
CALL ticket_Clone(vSelf, vNewTicketFk);
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vNewTicketFk, vItemPackingTypeFk);
END LOOP;
CLOSE vSaleGroup;
SELECT s.id
FROM sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
SELECT id INTO vTicketFk
FROM ticket t
WHERE t.id = vNewTicketFk
FOR UPDATE;
UPDATE tSalesToMove
SET ticketFk = vNewTicketFk
WHERE itemPackingTypeFk = vCurrentPackingType;
IF vCurrentPackingType = vDefaultPackingType THEN
INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk)
SELECT vNewTicketFk, s.id, i.itemPackingTypeFk
FROM sale s
JOIN item i ON i.id = s.itemFk
WHERE s.ticketFk = vSelf
AND i.itemPackingTypeFk IS NULL;
END IF;
END LOOP;
CLOSE vItemPackingTypes;
UPDATE sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
JOIN tSalesToMove t ON t.saleFk = s.id
SET s.ticketFk = t.ticketFk;
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
FROM tSaleGroup sg
WHERE sg.itemPackingTypeFk IS NOT NULL
ORDER BY sg.itemPackingTypeFk
LIMIT 1;
UPDATE sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
SET s.ticketFk = t.ticketFk
WHERE ts.itemPackingTypeFk IS NULL;
END CASE;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT
ENGINE=MEMORY
SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk
FROM sale s
JOIN item i ON i.id = s.itemFk
WHERE s.ticketFk = vSelf
GROUP BY s.ticketFk
UNION
SELECT ticketFk, MAX(itemPackingTypeFk)
FROM tSalesToMove
GROUP BY ticketFk;
COMMIT;
DROP TEMPORARY TABLE
tSale,
tSaleGroup;
DROP TEMPORARY TABLE tSalesToMove;
END$$
DELIMITER ;

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.itemConfig ADD defaultPackingTypeFk VARCHAR(1) DEFAULT 'H' NULL;

View File

@ -0,0 +1,4 @@
ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';

View File

@ -156,6 +156,7 @@ module.exports = Self => {
t.totalEntries,
t.isRaid,
t.daysInForward,
t.isRaid,
am.name agencyModeName,
win.name warehouseInName,
wout.name warehouseOutName,