diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js
index a9e5f2e60..f3575672f 100644
--- a/back/methods/collection/getSales.js
+++ b/back/methods/collection/getSales.js
@@ -29,10 +29,8 @@ module.exports = Self => {
});
Self.getSales = async(ctx, collectionOrTicketFk, print, source, options) => {
- const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
- const $t = ctx.req.__;
if (typeof options == 'object')
Object.assign(myOptions, options);
@@ -59,22 +57,6 @@ module.exports = Self => {
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
- for (let ticket of tickets) {
- if (ticket.observaciones) {
- let observations = ticket.observaciones.split(' ');
-
- for (let observation of observations) {
- const salesPerson = ticket.salesPersonFk;
- if (observation.startsWith('#') || observation.startsWith('@')) {
- await models.Chat.send(ctx,
- observation,
- $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
- );
- }
- }
- }
- }
-
return getCollection(id, tickets, sales, placements, myOptions);
};
diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js
index 4592a0797..89131491d 100644
--- a/back/methods/workerActivity/add.js
+++ b/back/methods/workerActivity/add.js
@@ -31,7 +31,7 @@ module.exports = Self => {
return await Self.rawSql(`
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
SELECT ?, ?, ?
- FROM workerTimeControlParams wtcp
+ FROM workerTimeControlConfig wtcc
LEFT JOIN (
SELECT wa.workerFk,
wa.created,
@@ -44,7 +44,7 @@ module.exports = Self => {
) sub ON TRUE
WHERE sub.workerFk IS NULL
OR sub.code <> ?
- OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
+ OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;`
, [userId, code, model, userId, code], myOptions);
};
};
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index eb376b6c6..ea7ba3767 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -1505,18 +1505,18 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
-INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`)
- VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL),
- (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL),
- (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL),
- (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL),
- (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL),
- (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL),
- (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2),
- (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL),
- (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2),
- (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL),
- (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL);
+INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `daysInForward`)
+ VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, FALSE, NULL),
+ (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, NULL),
+ (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, NULL),
+ (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, FALSE, NULL),
+ (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, FALSE, NULL),
+ (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, FALSE,NULL),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, TRUE, 2),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL),
+ (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
+ (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
+ (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`)
VALUES
@@ -2521,10 +2521,6 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`)
(2, 'Normal', 'normal'),
(3, 'Baja', 'low');
-INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
- VALUES
- (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
-
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
INSERT INTO `vn`.`thermograph`(`id`, `model`)
@@ -4008,10 +4004,17 @@ INSERT IGNORE INTO pbx.queueMember
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
-INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
+INSERT INTO vn.workerRelatives (workerFk, isDescendant, disabilityGradeFk, birthed, adoptionYear, isDependend, isJointCustody, updated)
+ VALUES
+ (1106, 1, NULL, 0, NULL, 0, 0, '2024-10-29 08:42:44.000');
+INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pintar traje', 50.00, 0);
+INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1);
+
+
+INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
(1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
- (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
(3, 1400, 0, 450, 13000, 1, 0, 1, '01B', 1, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
(4, 0, 500, 500, 13000, 1, 4, 1, '02A', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
(5, 1400, 500, 500, 13000, 1, 4, 1, '02B', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
@@ -4022,9 +4025,11 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c
(10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
-INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
+INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
VALUES (19, '1169'),
(8, '1183');
-INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
- VALUES ('saysimle-url-mock', 1320);
\ No newline at end of file
+INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
+ VALUES ('saysimle-url-mock', 1320);INSERT INTO vn.workerIrpf (workerFk,spouseNif,geographicMobilityDate)
+ VALUES
+ (1106,'26493101E','2019-09-20');
diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql
index efbbf6a13..447300305 100644
--- a/db/routines/cache/procedures/availableNoRaids_refresh.sql
+++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql
@@ -53,7 +53,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
AND s.name != 'INVENTARIO'
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY b.itemFk
) c
JOIN vn.item i ON i.id = c.itemFk
diff --git a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
index 28a8c9466..f3e5aaefd 100644
--- a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
+++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
@@ -14,7 +14,7 @@ BEGIN
b.stickers = NEW.NumberOfUnits
WHERE i.supplyResponseFk = NEW.ID
AND am.name = 'LOGIFLORA'
- AND tr.daysInForward
+ AND tr.isRaid
AND tr.landed >= util.VN_CURDATE();
END$$
diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql
index 365161bdf..d5bbe9d76 100644
--- a/db/routines/hedera/procedures/item_getVisible.sql
+++ b/db/routines/hedera/procedures/item_getVisible.sql
@@ -59,7 +59,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDateInv AND vDate
AND t.warehouseInFk = vWarehouse
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, -b.quantity
FROM vn.buy b
@@ -67,7 +67,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseOutFk = vWarehouse
- AND NOT t.daysInForward
+ AND NOT t.isRaid
AND t.isDelivered
UNION ALL
SELECT m.itemFk, -m.quantity
diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql
index d8e727f17..874e14072 100644
--- a/db/routines/stock/procedures/log_refreshBuy.sql
+++ b/db/routines/stock/procedures/log_refreshBuy.sql
@@ -6,12 +6,11 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tValues;
CREATE TEMPORARY TABLE tValues
ENGINE = MEMORY
- SELECT
- b.id buyFk,
+ SELECT b.id buyFk,
e.id entryFk,
t.id travelFk,
b.itemFk,
- t.daysInForward,
+ t.isRaid,
ADDTIME(t.shipped,
IFNULL(t.shipmentHour, '00:00:00')) shipped,
t.warehouseOutFk,
@@ -50,7 +49,7 @@ BEGIN
itemFk,
TIMESTAMPADD(DAY, life, @dated),
quantity,
- IF(isIn, isReceived, isDelivered) AND NOT daysInForward
+ IF(isIn, isReceived, isDelivered) AND NOT isRaid
FROM tValues
WHERE isIn OR !lessThanInventory;
@@ -65,7 +64,7 @@ BEGIN
itemFk,
created,
quantity,
- IF(isIn, isDelivered, isReceived) AND NOT daysInForward
+ IF(isIn, isDelivered, isReceived) AND NOT isRaid
FROM tValues
WHERE !isIn OR !lessThanInventory;
diff --git a/db/routines/vn/functions/timeWorkerControl_getDirection.sql b/db/routines/vn/functions/timeWorkerControl_getDirection.sql
deleted file mode 100644
index c0f1e67ea..000000000
--- a/db/routines/vn/functions/timeWorkerControl_getDirection.sql
+++ /dev/null
@@ -1,65 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME)
- RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
- NOT DETERMINISTIC
- READS SQL DATA
-BEGIN
-/**
- * Verifica la dirección de la fichada
- * @param vUserFk Identificador del trabajador
- * @param vTimed Hora de la fichada
- * @return Retorna sentido de la fichada 'in, out, middle'
- */
-
- DECLARE vPrevious DATETIME ;
- DECLARE vNext DATETIME ;
- DECLARE vPreviousDirection VARCHAR(3) ;
- DECLARE vNextDirection VARCHAR(3) ;
- DECLARE vDayStayMax INT;
- DECLARE vTimedSeconds INT;
- DECLARE vLastTimeIn INT;
-
- SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM vn.workerTimeControlParams;
-
- SELECT timed, direction INTO vNext,vNextDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed > vTimed
- ORDER BY timed ASC
- LIMIT 1;
-
- SELECT timed, direction INTO vPrevious, vPreviousDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed < vTimed
- ORDER BY timed DESC
- LIMIT 1;
-
- IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN
- RETURN 'middle';
- END IF;
-
-
- IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN
- IF vPreviousDirection = 'in' THEN
- RETURN 'out';
- ELSE
- SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction ='in'
- AND timed < vPrevious;
- IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN
- RETURN 'out';
- END IF;
- END IF;
- END IF;
-
- RETURN 'in';
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql
index 3ea8cf4de..d0d9ffac2 100644
--- a/db/routines/vn/procedures/absoluteInventoryHistory.sql
+++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql
@@ -39,7 +39,7 @@ BEGIN
AND vWarehouseFk IN (tr.warehouseInFk, 0)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
UNION ALL
SELECT tr.shipped,
NULL,
@@ -58,7 +58,7 @@ BEGIN
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
UNION ALL
SELECT t.shipped,
NULL,
diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql
index 513f58e36..bfd5b34c8 100644
--- a/db/routines/vn/procedures/available_traslate.sql
+++ b/db/routines/vn/procedures/available_traslate.sql
@@ -42,7 +42,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
AND t.warehouseInFk = vWarehouseLanding
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY c.itemFk;
-- Tabla con el ultimo dia de last_buy para cada producto
@@ -57,7 +57,7 @@ proc: BEGIN
JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
WHERE t.warehouseFk = vWarehouseShipment
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
tr.landed);
@@ -94,7 +94,7 @@ proc: BEGIN
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
WHERE NOT e.isExcludedFromAvailable
AND b.quantity <> 0
- AND NOT t.daysInForward
+ AND NOT t.isRaid
AND t.warehouseInFk = vWarehouseLanding
AND t.landed >= vDatedFrom
AND (ir.dated IS NULL OR t.landed <= ir.dated)
diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql
index 9527e0bf2..873827db2 100644
--- a/db/routines/vn/procedures/entry_getTransfer.sql
+++ b/db/routines/vn/procedures/entry_getTransfer.sql
@@ -166,7 +166,7 @@ BEGIN
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND (ti.visible OR ti.available)
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql
index 65dceef3d..316083db0 100644
--- a/db/routines/vn/procedures/inventoryMake.sql
+++ b/db/routines/vn/procedures/inventoryMake.sql
@@ -137,7 +137,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWarehouseFk
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
GROUP BY b.itemFk;
-- Transfers
@@ -150,7 +150,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWarehouseFk
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
GROUP BY b.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
index f141762b5..1975180d1 100644
--- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
+++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
@@ -48,7 +48,7 @@ BEGIN
iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)),
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
- ish.shelvingFk
+ sh.code
INTO vItemFk,
vSaleFk,
vItemShelvingFk,
@@ -58,7 +58,8 @@ BEGIN
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
- LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked;
diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql
index 93022c2af..7e59a5cfc 100644
--- a/db/routines/vn/procedures/itemShelving_get.sql
+++ b/db/routines/vn/procedures/itemShelving_get.sql
@@ -21,7 +21,8 @@ BEGIN
ish.isChecked,
ic.url,
ish.available,
- ish.buyFk
+ ish.buyFk,
+ sh.shelvingFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON s.id = ish.shelvingFk
diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql
index 260f0a527..c4974491c 100644
--- a/db/routines/vn/procedures/item_getBalance.sql
+++ b/db/routines/vn/procedures/item_getBalance.sql
@@ -59,7 +59,7 @@ BEGIN
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
),
entriesOut AS (
SELECT 'entry',
@@ -95,7 +95,7 @@ BEGIN
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT w.isFeedStock
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
),
sales AS (
WITH itemSales AS (
diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql
index 8a42bd737..e3c915820 100644
--- a/db/routines/vn/procedures/item_getMinacum.sql
+++ b/db/routines/vn/procedures/item_getMinacum.sql
@@ -63,7 +63,7 @@ BEGIN
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT r.itemFk,
r.shipment,
diff --git a/db/routines/vn/procedures/item_multipleBuyByDate.sql b/db/routines/vn/procedures/item_multipleBuyByDate.sql
index 7bd809312..04d3f1855 100644
--- a/db/routines/vn/procedures/item_multipleBuyByDate.sql
+++ b/db/routines/vn/procedures/item_multipleBuyByDate.sql
@@ -30,7 +30,7 @@ BEGIN
AND NOT s.name = 'INVENTARIO'
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND w.isComparative
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY i.id;
UPDATE tmp.itemInventory y
diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql
index b6d687960..7e420be27 100644
--- a/db/routines/vn/procedures/item_valuateInventory.sql
+++ b/db/routines/vn/procedures/item_valuateInventory.sql
@@ -109,7 +109,7 @@ BEGIN
JOIN warehouse w ON w.id = tr.warehouseInFk
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND e.supplierFk <> vInventorySupplierFk
@@ -131,7 +131,7 @@ BEGIN
JOIN itemCategory ic ON ic.id = t.categoryFk
JOIN warehouse w ON w.id = tr.warehouseOutFk
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
@@ -196,7 +196,7 @@ BEGIN
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
WHERE vDated >= tr.shipped AND vDated < tr.landed
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND wIn.valuatedInventory
AND t.isInventory
AND e.isConfirmed
diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql
index 6b26e456f..ee18bbe96 100644
--- a/db/routines/vn/procedures/multipleInventory.sql
+++ b/db/routines/vn/procedures/multipleInventory.sql
@@ -60,7 +60,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, - b.quantity
FROM buy b
@@ -71,7 +71,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
) sub
GROUP BY itemFk;
@@ -121,7 +121,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, t.shipped, - b.quantity
FROM buy b
@@ -132,7 +132,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
) sub
GROUP BY sub.itemFk, sub.dated;
diff --git a/db/routines/vn/procedures/travelVolume_get.sql b/db/routines/vn/procedures/travelVolume_get.sql
index bb98cacdf..ab24a6395 100644
--- a/db/routines/vn/procedures/travelVolume_get.sql
+++ b/db/routines/vn/procedures/travelVolume_get.sql
@@ -10,7 +10,7 @@ BEGIN
JOIN vn.entry e ON e.travelFk = tr.id
JOIN vn.buy b ON b.entryFk = e.id
WHERE tr.landed BETWEEN vFromDated AND vToDated
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND tr.warehouseInFk = vWarehouseFk
GROUP BY tr.landed , a.name ;
END$$
diff --git a/db/routines/vn/procedures/travel_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql
new file mode 100644
index 000000000..64f3355e2
--- /dev/null
+++ b/db/routines/vn/procedures/travel_checkRaid.sql
@@ -0,0 +1,17 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`(
+ vIsRaid BOOL,
+ vDaysInForward INT
+)
+BEGIN
+/**
+ * Check if the values of isRaid and daysInforward are correct
+ *
+ * @param vIsRaid idRaid value
+ * @param vDaysInForward daysInForward value
+ */
+ IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
+ CALL util.throw('The raid information is not correct');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql
index aa554a1a0..cf0fce23c 100644
--- a/db/routines/vn/procedures/travel_moveRaids.sql
+++ b/db/routines/vn/procedures/travel_moveRaids.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
BEGIN
/**
* Desplaza los travels en el futuro y avisa a los compradores
- *
+ *
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vBuyerEmail VARCHAR(40);
@@ -11,21 +11,21 @@ BEGIN
DECLARE vMailBody TEXT DEFAULT '';
DECLARE vCur CURSOR FOR
- SELECT GROUP_CONCAT(DISTINCT
- CONCAT('https://salix.verdnatura.es/#!/travel/',
- ttm.travelFk,
+ SELECT GROUP_CONCAT(DISTINCT
+ CONCAT('https://salix.verdnatura.es/#!/travel/',
+ ttm.travelFk,
'/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 entry e ON e.travelFk = ttm.travelFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN account.user u ON u.id = it.workerFk
GROUP BY u.name;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@@ -34,10 +34,11 @@ BEGIN
END;
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
- SELECT id travelFk,
+ SELECT id travelFk,
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
FROM travel
- WHERE daysInForward;
+ WHERE isRaid
+ AND daysInForward;
START TRANSACTION;
diff --git a/db/routines/vn/procedures/workerTimeControl_check.sql b/db/routines/vn/procedures/workerTimeControl_check.sql
deleted file mode 100644
index 30cf5c639..000000000
--- a/db/routines/vn/procedures/workerTimeControl_check.sql
+++ /dev/null
@@ -1,168 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
-proc: BEGIN
-/**
- * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd
- *
- * @param vUserFk Identificador del trabajador
- * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
- * En caso de tener algun problema retorna el primero que encuentra
- */
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
- DECLARE vWeekScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vProblem VARCHAR(20) DEFAULT NULL;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
- INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'out';
-
- SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
- FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
- SELECT CONCAT(firstName,' ',lastName) INTO vUserName
- FROM worker w
- WHERE w.id = vUserFk;
-
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- SELECT "Descansos 12 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ) THEN
- SELECT "Dias con fichadas impares" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR VACACIONES
- SELECT at2.name INTO vCalendarStateType
- FROM calendar c
- JOIN business b ON b.id = c.businessFk
- JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
- WHERE c.dated = util.VN_CURDATE()
- AND at2.isAllowedToWork = FALSE
- AND b.workerFk = vUserFk
- LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
- SELECT vCalendarStateType AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
- FROM business b
- WHERE b.workerFk = vUserFk
- AND b.started <= vDated
- AND IFNULL(b.ended, vDated) >= vDated
- ) = 0 THEN
- SELECT "No hay un contrato en vigor" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR DESCANSO SEMANAL
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
-
- DROP TEMPORARY TABLE IF EXISTS tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
- AND userFk= vUserFk
- AND direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- SELECT "Descansos 36 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
-
- -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ORDER BY timed;
-
- IF vTimedWorked > vDayWorkMax THEN
- SELECT "Jornadas" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- END IF;
-
- -- VERIFICAR DEPARTAMENTO
- /* IF vTabletFk IS NOT NULL THEN
- SELECT wtcu.departmentFk INTO vDepartmentFk
- FROM workerTimeControlUserInfo wtcu
- WHERE wtcu.userFk = vUserFk;
- IF (SELECT COUNT(td.tabletFk)
- FROM tabletDepartment td
- WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
- ) = 0 THEN
- SELECT "No perteneces a este departamento." AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
- END IF;*/
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql
index 3b999012f..1d0c26fc1 100644
--- a/db/routines/vn/triggers/entry_beforeUpdate.sql
+++ b/db/routines/vn/triggers/entry_beforeUpdate.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
BEFORE UPDATE ON `entry`
FOR EACH ROW
BEGIN
- DECLARE vDaysInForward INT;
+ DECLARE vIsRaid BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vTotalBuy INT;
@@ -38,7 +38,7 @@ BEGIN
CALL travel_throwAwb(NEW.travelFk);
END IF;
- SELECT daysInForward INTO vDaysInForward
+ SELECT isRaid INTO vIsRaid
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE entryFk = NEW.id;
@@ -50,7 +50,7 @@ BEGIN
WHERE o.id = OLD.travelFk
AND n.id = NEW.travelFk;
- IF vDaysInForward AND vHasDistinctWarehouses THEN
+ IF vIsRaid AND vHasDistinctWarehouses THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
END IF;
diff --git a/db/routines/vn/triggers/route_afterUpdate.sql b/db/routines/vn/triggers/route_afterUpdate.sql
index ec205090e..447608acc 100644
--- a/db/routines/vn/triggers/route_afterUpdate.sql
+++ b/db/routines/vn/triggers/route_afterUpdate.sql
@@ -2,18 +2,18 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate`
AFTER UPDATE ON `route`
FOR EACH ROW
-BEGIN
+BEGIN
IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
-- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
-
+
-- Inserta el gestdoc en todos los tickets de la ruta
INSERT INTO ticketDms(ticketFk,dmsFk)
SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
- -- Update del firmado
- UPDATE ticket t
- JOIN ticketDms tg ON t.id = tg.ticketFk
+ -- Update del firmado
+ UPDATE ticket t
+ JOIN ticketDms tg ON t.id = tg.ticketFk
SET isSigned = 1 WHERE t.routeFk = NEW.id;
END IF;
@@ -21,7 +21,8 @@ BEGIN
OR !(NEW.kmEnd <=> OLD.kmEnd)
OR !(NEW.workerFk <=> OLD.workerFk)
OR !(NEW.m3 <=> OLD.m3)
- OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN
+ OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
+ OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
CALL route_calcCommission(NEW.id);
END IF;
diff --git a/db/routines/vn/triggers/town_beforeUpdate.sql b/db/routines/vn/triggers/town_beforeUpdate.sql
deleted file mode 100644
index fc1410d5c..000000000
--- a/db/routines/vn/triggers/town_beforeUpdate.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeUpdate`
- BEFORE UPDATE ON `town`
- FOR EACH ROW
-BEGIN
- -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
- -- CALL zoneGeo_throwNotEditable;
- -- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql
index 4563c9a81..5356ed537 100644
--- a/db/routines/vn/triggers/travel_beforeInsert.sql
+++ b/db/routines/vn/triggers/travel_beforeInsert.sql
@@ -8,7 +8,11 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
-
+
+ IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
+ CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
+ END IF;
+
IF NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 33578fea1..5a27b43b4 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -7,7 +7,7 @@ BEGIN
SET NEW.editorFk = account.myUser_getId();
- IF NOT (NEW.landed <=> OLD.landed)
+ IF NOT (NEW.landed <=> OLD.landed)
OR NOT (NEW.shipped <=> OLD.shipped) THEN
CALL travel_checkDates(NEW.shipped, NEW.landed);
END IF;
@@ -20,19 +20,23 @@ BEGIN
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END IF;
+ IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN
+ CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
+ END IF;
+
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
- SELECT COUNT(*) INTO vHasAnyInvoiceBooked
+ SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM travel t
- JOIN entry e ON e.travelFk = t.id
- JOIN invoiceIn ii ON ii.id = e.invoiceInFk
+ JOIN entry e ON e.travelFk = t.id
+ JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE t.id = NEW.id
- AND ii.isBooked;
-
+ AND ii.isBooked;
+
IF vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices');
END IF;
- END IF;
-
+ END IF;
+
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql
index 6196e9396..60af585f2 100644
--- a/db/routines/vn/views/itemEntryIn.sql
+++ b/db/routines/vn/views/itemEntryIn.sql
@@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
`b`.`itemFk` AS `itemFk`,
`b`.`quantity` AS `quantity`,
`t`.`isReceived` AS `isReceived`,
- `t`.`daysInForward` AS `isVirtualStock`,
+ `t`.`isRaid` AS `isVirtualStock`,
`e`.`id` AS `entryFk`
FROM (
(
diff --git a/db/routines/vn/views/itemEntryOut.sql b/db/routines/vn/views/itemEntryOut.sql
index f18116e61..4793ddbb8 100644
--- a/db/routines/vn/views/itemEntryOut.sql
+++ b/db/routines/vn/views/itemEntryOut.sql
@@ -15,5 +15,5 @@ FROM (
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
)
WHERE `e`.`isExcludedFromAvailable` = 0
- AND NOT `t`.`daysInForward`
+ AND NOT `t`.`isRaid`
AND `b`.`quantity` <> 0
diff --git a/db/routines/vn/views/lastPurchases.sql b/db/routines/vn/views/lastPurchases.sql
index 9dc5ec898..3dcaf8c1d 100644
--- a/db/routines/vn/views/lastPurchases.sql
+++ b/db/routines/vn/views/lastPurchases.sql
@@ -31,5 +31,5 @@ FROM (
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
)
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
- AND NOT `tr`.`daysInForward`
+ AND NOT `tr`.`isRaid`
AND `b`.`stickers` > 0
diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql
index 9c0c0f6ed..732603617 100644
--- a/db/routines/vn2008/views/entrySource.sql
+++ b/db/routines/vn2008/views/entrySource.sql
@@ -8,6 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
`e`.`isExcludedFromAvailable` AS `Inventario`,
`e`.`isConfirmed` AS `Confirmada`,
`e`.`isOrdered` AS `Pedida`,
+ `tr`.`isRaid` AS `isRaid`,
`tr`.`daysInForward` AS `daysInForward`,
`e`.`evaNotes` AS `notas`,
`e`.`supplierFk` AS `Id_Proveedor`,
diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql
index 0e1f5acb2..38dfd40ea 100644
--- a/db/routines/vn2008/views/travel.sql
+++ b/db/routines/vn2008/views/travel.sql
@@ -18,5 +18,6 @@ AS SELECT `t`.`id` AS `id`,
`t`.`totalEntries` AS `totalEntries`,
`t`.`appointment` AS `appointment`,
`t`.`awbFk` AS `awbFk`,
+ `t`.`isRaid` AS `isRaid`,
`t`.`daysInForward` AS `daysInForward`
FROM `vn`.`travel` `t`
diff --git a/db/routines/vn2008/views/v_compres.sql b/db/routines/vn2008/views/v_compres.sql
index 324e459f6..633feb471 100644
--- a/db/routines/vn2008/views/v_compres.sql
+++ b/db/routines/vn2008/views/v_compres.sql
@@ -86,4 +86,4 @@ FROM (
)
WHERE NOT `W_IN`.`isFeedStock`
AND NOT `E`.`Inventario`
- AND NOT `TR`.`daysInForward`
+ AND NOT `TR`.`isRaid`
diff --git a/db/versions/11312-navyAralia/00-firstScript.sql b/db/versions/11312-navyAralia/00-firstScript.sql
new file mode 100644
index 000000000..452b1feed
--- /dev/null
+++ b/db/versions/11312-navyAralia/00-firstScript.sql
@@ -0,0 +1,23 @@
+ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk;
+ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk;
+
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
+ VALUES
+ ('WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','crud','WRITE','ALLOW','ROLE','hr'),
+ ('WorkerRelative','findById','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','find','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','upsert','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','filter','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','crud','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','findById','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','find','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','upsert','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','filter','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','crud','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','findById','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','find','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','upsert','*','ALLOW','ROLE','hr');
+
diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql
new file mode 100644
index 000000000..6358695b2
--- /dev/null
+++ b/db/versions/11332-tealErica/00-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
+
+ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
+ COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';
diff --git a/db/versions/11341-pinkSalal/00-firstScript.sql b/db/versions/11341-pinkSalal/00-firstScript.sql
new file mode 100644
index 000000000..2c9e912d9
--- /dev/null
+++ b/db/versions/11341-pinkSalal/00-firstScript.sql
@@ -0,0 +1,5 @@
+
+ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
+
+ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
+ COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';
diff --git a/db/versions/11353-wheatCymbidium/00-firstScript.sql b/db/versions/11353-wheatCymbidium/00-firstScript.sql
new file mode 100644
index 000000000..557ffab9e
--- /dev/null
+++ b/db/versions/11353-wheatCymbidium/00-firstScript.sql
@@ -0,0 +1,15 @@
+
+
+USE vn;
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteAction', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'create', 'WRITE', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'delivery');
\ No newline at end of file
diff --git a/db/versions/11354-aquaMastic/00-firstScript.sql b/db/versions/11354-aquaMastic/00-firstScript.sql
new file mode 100644
index 000000000..dda3f4752
--- /dev/null
+++ b/db/versions/11354-aquaMastic/00-firstScript.sql
@@ -0,0 +1,2 @@
+RENAME TABLE vn.workerTimeControlParams TO vn.workerTimeControlParams__;
+ALTER TABLE vn.workerTimeControlParams__ COMMENT='@deprecated 2024-11-19';
\ No newline at end of file
diff --git a/db/versions/11355-pinkMedeola/00-firstScript.sql b/db/versions/11355-pinkMedeola/00-firstScript.sql
new file mode 100644
index 000000000..fc89b386c
--- /dev/null
+++ b/db/versions/11355-pinkMedeola/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
+ VALUES ('https://verdnatura.saysimple.io/start-conversation', 1320);
\ No newline at end of file
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index 86ebebc89..e8565d42e 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -223,7 +223,6 @@
"Shelving not valid": "Shelving not valid",
"printerNotExists": "The printer does not exist",
"There are not picking tickets": "There are not picking tickets",
- "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
"They're not your subordinate": "They're not your subordinate",
"InvoiceIn is already booked": "InvoiceIn is already booked",
@@ -245,6 +244,7 @@
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first",
"ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
"Payment method is required": "Payment method is required",
+ "The raid information is not correct": "The raid information is not correct",
"Sales already moved": "Sales already moved"
}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 8bf9f31c4..0ec3f6e2e 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -359,7 +359,6 @@
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
"Select ticket or client": "Elija un ticket o un client",
"It was not able to create the invoice": "No se pudo crear la factura",
- "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
"Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
"You can not use the same password": "No puedes usar la misma contraseña",
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
@@ -388,5 +387,7 @@
"There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
"The web user's email already exists": "El correo del usuario web ya existe",
- "Sales already moved": "Ya han sido transferidas"
+ "Sales already moved": "Ya han sido transferidas",
+ "The raid information is not correct": "La información de la redada no es correcta"
}
+
diff --git a/modules/entry/back/locale/entry/en.yml b/modules/entry/back/locale/entry/en.yml
index ab8c0fd1c..6bc2333e6 100644
--- a/modules/entry/back/locale/entry/en.yml
+++ b/modules/entry/back/locale/entry/en.yml
@@ -9,6 +9,7 @@ columns:
notes: notes
isConfirmed: confirmed
isVirtual: virtual
+ isRaid: raid
commission: commission
isOrdered: price3
created: created
diff --git a/modules/entry/back/locale/entry/es.yml b/modules/entry/back/locale/entry/es.yml
index 18bf1ca33..a892b05d2 100644
--- a/modules/entry/back/locale/entry/es.yml
+++ b/modules/entry/back/locale/entry/es.yml
@@ -9,6 +9,7 @@ columns:
notes: notas
isConfirmed: confirmado
isVirtual: virtual
+ isRaid: redada
commission: comisión
isOrdered: pedida
created: creado
diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js
index a5c236fe4..d7740dd4e 100644
--- a/modules/entry/back/methods/entry/filter.js
+++ b/modules/entry/back/methods/entry/filter.js
@@ -194,6 +194,7 @@ module.exports = Self => {
e.evaNotes observation,
e.isConfirmed,
e.isOrdered,
+ t.isRaid,
t.daysInForward,
e.commission,
e.created,
diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js
index 4612de9a5..92be9a9dd 100644
--- a/modules/entry/back/methods/entry/getEntry.js
+++ b/modules/entry/back/methods/entry/getEntry.js
@@ -49,8 +49,8 @@ module.exports = Self => {
'isReceived',
'isDelivered',
'ref',
- 'daysInForward',
- ],
+ 'isRaid',
+ 'daysInForward'],
include: [
{
relation: 'agency',
diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html
index 40625a4d5..957bcafb5 100644
--- a/modules/entry/front/descriptor/index.html
+++ b/modules/entry/front/descriptor/index.html
@@ -30,7 +30,7 @@