feat: refs #8087 Traspasar redadas a travels
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
db4b540958
commit
1bf900f81b
|
@ -1518,19 +1518,19 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
||||||
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4),
|
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4),
|
||||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
|
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
|
||||||
|
|
||||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, ''),
|
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''),
|
||||||
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two'),
|
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two'),
|
||||||
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three'),
|
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three'),
|
||||||
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four'),
|
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four'),
|
||||||
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
|
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five'),
|
||||||
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
|
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six'),
|
||||||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
|
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven'),
|
||||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
|
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''),
|
||||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''),
|
||||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''),
|
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''),
|
||||||
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '');
|
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, '');
|
||||||
|
|
||||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||||
VALUES (2, 4, 1);
|
VALUES (2, 4, 1);
|
||||||
|
|
|
@ -53,7 +53,7 @@ proc: BEGIN
|
||||||
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
||||||
AND t.warehouseInFk = vWarehouse
|
AND t.warehouseInFk = vWarehouse
|
||||||
AND s.name != 'INVENTARIO'
|
AND s.name != 'INVENTARIO'
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
) c
|
) c
|
||||||
JOIN vn.item i ON i.id = c.itemFk
|
JOIN vn.item i ON i.id = c.itemFk
|
||||||
|
|
|
@ -6,16 +6,16 @@ BEGIN
|
||||||
|
|
||||||
UPDATE vn.buy b
|
UPDATE vn.buy b
|
||||||
JOIN vn.entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
|
JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
|
||||||
SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
|
SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
|
||||||
b.stickers = NEW.NumberOfUnits
|
b.stickers = NEW.NumberOfUnits
|
||||||
WHERE i.supplyResponseFk = NEW.ID
|
WHERE i.supplyResponseFk = NEW.ID
|
||||||
AND am.name = 'LOGIFLORA'
|
AND am.name = 'LOGIFLORA'
|
||||||
AND e.isRaid
|
AND tr.daysInForward
|
||||||
AND tr.landed >= util.VN_CURDATE();
|
AND tr.landed >= util.VN_CURDATE();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
WHERE t.landed BETWEEN vDateInv AND vDate
|
WHERE t.landed BETWEEN vDateInv AND vDate
|
||||||
AND t.warehouseInFk = vWarehouse
|
AND t.warehouseInFk = vWarehouse
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, -b.quantity
|
SELECT b.itemFk, -b.quantity
|
||||||
FROM vn.buy b
|
FROM vn.buy b
|
||||||
|
@ -67,7 +67,7 @@ BEGIN
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
|
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
|
||||||
AND t.warehouseOutFk = vWarehouse
|
AND t.warehouseOutFk = vWarehouse
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
AND t.isDelivered
|
AND t.isDelivered
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT m.itemFk, -m.quantity
|
SELECT m.itemFk, -m.quantity
|
||||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
||||||
e.id entryFk,
|
e.id entryFk,
|
||||||
t.id travelFk,
|
t.id travelFk,
|
||||||
b.itemFk,
|
b.itemFk,
|
||||||
e.isRaid,
|
t.daysInForward,
|
||||||
ADDTIME(t.shipped,
|
ADDTIME(t.shipped,
|
||||||
IFNULL(t.shipmentHour, '00:00:00')) shipped,
|
IFNULL(t.shipmentHour, '00:00:00')) shipped,
|
||||||
t.warehouseOutFk,
|
t.warehouseOutFk,
|
||||||
|
@ -50,7 +50,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
TIMESTAMPADD(DAY, life, @dated),
|
TIMESTAMPADD(DAY, life, @dated),
|
||||||
quantity,
|
quantity,
|
||||||
IF(isIn, isReceived, isDelivered) AND !isRaid
|
IF(isIn, isReceived, isDelivered) AND NOT daysInForward
|
||||||
FROM tValues
|
FROM tValues
|
||||||
WHERE isIn OR !lessThanInventory;
|
WHERE isIn OR !lessThanInventory;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
created,
|
created,
|
||||||
quantity,
|
quantity,
|
||||||
IF(isIn, isDelivered, isReceived) AND !isRaid
|
IF(isIn, isDelivered, isReceived) AND NOT daysInForward
|
||||||
FROM tValues
|
FROM tValues
|
||||||
WHERE !isIn OR !lessThanInventory;
|
WHERE !isIn OR !lessThanInventory;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`raidUpdate`
|
|
||||||
ON SCHEDULE EVERY 1 DAY
|
|
||||||
STARTS '2017-12-29 00:05:00.000'
|
|
||||||
ON COMPLETION PRESERVE
|
|
||||||
ENABLE
|
|
||||||
DO CALL raidUpdate$$
|
|
||||||
DELIMITER ;
|
|
|
@ -39,7 +39,7 @@ BEGIN
|
||||||
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT tr.shipped,
|
SELECT tr.shipped,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -58,7 +58,7 @@ BEGIN
|
||||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT t.shipped,
|
SELECT t.shipped,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -81,7 +81,7 @@ BEGIN
|
||||||
FROM tHistoricalPast
|
FROM tHistoricalPast
|
||||||
WHERE `date` < vDate;
|
WHERE `date` < vDate;
|
||||||
|
|
||||||
SELECT p1.*, NULL v_virtual
|
SELECT p1.*, NULL v_virtual
|
||||||
FROM (
|
FROM (
|
||||||
SELECT vDate `date`,
|
SELECT vDate `date`,
|
||||||
vCalculatedInventory input,
|
vCalculatedInventory input,
|
||||||
|
@ -96,7 +96,7 @@ BEGIN
|
||||||
FROM tHistoricalPast
|
FROM tHistoricalPast
|
||||||
WHERE `date` >= vDate
|
WHERE `date` >= vDate
|
||||||
) p1;
|
) p1;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tHistoricalPast;
|
DROP TEMPORARY TABLE tHistoricalPast;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`available_traslate`(
|
||||||
vWarehouseShipment INT)
|
vWarehouseShipment INT)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcular la disponibilidad dependiendo del almacen
|
* Calcular la disponibilidad dependiendo del almacen
|
||||||
* de origen y destino según la fecha.
|
* de origen y destino según la fecha.
|
||||||
*
|
*
|
||||||
* @param vWarehouseLanding Almacén de llegada
|
* @param vWarehouseLanding Almacén de llegada
|
||||||
|
@ -42,10 +42,10 @@ proc: BEGIN
|
||||||
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
|
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
|
||||||
AND t.warehouseInFk = vWarehouseLanding
|
AND t.warehouseInFk = vWarehouseLanding
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY c.itemFk;
|
GROUP BY c.itemFk;
|
||||||
|
|
||||||
-- Tabla con el ultimo dia de last_buy para cada producto
|
-- Tabla con el ultimo dia de last_buy para cada producto
|
||||||
-- que hace un replace de la anterior.
|
-- que hace un replace de la anterior.
|
||||||
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
|
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ proc: BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
|
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
|
||||||
WHERE t.warehouseFk = vWarehouseShipment
|
WHERE t.warehouseFk = vWarehouseShipment
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
|
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
|
||||||
tr.landed);
|
tr.landed);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ proc: BEGIN
|
||||||
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
|
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
|
||||||
WHERE NOT e.isExcludedFromAvailable
|
WHERE NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
AND t.warehouseInFk = vWarehouseLanding
|
AND t.warehouseInFk = vWarehouseLanding
|
||||||
AND t.landed >= vDatedFrom
|
AND t.landed >= vDatedFrom
|
||||||
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
||||||
|
@ -135,4 +135,4 @@ proc: BEGIN
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive;
|
DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
||||||
JOIN agencyMode am ON am.id = tr.agencyModeFk
|
JOIN agencyMode am ON am.id = tr.agencyModeFk
|
||||||
WHERE NOT b.quantity
|
WHERE NOT b.quantity
|
||||||
AND am.code = 'logiflora'
|
AND am.code = 'logiflora'
|
||||||
AND e.isRaid;
|
AND tr.daysInForward;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ BEGIN
|
||||||
supplierFk,
|
supplierFk,
|
||||||
dated,
|
dated,
|
||||||
isExcludedFromAvailable,
|
isExcludedFromAvailable,
|
||||||
isRaid,
|
|
||||||
commission,
|
commission,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
|
@ -28,7 +27,6 @@ BEGIN
|
||||||
supplierFk,
|
supplierFk,
|
||||||
dated,
|
dated,
|
||||||
isExcludedFromAvailable,
|
isExcludedFromAvailable,
|
||||||
isRaid,
|
|
||||||
commission,
|
commission,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_getTransfer`(
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Retorna los artículos trasladables a partir de una entrada.
|
* Retorna los artículos trasladables a partir de una entrada.
|
||||||
*
|
*
|
||||||
* @param vSelf Id de entrada
|
* @param vSelf Id de entrada
|
||||||
*/
|
*/
|
||||||
DECLARE vDateShipped DATE;
|
DECLARE vDateShipped DATE;
|
||||||
|
@ -166,7 +166,7 @@ BEGIN
|
||||||
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
||||||
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
||||||
WHERE ic.display
|
WHERE ic.display
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
AND (ti.visible OR ti.available)
|
AND (ti.visible OR ti.available)
|
||||||
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
|
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseInFk = vWarehouseFk
|
WHERE tr.warehouseInFk = vWarehouseFk
|
||||||
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
GROUP BY b.itemFk;
|
GROUP BY b.itemFk;
|
||||||
|
|
||||||
-- Transfers
|
-- Transfers
|
||||||
|
@ -150,7 +150,7 @@ BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseOutFk = vWarehouseFk
|
WHERE tr.warehouseOutFk = vWarehouseFk
|
||||||
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
) sub
|
) sub
|
||||||
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
||||||
|
|
|
@ -50,16 +50,16 @@ BEGIN
|
||||||
JOIN vn.entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
|
JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
|
||||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||||
'DELIVERED',
|
'DELIVERED',
|
||||||
'FREE')
|
'FREE')
|
||||||
WHERE tr.landed >= vDateInventory
|
WHERE tr.landed >= vDateInventory
|
||||||
AND tr.warehouseInFk = vWarehouseFk
|
AND tr.warehouseInFk = vWarehouseFk
|
||||||
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
|
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
),
|
),
|
||||||
entriesOut AS (
|
entriesOut AS (
|
||||||
SELECT 'entry',
|
SELECT 'entry',
|
||||||
|
@ -95,7 +95,7 @@ BEGIN
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT w.isFeedStock
|
AND NOT w.isFeedStock
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
),
|
),
|
||||||
sales AS (
|
sales AS (
|
||||||
WITH itemSales AS (
|
WITH itemSales AS (
|
||||||
|
@ -147,10 +147,10 @@ BEGIN
|
||||||
NULL
|
NULL
|
||||||
FROM itemSales s
|
FROM itemSales s
|
||||||
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
||||||
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
||||||
AND stk.stateFk = stPrep.id
|
AND stk.stateFk = stPrep.id
|
||||||
GROUP BY s.saleFk
|
GROUP BY s.saleFk
|
||||||
),
|
),
|
||||||
orders AS (
|
orders AS (
|
||||||
SELECT 'order' originType,
|
SELECT 'order' originType,
|
||||||
o.id originId,
|
o.id originId,
|
||||||
|
@ -215,9 +215,9 @@ BEGIN
|
||||||
t.`in` invalue,
|
t.`in` invalue,
|
||||||
t.`out`,
|
t.`out`,
|
||||||
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
|
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
|
||||||
@currentLineFk := IF (@shipped < util.VN_CURDATE()
|
@currentLineFk := IF (@shipped < util.VN_CURDATE()
|
||||||
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
|
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
|
||||||
t.lineFk,
|
t.lineFk,
|
||||||
@currentLineFk) lastPreparedLineFk,
|
@currentLineFk) lastPreparedLineFk,
|
||||||
t.isTicket,
|
t.isTicket,
|
||||||
t.lineFk,
|
t.lineFk,
|
||||||
|
@ -254,21 +254,21 @@ BEGIN
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT originType,
|
SELECT originType,
|
||||||
originId,
|
originId,
|
||||||
shipped,
|
shipped,
|
||||||
alertlevel,
|
alertlevel,
|
||||||
stateName,
|
stateName,
|
||||||
reference,
|
reference,
|
||||||
entityType,
|
entityType,
|
||||||
entityId,
|
entityId,
|
||||||
entityName,
|
entityName,
|
||||||
`in`,
|
`in`,
|
||||||
`out`,
|
`out`,
|
||||||
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
|
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
|
||||||
0,
|
0,
|
||||||
isTicket,
|
isTicket,
|
||||||
lineFk,
|
lineFk,
|
||||||
isPicked,
|
isPicked,
|
||||||
clientType,
|
clientType,
|
||||||
claimFk,
|
claimFk,
|
||||||
`order`
|
`order`
|
||||||
FROM tItemDiary
|
FROM tItemDiary
|
||||||
|
|
|
@ -63,7 +63,7 @@ BEGIN
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.itemFk,
|
SELECT r.itemFk,
|
||||||
r.shipment,
|
r.shipment,
|
||||||
|
|
|
@ -17,22 +17,22 @@ BEGIN
|
||||||
|
|
||||||
ALTER TABLE tmp.itemInventory
|
ALTER TABLE tmp.itemInventory
|
||||||
ADD `buy_date` datetime NOT NULL;
|
ADD `buy_date` datetime NOT NULL;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE lastBuyScope
|
CREATE OR REPLACE TEMPORARY TABLE lastBuyScope
|
||||||
SELECT i.id, MAX(t.landed) lastLanded
|
SELECT i.id, MAX(t.landed) lastLanded
|
||||||
FROM item i
|
FROM item i
|
||||||
JOIN buy b ON b.itemFk = i.id
|
JOIN buy b ON b.itemFk = i.id
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
JOIN supplier s ON s.id = e.supplierFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated
|
WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated
|
||||||
AND NOT s.name = 'INVENTARIO'
|
AND NOT s.name = 'INVENTARIO'
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY i.id;
|
GROUP BY i.id;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory y
|
UPDATE tmp.itemInventory y
|
||||||
JOIN lastBuyScope lbs ON lbs.id = y.id
|
JOIN lastBuyScope lbs ON lbs.id = y.id
|
||||||
SET y.buy_date = lbs.lastLanded;
|
SET y.buy_date = lbs.lastLanded;
|
||||||
|
|
|
@ -25,7 +25,7 @@ BEGIN
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
SET vHasNotInventory = (vInventoried IS NULL);
|
SET vHasNotInventory = (vInventoried IS NULL);
|
||||||
|
|
||||||
IF vHasNotInventory THEN
|
IF vHasNotInventory THEN
|
||||||
SELECT landed INTO vInventoryClone
|
SELECT landed INTO vInventoryClone
|
||||||
FROM travel tr
|
FROM travel tr
|
||||||
|
@ -50,7 +50,7 @@ BEGIN
|
||||||
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
||||||
)
|
)
|
||||||
ENGINE = MEMORY;
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
-- Inventario inicial
|
-- Inventario inicial
|
||||||
IF vHasNotInventory THEN
|
IF vHasNotInventory THEN
|
||||||
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
||||||
|
@ -109,7 +109,7 @@ BEGIN
|
||||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||||
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.supplierFk <> vInventorySupplierFk
|
AND e.supplierFk <> vInventorySupplierFk
|
||||||
|
@ -131,7 +131,7 @@ BEGIN
|
||||||
JOIN itemCategory ic ON ic.id = t.categoryFk
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||||
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
@ -159,7 +159,7 @@ BEGIN
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
||||||
|
|
||||||
-- Volver a poner lo que esta aun en las estanterias
|
-- Volver a poner lo que esta aun en las estanterias
|
||||||
IF vDated = util.VN_CURDATE() THEN
|
IF vDated = util.VN_CURDATE() THEN
|
||||||
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
||||||
SELECT w.id,
|
SELECT w.id,
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
|
@ -196,14 +196,14 @@ BEGIN
|
||||||
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
||||||
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
||||||
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
AND wIn.valuatedInventory
|
AND wIn.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.isConfirmed
|
AND e.isConfirmed
|
||||||
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
||||||
|
|
||||||
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
|
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
|
||||||
|
|
||||||
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
||||||
|
@ -233,7 +233,7 @@ BEGIN
|
||||||
JOIN warehouse w ON w.id = warehouseFk
|
JOIN warehouse w ON w.id = warehouseFk
|
||||||
JOIN item i ON i.id = ti.itemFk
|
JOIN item i ON i.id = ti.itemFk
|
||||||
JOIN itemType tp ON tp.id = i.typeFk
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
WHERE w.valuatedInventory
|
WHERE w.valuatedInventory
|
||||||
AND ti.total > 0;
|
AND ti.total > 0;
|
||||||
|
|
||||||
|
|
|
@ -1,173 +1,173 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`(
|
||||||
vDate DATE,
|
vDate DATE,
|
||||||
vWarehouseFk TINYINT,
|
vWarehouseFk TINYINT,
|
||||||
vMaxDays TINYINT
|
vMaxDays TINYINT
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
|
DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
|
||||||
DECLARE vDateFrom DATE DEFAULT vDate;
|
DECLARE vDateFrom DATE DEFAULT vDate;
|
||||||
DECLARE vDateTo DATETIME;
|
DECLARE vDateTo DATETIME;
|
||||||
DECLARE vDateToTomorrow DATETIME;
|
DECLARE vDateToTomorrow DATETIME;
|
||||||
DECLARE vDefaultDayRange INT;
|
DECLARE vDefaultDayRange INT;
|
||||||
DECLARE vCalcFk INT;
|
DECLARE vCalcFk INT;
|
||||||
|
|
||||||
IF vDate < util.VN_CURDATE() THEN
|
IF vDate < util.VN_CURDATE() THEN
|
||||||
LEAVE proc;
|
LEAVE proc;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vDate = util.VN_CURDATE() THEN
|
IF vDate = util.VN_CURDATE() THEN
|
||||||
SELECT inventoried INTO vDateFrom
|
SELECT inventoried INTO vDateFrom
|
||||||
FROM config;
|
FROM config;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT defaultDayRange INTO vDefaultDayRange
|
SELECT defaultDayRange INTO vDefaultDayRange
|
||||||
FROM comparativeConfig;
|
FROM comparativeConfig;
|
||||||
|
|
||||||
SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
|
SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
|
||||||
SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
|
SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
|
||||||
|
|
||||||
ALTER TABLE tmp.itemInventory
|
ALTER TABLE tmp.itemInventory
|
||||||
ADD `avalaible` INT NOT NULL,
|
ADD `avalaible` INT NOT NULL,
|
||||||
ADD `sd` INT NOT NULL,
|
ADD `sd` INT NOT NULL,
|
||||||
ADD `rest` INT NOT NULL,
|
ADD `rest` INT NOT NULL,
|
||||||
ADD `expected` INT NOT NULL,
|
ADD `expected` INT NOT NULL,
|
||||||
ADD `inventory` INT NOT NULL,
|
ADD `inventory` INT NOT NULL,
|
||||||
ADD `visible` INT NOT NULL,
|
ADD `visible` INT NOT NULL,
|
||||||
ADD `life` TINYINT NOT NULL DEFAULT '0';
|
ADD `life` TINYINT NOT NULL DEFAULT '0';
|
||||||
|
|
||||||
-- Calculo del inventario
|
-- Calculo del inventario
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
|
||||||
(PRIMARY KEY (itemFk))
|
(PRIMARY KEY (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT itemFk,
|
SELECT itemFk,
|
||||||
SUM(quantity) quantity
|
SUM(quantity) quantity
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.itemFk, - s.quantity quantity
|
SELECT s.itemFk, - s.quantity quantity
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, b.quantity
|
SELECT b.itemFk, b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, - b.quantity
|
SELECT b.itemFk, - b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseOutFk
|
JOIN warehouse w ON w.id = t.warehouseOutFk
|
||||||
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
) sub
|
) sub
|
||||||
GROUP BY itemFk;
|
GROUP BY itemFk;
|
||||||
|
|
||||||
-- Cálculo del visible
|
-- Cálculo del visible
|
||||||
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
|
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
|
||||||
(PRIMARY KEY (item_id))
|
(PRIMARY KEY (item_id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT item_id, visible
|
SELECT item_id, visible
|
||||||
FROM cache.visible
|
FROM cache.visible
|
||||||
WHERE calc_id = vCalcFk;
|
WHERE calc_id = vCalcFk;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory it
|
UPDATE tmp.itemInventory it
|
||||||
LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
|
LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
|
||||||
LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
|
LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
|
||||||
SET it.inventory = iic.quantity,
|
SET it.inventory = iic.quantity,
|
||||||
it.visible = ivc.visible,
|
it.visible = ivc.visible,
|
||||||
it.avalaible = iic.quantity,
|
it.avalaible = iic.quantity,
|
||||||
it.sd = iic.quantity;
|
it.sd = iic.quantity;
|
||||||
|
|
||||||
-- Calculo del disponible
|
-- Calculo del disponible
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
|
||||||
(INDEX (itemFk, warehouseFk))
|
(INDEX (itemFk, warehouseFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT sub.itemFk,
|
SELECT sub.itemFk,
|
||||||
vWarehouseFk warehouseFk,
|
vWarehouseFk warehouseFk,
|
||||||
sub.dated,
|
sub.dated,
|
||||||
SUM(sub.quantity) quantity
|
SUM(sub.quantity) quantity
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.itemFk,
|
SELECT s.itemFk,
|
||||||
DATE(t.shipped) dated,
|
DATE(t.shipped) dated,
|
||||||
- s.quantity quantity
|
- s.quantity quantity
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, t.landed, b.quantity
|
SELECT b.itemFk, t.landed, b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, t.shipped, - b.quantity
|
SELECT b.itemFk, t.shipped, - b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseOutFk
|
JOIN warehouse w ON w.id = t.warehouseOutFk
|
||||||
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
) sub
|
) sub
|
||||||
GROUP BY sub.itemFk, sub.dated;
|
GROUP BY sub.itemFk, sub.dated;
|
||||||
|
|
||||||
CALL item_getAtp(vDate);
|
CALL item_getAtp(vDate);
|
||||||
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
|
||||||
(PRIMARY KEY (itemFk))
|
(PRIMARY KEY (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT it.itemFk,
|
SELECT it.itemFk,
|
||||||
SUM(it.quantity) quantity,
|
SUM(it.quantity) quantity,
|
||||||
im.quantity minQuantity
|
im.quantity minQuantity
|
||||||
FROM tmp.itemCalc it
|
FROM tmp.itemCalc it
|
||||||
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
||||||
JOIN item i ON i.id = it.itemFk
|
JOIN item i ON i.id = it.itemFk
|
||||||
LEFT JOIN origin o ON o.id = i.originFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
||||||
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
||||||
t.landing,
|
t.landing,
|
||||||
vDateToTomorrow)
|
vDateToTomorrow)
|
||||||
GROUP BY it.itemFk;
|
GROUP BY it.itemFk;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory it
|
UPDATE tmp.itemInventory it
|
||||||
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
||||||
SET it.avalaible = IF(iac.minQuantity > 0,
|
SET it.avalaible = IF(iac.minQuantity > 0,
|
||||||
it.avalaible,
|
it.avalaible,
|
||||||
it.avalaible + iac.minQuantity),
|
it.avalaible + iac.minQuantity),
|
||||||
it.sd = it.inventory + iac.quantity;
|
it.sd = it.inventory + iac.quantity;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.itemTravel,
|
tmp.itemTravel,
|
||||||
tmp.itemCalc,
|
tmp.itemCalc,
|
||||||
tmp.itemAtp,
|
tmp.itemAtp,
|
||||||
tItemInventoryCalc,
|
tItemInventoryCalc,
|
||||||
tItemVisibleCalc,
|
tItemVisibleCalc,
|
||||||
tItemAvailableCalc;
|
tItemAvailableCalc;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`raidUpdate`()
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Actualiza el travel de las entradas de redadas
|
|
||||||
*/
|
|
||||||
UPDATE entry e
|
|
||||||
JOIN entryVirtual ev ON ev.entryFk = e.id
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
JOIN (
|
|
||||||
SELECT *
|
|
||||||
FROM (
|
|
||||||
SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk
|
|
||||||
FROM travel t
|
|
||||||
JOIN (
|
|
||||||
SELECT t.warehouseInFk, t.warehouseOutFk
|
|
||||||
FROM entryVirtual ev
|
|
||||||
JOIN entry e ON e.id = ev.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
GROUP BY t.warehouseInFk, t.warehouseOutFk
|
|
||||||
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
|
||||||
WHERE shipped > util.VN_CURDATE() AND NOT isDelivered
|
|
||||||
ORDER BY t.landed
|
|
||||||
LIMIT 10000000000000000000
|
|
||||||
) t
|
|
||||||
GROUP BY t.warehouseInFk, t.warehouseOutFk
|
|
||||||
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
|
||||||
SET e.travelFk = t.id;
|
|
||||||
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -10,7 +10,7 @@ BEGIN
|
||||||
JOIN vn.entry e ON e.travelFk = tr.id
|
JOIN vn.entry e ON e.travelFk = tr.id
|
||||||
JOIN vn.buy b ON b.entryFk = e.id
|
JOIN vn.buy b ON b.entryFk = e.id
|
||||||
WHERE tr.landed BETWEEN vFromDated AND vToDated
|
WHERE tr.landed BETWEEN vFromDated AND vToDated
|
||||||
AND e.isRaid = FALSE
|
AND NOT tr.daysInForward
|
||||||
AND tr.warehouseInFk = vWarehouseFk
|
AND tr.warehouseInFk = vWarehouseFk
|
||||||
GROUP BY tr.landed , a.name ;
|
GROUP BY tr.landed , a.name ;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -1,72 +1,68 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
/*
|
* Desplaza los travels en el futuro y avisa a los compradores
|
||||||
* Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vWorkerName VARCHAR(50);
|
DECLARE vBuyerEmail VARCHAR(40);
|
||||||
DECLARE vRaid TEXT;
|
DECLARE vTravelLink TEXT;
|
||||||
DECLARE vWorker VARCHAR(50) DEFAULT '';
|
|
||||||
DECLARE vMailBody TEXT DEFAULT '';
|
DECLARE vMailBody TEXT DEFAULT '';
|
||||||
|
|
||||||
DECLARE vCur CURSOR FOR
|
DECLARE vCur CURSOR FOR
|
||||||
SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'),
|
SELECT GROUP_CONCAT(DISTINCT
|
||||||
u.name
|
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
||||||
FROM tmp.travel ttr
|
ttm.travelFk,
|
||||||
JOIN entry e ON e.travelFk = ttr.id
|
'/summary ')
|
||||||
|
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
|
||||||
|
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
||||||
|
FROM tTravelToMove ttm
|
||||||
|
JOIN entry e ON e.travelFk = ttm.travelFk
|
||||||
JOIN buy b ON b.entryFk = e.id
|
JOIN buy b ON b.entryFk = e.id
|
||||||
JOIN item i ON i.id = b.itemFk
|
JOIN item i ON i.id = b.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
JOIN account.user u ON u.id = it.workerFk
|
JOIN account.user u ON u.id = it.workerFk
|
||||||
GROUP BY u.name;
|
GROUP BY u.name;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
SET vDone = TRUE;
|
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.travel;
|
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
||||||
CREATE TEMPORARY TABLE tmp.travel
|
SELECT id travelFk,
|
||||||
SELECT tr.id,tr.landed
|
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
|
||||||
FROM travel tr
|
FROM travel
|
||||||
JOIN entry e ON e.travelFk = tr.id
|
WHERE daysInForward;
|
||||||
WHERE tr.landed = util.tomorrow()
|
|
||||||
AND e.isRaid
|
|
||||||
GROUP BY tr.id;
|
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE travel tr
|
UPDATE travel tr
|
||||||
JOIN tmp.travel ttr ON ttr.id = tr.id
|
JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
|
||||||
SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed);
|
SET tr.landed = ttm.newLanded;
|
||||||
|
|
||||||
OPEN vCur;
|
OPEN vCur;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vCur INTO vRaid, vWorkerName;
|
FETCH vCur INTO vTravelLink, vBuyerEmail;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL `vn`.`mail_insert`(CONCAT(vWorkerName, '@verdnatura.es'),
|
CALL `vn`.`mail_insert`(
|
||||||
'noreply@verdnatura.es',
|
vBuyerEmail,
|
||||||
'Cambio de fecha en Redadas',
|
'noreply@verdnatura.es',
|
||||||
CONCAT('Se ha movido las siguientes redadas: \n\r ', vRaid)
|
'Cambio de fecha en Redadas',
|
||||||
);
|
CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vCur;
|
CLOSE vCur;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
DROP TEMPORARY TABLE tmp.travel;
|
DROP TEMPORARY TABLE tTravelToMove;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
|
||||||
BEFORE UPDATE ON `entry`
|
BEFORE UPDATE ON `entry`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vIsVirtual BOOL;
|
DECLARE vDaysInForward INT;
|
||||||
DECLARE vPrintedCount INT;
|
DECLARE vPrintedCount INT;
|
||||||
DECLARE vHasDistinctWarehouses BOOL;
|
DECLARE vHasDistinctWarehouses BOOL;
|
||||||
DECLARE vTotalBuy INT;
|
DECLARE vTotalBuy INT;
|
||||||
|
@ -37,18 +37,20 @@ BEGIN
|
||||||
IF NEW.travelFk IS NOT NULL THEN
|
IF NEW.travelFk IS NOT NULL THEN
|
||||||
CALL travel_throwAwb(NEW.travelFk);
|
CALL travel_throwAwb(NEW.travelFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) > 0 INTO vIsVirtual
|
SELECT daysInForward INTO vDaysInForward
|
||||||
FROM entryVirtual WHERE entryFk = NEW.id;
|
FROM travel t
|
||||||
|
JOIN entry e ON e.travelFk = t.id
|
||||||
|
WHERE entryFk = NEW.id;
|
||||||
|
|
||||||
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
|
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
|
||||||
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
|
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
|
||||||
INTO vHasDistinctWarehouses
|
INTO vHasDistinctWarehouses
|
||||||
FROM travel o, travel n
|
FROM travel o, travel n
|
||||||
WHERE o.id = OLD.travelFk
|
WHERE o.id = OLD.travelFk
|
||||||
AND n.id = NEW.travelFk;
|
AND n.id = NEW.travelFk;
|
||||||
|
|
||||||
IF vIsVirtual AND vHasDistinctWarehouses THEN
|
IF vDaysInForward AND vHasDistinctWarehouses THEN
|
||||||
SIGNAL SQLSTATE '45000'
|
SIGNAL SQLSTATE '45000'
|
||||||
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
|
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -71,7 +73,7 @@ BEGIN
|
||||||
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.travelFk <=> OLD.travelFk)
|
IF NOT (NEW.travelFk <=> OLD.travelFk)
|
||||||
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
|
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
|
||||||
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
|
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
|
||||||
`b`.`itemFk` AS `itemFk`,
|
`b`.`itemFk` AS `itemFk`,
|
||||||
`b`.`quantity` AS `quantity`,
|
`b`.`quantity` AS `quantity`,
|
||||||
`t`.`isReceived` AS `isReceived`,
|
`t`.`isReceived` AS `isReceived`,
|
||||||
`e`.`isRaid` AS `isVirtualStock`,
|
`t`.`daysInForward` AS `isVirtualStock`,
|
||||||
`e`.`id` AS `entryFk`
|
`e`.`id` AS `entryFk`
|
||||||
FROM (
|
FROM (
|
||||||
(
|
(
|
||||||
|
|
|
@ -15,5 +15,5 @@ FROM (
|
||||||
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
|
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
|
||||||
)
|
)
|
||||||
WHERE `e`.`isExcludedFromAvailable` = 0
|
WHERE `e`.`isExcludedFromAvailable` = 0
|
||||||
AND `e`.`isRaid` = 0
|
AND NOT `t`.`daysInForward`
|
||||||
AND `b`.`quantity` <> 0
|
AND `b`.`quantity` <> 0
|
||||||
|
|
|
@ -31,5 +31,5 @@ FROM (
|
||||||
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
||||||
)
|
)
|
||||||
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
||||||
AND `e`.`isRaid` = 0
|
AND NOT `tr`.`daysInForward`
|
||||||
AND `b`.`stickers` > 0
|
AND `b`.`stickers` > 0
|
||||||
|
|
|
@ -8,7 +8,6 @@ AS SELECT `e`.`id` AS `Id_Entrada`,
|
||||||
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
||||||
`e`.`isConfirmed` AS `Confirmada`,
|
`e`.`isConfirmed` AS `Confirmada`,
|
||||||
`e`.`isOrdered` AS `Pedida`,
|
`e`.`isOrdered` AS `Pedida`,
|
||||||
`e`.`isRaid` AS `Redada`,
|
|
||||||
`e`.`commission` AS `comision`,
|
`e`.`commission` AS `comision`,
|
||||||
`e`.`created` AS `odbc_date`,
|
`e`.`created` AS `odbc_date`,
|
||||||
`e`.`evaNotes` AS `Notas_Eva`,
|
`e`.`evaNotes` AS `Notas_Eva`,
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`Entradas_Auto`
|
|
||||||
AS SELECT `ev`.`entryFk` AS `Id_Entrada`
|
|
||||||
FROM `vn`.`entryVirtual` `ev`
|
|
|
@ -8,7 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
|
||||||
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
||||||
`e`.`isConfirmed` AS `Confirmada`,
|
`e`.`isConfirmed` AS `Confirmada`,
|
||||||
`e`.`isOrdered` AS `Pedida`,
|
`e`.`isOrdered` AS `Pedida`,
|
||||||
`e`.`isRaid` AS `Redada`,
|
`tr`.`daysInForward` AS `Redada`,
|
||||||
`e`.`evaNotes` AS `notas`,
|
`e`.`evaNotes` AS `notas`,
|
||||||
`e`.`supplierFk` AS `Id_Proveedor`,
|
`e`.`supplierFk` AS `Id_Proveedor`,
|
||||||
`tr`.`shipped` AS `shipment`,
|
`tr`.`shipped` AS `shipment`,
|
||||||
|
|
|
@ -17,5 +17,6 @@ AS SELECT `t`.`id` AS `id`,
|
||||||
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
||||||
`t`.`totalEntries` AS `totalEntries`,
|
`t`.`totalEntries` AS `totalEntries`,
|
||||||
`t`.`appointment` AS `appointment`,
|
`t`.`appointment` AS `appointment`,
|
||||||
`t`.`awbFk` AS `awbFk`
|
`t`.`awbFk` AS `awbFk`,
|
||||||
|
`t`.`daysInForward` AS `daysInForward`
|
||||||
FROM `vn`.`travel` `t`
|
FROM `vn`.`travel` `t`
|
||||||
|
|
|
@ -28,7 +28,6 @@ AS SELECT `TP`.`Id_Tipo` AS `Familia`,
|
||||||
`E`.`Id_Proveedor` AS `Id_Proveedor`,
|
`E`.`Id_Proveedor` AS `Id_Proveedor`,
|
||||||
`E`.`Fecha` AS `Fecha`,
|
`E`.`Fecha` AS `Fecha`,
|
||||||
`E`.`Confirmada` AS `Confirmada`,
|
`E`.`Confirmada` AS `Confirmada`,
|
||||||
`E`.`Redada` AS `Redada`,
|
|
||||||
`E`.`empresa_id` AS `empresa_id`,
|
`E`.`empresa_id` AS `empresa_id`,
|
||||||
`E`.`travel_id` AS `travel_id`,
|
`E`.`travel_id` AS `travel_id`,
|
||||||
`E`.`Pedida` AS `Pedida`,
|
`E`.`Pedida` AS `Pedida`,
|
||||||
|
@ -85,6 +84,6 @@ FROM (
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
|
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
|
||||||
)
|
)
|
||||||
WHERE `W_IN`.`isFeedStock` = 0
|
WHERE NOT `W_IN`.`isFeedStock`
|
||||||
AND `E`.`Inventario` = 0
|
AND NOT `E`.`Inventario`
|
||||||
AND `E`.`Redada` = 0
|
AND NOT `TR`.`daysInForward`
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT NULL NULL
|
||||||
|
COMMENT 'Número de días donde se siturá el landed de las entradas con respecto a hoy';
|
|
@ -9,7 +9,6 @@ columns:
|
||||||
notes: notes
|
notes: notes
|
||||||
isConfirmed: confirmed
|
isConfirmed: confirmed
|
||||||
isVirtual: virtual
|
isVirtual: virtual
|
||||||
isRaid: raid
|
|
||||||
commission: commission
|
commission: commission
|
||||||
isOrdered: price3
|
isOrdered: price3
|
||||||
created: created
|
created: created
|
||||||
|
|
|
@ -9,7 +9,6 @@ columns:
|
||||||
notes: notas
|
notes: notas
|
||||||
isConfirmed: confirmado
|
isConfirmed: confirmado
|
||||||
isVirtual: virtual
|
isVirtual: virtual
|
||||||
isRaid: redada
|
|
||||||
commission: comisión
|
commission: comisión
|
||||||
isOrdered: pedida
|
isOrdered: pedida
|
||||||
created: creado
|
created: creado
|
||||||
|
|
|
@ -194,7 +194,7 @@ module.exports = Self => {
|
||||||
e.evaNotes observation,
|
e.evaNotes observation,
|
||||||
e.isConfirmed,
|
e.isConfirmed,
|
||||||
e.isOrdered,
|
e.isOrdered,
|
||||||
e.isRaid,
|
t.daysInForward,
|
||||||
e.commission,
|
e.commission,
|
||||||
e.created,
|
e.created,
|
||||||
e.travelFk,
|
e.travelFk,
|
||||||
|
|
|
@ -48,7 +48,9 @@ module.exports = Self => {
|
||||||
'warehouseInFk',
|
'warehouseInFk',
|
||||||
'isReceived',
|
'isReceived',
|
||||||
'isDelivered',
|
'isDelivered',
|
||||||
'ref'],
|
'ref',
|
||||||
|
'daysInForward',
|
||||||
|
],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'agency',
|
relation: 'agency',
|
||||||
|
@ -85,7 +87,6 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
return models.Entry.findOne(filter, myOptions);
|
return models.Entry.findOne(filter, myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,15 +33,6 @@
|
||||||
"isConfirmed": {
|
"isConfirmed": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"isVirtual": {
|
|
||||||
"type": "boolean",
|
|
||||||
"mysql": {
|
|
||||||
"columnName": "isRaid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isRaid": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"commission": {
|
"commission": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
@ -88,7 +79,8 @@
|
||||||
"travel": {
|
"travel": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Travel",
|
"model": "Travel",
|
||||||
"foreignKey": "travelFk"
|
"foreignKey": "travelFk",
|
||||||
|
"daysInForward": "daysInForward"
|
||||||
},
|
},
|
||||||
"company": {
|
"company": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
|
|
|
@ -44,7 +44,6 @@ module.exports = Self => {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let travel = await Self.app.models.Travel.findOne(filter);
|
return Self.app.models.Travel.findOne(filter);
|
||||||
return travel;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,6 +50,9 @@
|
||||||
},
|
},
|
||||||
"landingHour": {
|
"landingHour": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"daysInForward": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
Loading…
Reference in New Issue