Compare commits
13 Commits
80851e094d
...
53673f43b8
Author | SHA1 | Date |
---|---|---|
Javi Gallego | 53673f43b8 | |
Javi Gallego | 0ecbef0c9f | |
Carlos Andrés | 770ace0f8e | |
Carlos Andrés | 2563d1f0e4 | |
Carlos Andrés | 0870a1c3d6 | |
Carlos Andrés | dbf71b981e | |
Carlos Andrés | 762d4b9955 | |
Sergio De la torre | 07201f6448 | |
Sergio De la torre | 512b4a54df | |
Carlos Andrés | 031c4398ae | |
Carlos Andrés | 43abb52efc | |
Carlos Andrés | a7ab8696ac | |
Carlos Andrés | 43e121a2f3 |
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
ALTER TABLE vn.itemConfig ADD defaultPackingTypeFk VARCHAR(1) DEFAULT 'H' NULL;
|
|
@ -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';
|
|
@ -156,6 +156,7 @@ module.exports = Self => {
|
|||
t.totalEntries,
|
||||
t.isRaid,
|
||||
t.daysInForward,
|
||||
t.isRaid,
|
||||
am.name agencyModeName,
|
||||
win.name warehouseInName,
|
||||
wout.name warehouseOutName,
|
||||
|
|
Loading…
Reference in New Issue