7648_myEntries #2744
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: 'boolean',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
||||||
const xmlString = response.data;
|
const xmlString = response.data;
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||||
|
return result.toLowerCase().includes('se ha cancelado correctamente');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</mrw:Direccion>
|
</mrw:Direccion>
|
||||||
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
||||||
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
||||||
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
<mrw:Telefono><%= expeditionData.mobile %></mrw:Telefono>
|
||||||
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
||||||
</mrw:DatosEntrega>
|
</mrw:DatosEntrega>
|
||||||
<mrw:DatosServicio>
|
<mrw:DatosServicio>
|
||||||
|
|
|
@ -47,7 +47,7 @@ module.exports = Self => {
|
||||||
co.code countryCode,
|
co.code countryCode,
|
||||||
c.fi,
|
c.fi,
|
||||||
c.name clientName,
|
c.name clientName,
|
||||||
c.phone,
|
a.mobile,
|
||||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||||
t.shipped,
|
t.shipped,
|
||||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||||
|
|
|
@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithR
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vQuantity INT,
|
vQuantity INT,
|
||||||
vTicketFk INT,
|
vTicketFk INT,
|
||||||
vSaleGroupFk INT
|
vSaleGroupFk INT,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +68,7 @@ BEGIN
|
||||||
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
||||||
|
|
||||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
CALL sale_calculateComponent(vSaleFk, NULL);
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(
|
||||||
|
vExpeditions JSON,
|
||||||
|
vArcId INT,
|
||||||
|
vWorkerFk INT,
|
||||||
|
OUT vPalletFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/** Construye un pallet de expediciones.
|
/** Construye un pallet de expediciones.
|
||||||
*
|
*
|
||||||
|
@ -7,28 +12,22 @@ BEGIN
|
||||||
* en cuyo caso actualiza ese pallet.
|
* en cuyo caso actualiza ese pallet.
|
||||||
*
|
*
|
||||||
* @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
|
* @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
|
||||||
* @param vArcId INT Identificador de vn.arcRead
|
* @param vArcId INT Identificador de arcRead
|
||||||
* @param vWorkerFk INT Identificador de vn.worker
|
* @param vWorkerFk INT Identificador de worker
|
||||||
* @param out vPalletFk Identificador de vn.expeditionPallet
|
* @param out vPalletFk Identificador de expeditionPallet
|
||||||
*/
|
*/
|
||||||
DECLARE vCounter INT;
|
DECLARE vCounter INT;
|
||||||
DECLARE vExpeditionFk INT;
|
DECLARE vExpeditionFk INT;
|
||||||
DECLARE vTruckFk INT;
|
DECLARE vTruckFk INT;
|
||||||
DECLARE vPrinterFk INT;
|
DECLARE vPrinterFk INT;
|
||||||
|
DECLARE vExpeditionScanTypeFk INT;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tExpedition;
|
CREATE OR REPLACE TEMPORARY TABLE tExpedition (
|
||||||
CREATE TEMPORARY TABLE tExpedition
|
expeditionFk INT,
|
||||||
SELECT
|
routeFk INT,
|
||||||
e.id expeditionFk,
|
palletFk INT,
|
||||||
r.id routeFk,
|
PRIMARY KEY (expeditionFk)
|
||||||
ep.id palletFk
|
);
|
||||||
FROM
|
|
||||||
vn.expedition e,
|
|
||||||
vn.route r,
|
|
||||||
vn.expeditionPallet ep
|
|
||||||
LIMIT 0;
|
|
||||||
|
|
||||||
ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk);
|
|
||||||
|
|
||||||
SET vCounter = JSON_LENGTH(vExpeditions);
|
SET vCounter = JSON_LENGTH(vExpeditions);
|
||||||
|
|
||||||
|
@ -39,53 +38,56 @@ BEGIN
|
||||||
|
|
||||||
INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk)
|
INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk)
|
||||||
SELECT vExpeditionFk, t.routeFk, es.palletFk
|
SELECT vExpeditionFk, t.routeFk, es.palletFk
|
||||||
FROM vn.expedition e
|
FROM expedition e
|
||||||
LEFT JOIN vn.ticket t ON t.id = e.ticketFk
|
LEFT JOIN ticket t ON t.id = e.ticketFk
|
||||||
LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id
|
LEFT JOIN expeditionScan es ON es.expeditionFk = e.id
|
||||||
WHERE e.id = vExpeditionFk;
|
WHERE e.id = vExpeditionFk;
|
||||||
END WHILE;
|
END WHILE;
|
||||||
|
|
||||||
SELECT palletFk INTO vPalletFk
|
SELECT palletFk INTO vPalletFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT palletFk, count(*) n
|
SELECT palletFk, count(*) n
|
||||||
FROM tExpedition
|
FROM tExpedition
|
||||||
WHERE palletFk > 0
|
WHERE palletFk > 0
|
||||||
GROUP BY palletFk
|
GROUP BY palletFk
|
||||||
ORDER BY n DESC
|
ORDER BY n DESC
|
||||||
LIMIT 100 ) sub
|
LIMIT 100
|
||||||
|
) sub
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF vPalletFk IS NULL THEN
|
IF vPalletFk IS NULL THEN
|
||||||
SELECT roadmapStopFk
|
SELECT roadmapStopFk INTO vTruckFk
|
||||||
INTO vTruckFk
|
FROM (
|
||||||
FROM (
|
SELECT rm.roadmapStopFk, count(*) n
|
||||||
SELECT rm.roadmapStopFk, count(*) n
|
FROM routesMonitor rm
|
||||||
FROM vn.routesMonitor rm
|
JOIN tExpedition e ON e.routeFk = rm.routeFk
|
||||||
JOIN tExpedition e ON e.routeFk = rm.routeFk
|
GROUP BY roadmapStopFk
|
||||||
GROUP BY roadmapStopFk
|
ORDER BY n DESC
|
||||||
ORDER BY n DESC
|
LIMIT 1
|
||||||
LIMIT 1) sub;
|
) sub;
|
||||||
|
|
||||||
IF vTruckFk IS NULL THEN
|
IF vTruckFk IS NULL THEN
|
||||||
CALL util.throw ('TRUCK_NOT_AVAILABLE');
|
CALL util.throw ('TRUCK_NOT_AVAILABLE');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO vn.expeditionPallet(truckFk)
|
INSERT INTO expeditionPallet SET truckFk = vTruckFk;
|
||||||
VALUES(vTruckFk);
|
|
||||||
|
|
||||||
SET vPalletFk = LAST_INSERT_ID();
|
SET vPalletFk = LAST_INSERT_ID();
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk)
|
INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk)
|
||||||
SELECT expeditionFk, vPalletFk, vWorkerFk
|
SELECT expeditionFk, vPalletFk, vWorkerFk
|
||||||
FROM tExpedition
|
FROM tExpedition
|
||||||
ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
|
ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
|
||||||
|
|
||||||
SELECT printerFk INTO vPrinterFk
|
SELECT id INTO vExpeditionScanTypeFk FROM expeditionScanType WHERE code = 'PALLETIZED';
|
||||||
FROM vn.arcRead
|
|
||||||
WHERE id = vArcId;
|
|
||||||
|
|
||||||
CALL vn.report_print(
|
INSERT INTO expeditionState(expeditionFk, typeFk)
|
||||||
|
SELECT expeditionFk, vExpeditionScanTypeFk FROM tExpedition;
|
||||||
|
|
||||||
|
SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;
|
||||||
|
|
||||||
|
CALL report_print(
|
||||||
'LabelPalletExpedition',
|
'LabelPalletExpedition',
|
||||||
vPrinterFk,
|
vPrinterFk,
|
||||||
account.myUser_getId(),
|
account.myUser_getId(),
|
||||||
|
@ -93,7 +95,7 @@ BEGIN
|
||||||
'high'
|
'high'
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
|
UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tExpedition;
|
DROP TEMPORARY TABLE tExpedition;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -44,7 +44,7 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, NULL);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
|
||||||
vSaleFk INT
|
vSaleFk INT,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +9,7 @@ proc: BEGIN
|
||||||
*
|
*
|
||||||
* @param vSaleFk Id de sale
|
* @param vSaleFk Id de sale
|
||||||
* @param vItemShelvingSaleFk Id de reserva
|
* @param vItemShelvingSaleFk Id de reserva
|
||||||
|
* @param vSectorFk Id del sector del operator
|
||||||
*/
|
*/
|
||||||
DECLARE vLastPickingOrder INT;
|
DECLARE vLastPickingOrder INT;
|
||||||
DECLARE vDone INT DEFAULT FALSE;
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
|
@ -30,6 +32,7 @@ proc: BEGIN
|
||||||
JOIN productionConfig pc
|
JOIN productionConfig pc
|
||||||
WHERE s.id = vSaleFk
|
WHERE s.id = vSaleFk
|
||||||
AND NOT sc.isHideForPickers
|
AND NOT sc.isHideForPickers
|
||||||
|
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
||||||
ORDER BY s.id,
|
ORDER BY s.id,
|
||||||
p.pickingOrder >= vLastPickingOrder,
|
p.pickingOrder >= vLastPickingOrder,
|
||||||
sh.priority DESC,
|
sh.priority DESC,
|
||||||
|
|
|
@ -10,6 +10,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
DECLARE vSales CURSOR FOR
|
DECLARE vSales CURSOR FOR
|
||||||
SELECT s.id
|
SELECT s.id
|
||||||
FROM sectorCollectionSaleGroup sc
|
FROM sectorCollectionSaleGroup sc
|
||||||
|
@ -25,6 +26,10 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT sectorFk INTO vSectorFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
OPEN vSales;
|
OPEN vSales;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
|
@ -34,7 +39,7 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -6,9 +6,10 @@ proc: BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
|
|
||||||
DECLARE vSales CURSOR FOR
|
DECLARE vSales CURSOR FOR
|
||||||
SELECT DISTINCT saleFk FROM tSale;
|
SELECT DISTINCT saleFk, sectorFk FROM tSale;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||||
SET vDone = TRUE;
|
SET vDone = TRUE;
|
||||||
|
@ -26,24 +27,25 @@ proc: BEGIN
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSale
|
CREATE OR REPLACE TEMPORARY TABLE tSale
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id, saleFk FROM itemShelvingSaleReserve;
|
SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve;
|
||||||
|
|
||||||
OPEN vSales;
|
OPEN vSales;
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vSales INTO vSaleFk;
|
FETCH vSales INTO vSaleFk, vSectorFk;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale (vSaleFk);
|
CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
|
|
||||||
DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id;
|
DELETE iss FROM itemShelvingSaleReserve iss
|
||||||
|
JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tSale;
|
DROP TEMPORARY TABLE tSale;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
||||||
vItemShelvingFk INT(10),
|
vItemShelvingFk INT(10),
|
||||||
vItemFk INT(10)
|
vItemFk INT(10),
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
||||||
*
|
*
|
||||||
* @param vItemShelvingFk Id itemShelving
|
* @param vItemShelvingFk Id itemShelving
|
||||||
|
* @param vItemFk Id del artículo
|
||||||
|
* @param vSectorFk Id del sector
|
||||||
*/
|
*/
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -17,18 +20,21 @@ BEGIN
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
SELECT id INTO vItemShelvingFk
|
|
||||||
FROM itemShelving
|
|
||||||
WHERE id = vItemShelvingFk
|
|
||||||
FOR UPDATE;
|
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET visible = 0,
|
SET visible = 0,
|
||||||
available = 0
|
available = 0
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
AND itemFk = vItemFk;
|
AND itemFk = vItemFk;
|
||||||
|
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
SELECT iss.id
|
||||||
|
FROM itemShelvingSale iss
|
||||||
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
|
AND iss.itemFk = vItemFk
|
||||||
|
AND NOT iss.isPicked
|
||||||
|
FOR UPDATE;
|
||||||
|
|
||||||
|
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
||||||
SELECT DISTINCT iss.saleFk
|
SELECT DISTINCT iss.saleFk
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
|
|
@ -2,7 +2,8 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
|
||||||
vItemShelvingSaleFk INT(10),
|
vItemShelvingSaleFk INT(10),
|
||||||
vQuantity DECIMAL(10,0),
|
vQuantity DECIMAL(10,0),
|
||||||
vIsItemShelvingSaleEmpty BOOLEAN
|
vIsItemShelvingSaleEmpty BOOLEAN,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +15,7 @@ BEGIN
|
||||||
* @param vQuantity Cantidad real que se ha cogido de la ubicación
|
* @param vQuantity Cantidad real que se ha cogido de la ubicación
|
||||||
* @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha
|
* @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha
|
||||||
* quedado vacio tras el movimiento
|
* quedado vacio tras el movimiento
|
||||||
|
* @param vSectorFk Id del sector
|
||||||
*/
|
*/
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
DECLARE vItemShelvingFk INT;
|
DECLARE vItemShelvingFk INT;
|
||||||
|
@ -29,6 +31,12 @@ BEGIN
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
IF vQuantity > vReservedQuantity
|
||||||
|
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
|
||||||
|
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
|
||||||
|
CALL util.throw('The quantity cannot be different from the reserved');
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN
|
IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN
|
||||||
CALL util.throw('Reservation completed');
|
CALL util.throw('Reservation completed');
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -50,9 +58,8 @@ BEGIN
|
||||||
AND NOT iss.isPicked;
|
AND NOT iss.isPicked;
|
||||||
|
|
||||||
IF vQuantity > vReservedQuantity
|
IF vQuantity > vReservedQuantity
|
||||||
OR (vQuantity < vReservedQuantity AND
|
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
|
||||||
(NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL))
|
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
|
||||||
OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN
|
|
||||||
CALL util.throw('The quantity cannot be different from the reserved');
|
CALL util.throw('The quantity cannot be different from the reserved');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -72,7 +79,7 @@ BEGIN
|
||||||
SET visible = GREATEST(0, visible - vQuantity)
|
SET visible = GREATEST(0, visible - vQuantity)
|
||||||
WHERE id = vItemShelvingFk;
|
WHERE id = vItemShelvingFk;
|
||||||
|
|
||||||
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
|
SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity)
|
||||||
INTO vRemainingQuantity, vTotalQuantity
|
INTO vRemainingQuantity, vTotalQuantity
|
||||||
FROM itemShelvingSale
|
FROM itemShelvingSale
|
||||||
WHERE saleFk = vSaleFk;
|
WHERE saleFk = vSaleFk;
|
||||||
|
@ -96,9 +103,9 @@ BEGIN
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
||||||
SELECT vSaleFk;
|
SELECT vSaleFk, vSectorFk;
|
||||||
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk);
|
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve
|
||||||
|
ADD IF NOT EXISTS sectorFk int(11) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve
|
||||||
|
DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve
|
||||||
|
ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id)
|
||||||
|
REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSale MODIFY COLUMN IF EXISTS isPicked tinyint(1) DEFAULT 1 NOT NULL;
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE vn.state DROP FOREIGN KEY state_ibfk_1;
|
||||||
|
ALTER TABLE vn.state ADD CONSTRAINT state_ibfk_1 FOREIGN KEY (alertLevel) REFERENCES vn.alertLevel(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -10,7 +10,7 @@
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
url="Countries"
|
url="Countries"
|
||||||
data="countries"
|
data="countries"
|
||||||
order="country">
|
order="name">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
|
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
|
||||||
description: 'Set quanitity of a sale in itemShelvingSale',
|
description: 'Set quantity of a sale in itemShelvingSale',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,12 @@ module.exports = Self => {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'True if the shelvingFk is empty ',
|
description: 'True if the shelvingFk is empty ',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'sectorFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'Sector Id',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
|
@ -28,14 +34,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => {
|
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, sectorFk, options) => {
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`,
|
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ?, ?)`,
|
||||||
[id, quantity, isItemShelvingSaleEmpty],
|
[id, quantity, isItemShelvingSaleEmpty, sectorFk],
|
||||||
myOptions);
|
myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,34 +27,33 @@ module.exports = Self => {
|
||||||
const deletedExpeditions = [];
|
const deletedExpeditions = [];
|
||||||
|
|
||||||
for (let expeditionId of expeditionIds) {
|
for (let expeditionId of expeditionIds) {
|
||||||
const filter = {
|
try {
|
||||||
fields: [],
|
const expedition = await models.Expedition.findById(expeditionId, {
|
||||||
where: {
|
include: [
|
||||||
id: expeditionId
|
{
|
||||||
},
|
relation: 'agencyMode',
|
||||||
include: [
|
scope: {
|
||||||
{
|
fields: ['code'],
|
||||||
relation: 'agencyMode',
|
}
|
||||||
scope: {
|
|
||||||
fields: ['code'],
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
});
|
||||||
};
|
const {code} = expedition.agencyMode();
|
||||||
|
|
||||||
const expedition = await models.Expedition.findOne(filter);
|
if (code?.toLowerCase()?.includes('mrw') && expedition.externalId) {
|
||||||
const {code} = expedition.agencyMode();
|
const result = await models.MrwConfig.cancelShipment(expeditionId);
|
||||||
|
if (!result) throw new Error('not deleted');
|
||||||
|
}
|
||||||
|
|
||||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') {
|
||||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
const result = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||||
|
if (result !== 'true') throw new Error('not deleted');
|
||||||
|
}
|
||||||
|
|
||||||
if (isDeleted === 'true') {
|
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
|
||||||
deletedExpeditions.push(deletedExpedition);
|
|
||||||
} else notDeletedExpeditions.push(expeditionId);
|
|
||||||
} else {
|
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||||
deletedExpeditions.push(deletedExpedition);
|
deletedExpeditions.push(deletedExpedition);
|
||||||
|
} catch (e) {
|
||||||
|
notDeletedExpeditions.push(expeditionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ module.exports = Self => {
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const days = await conn.executeStmt(sql, myOptions);
|
const days = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
let previousWorkerFk = days[index][0].workerFk;
|
let previousWorkerFk = days[index][0]?.workerFk;
|
||||||
let previousReceiver = days[index][0].receiver;
|
let previousReceiver = days[index][0]?.receiver;
|
||||||
|
|
||||||
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ module.exports = Self => {
|
||||||
const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`;
|
const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`;
|
||||||
ctx.args.url = url;
|
ctx.args.url = url;
|
||||||
|
|
||||||
await models.WorkerTimeControl.updateMailState(ctx, ctx.workerId, myOptions);
|
await models.WorkerTimeControl.updateMailState(ctx, ctx.args.workerId, myOptions);
|
||||||
return Self.sendTemplate(ctx, 'weekly-hour-record');
|
return Self.sendTemplate(ctx, 'weekly-hour-record');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,6 @@ class Controller extends Section {
|
||||||
|
|
||||||
updateWorkerTimeControlMail(state, reason) {
|
updateWorkerTimeControlMail(state, reason) {
|
||||||
const params = {
|
const params = {
|
||||||
workerId: this.worker.id,
|
|
||||||
year: this.date.getFullYear(),
|
year: this.date.getFullYear(),
|
||||||
week: this.weekNumber,
|
week: this.weekNumber,
|
||||||
state
|
state
|
||||||
|
@ -389,7 +388,7 @@ class Controller extends Section {
|
||||||
if (reason)
|
if (reason)
|
||||||
params.reason = reason;
|
params.reason = reason;
|
||||||
|
|
||||||
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
|
const query = `WorkerTimeControls/${this.worker.id}/updateMailState`;
|
||||||
this.$http.post(query, params).then(() => {
|
this.$http.post(query, params).then(() => {
|
||||||
this.getMailStates(this.date);
|
this.getMailStates(this.date);
|
||||||
this.getWeekData();
|
this.getWeekData();
|
||||||
|
|
|
@ -201,7 +201,7 @@ describe('Component vnWorkerTimeControl', () => {
|
||||||
controller.date = today;
|
controller.date = today;
|
||||||
controller.weekNumber = 1;
|
controller.weekNumber = 1;
|
||||||
|
|
||||||
$httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond();
|
$httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond();
|
||||||
controller.isSatisfied();
|
controller.isSatisfied();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ describe('Component vnWorkerTimeControl', () => {
|
||||||
controller.weekNumber = 1;
|
controller.weekNumber = 1;
|
||||||
controller.reason = 'reason';
|
controller.reason = 'reason';
|
||||||
|
|
||||||
$httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond();
|
$httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond();
|
||||||
controller.isSatisfied();
|
controller.isSatisfied();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue