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