diff --git a/back/methods/collection/assignCollection.js b/back/methods/collection/assignCollection.js
index 2ff37ab59..2a7ec9ad5 100644
--- a/back/methods/collection/assignCollection.js
+++ b/back/methods/collection/assignCollection.js
@@ -19,8 +19,15 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- const [info, info2, [{'@vCollectionFk': collectionFk}]] = await Self.rawSql(
- 'CALL vn.collection_getAssigned(?, @vCollectionFk);SELECT @vCollectionFk', [userId], myOptions);
+
+ const randStr = Math.random().toString(36).substring(3);
+ const result = await Self.rawSql(`
+ CALL vn.collection_getAssigned(?, @vCollectionFk);
+ SELECT @vCollectionFk ?
+ `, [userId, randStr], myOptions);
+
+ const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
+
if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js
index 8f1bb54c1..8941916ec 100644
--- a/back/methods/vn-user/specs/renew-token.spec.js
+++ b/back/methods/vn-user/specs/renew-token.spec.js
@@ -72,9 +72,9 @@ describe('Renew Token', () => {
}
expect(error).toBeDefined();
- const query = 'SELECT * FROM util.debug';
- const debugLog = await models.Application.rawSql(query, null);
+ const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"';
+ const debugLog = await models.Application.rawSql(query);
expect(debugLog.length).toEqual(1);
});
diff --git a/back/model-config.json b/back/model-config.json
index 20bfb06bd..b6d304675 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -175,6 +175,9 @@
"PrintConfig": {
"dataSource": "vn"
},
+ "QueueMember": {
+ "dataSource": "vn"
+ },
"ViaexpressConfig": {
"dataSource": "vn"
},
diff --git a/back/models/queue-member.json b/back/models/queue-member.json
new file mode 100644
index 000000000..93ca2ebd7
--- /dev/null
+++ b/back/models/queue-member.json
@@ -0,0 +1,38 @@
+{
+ "name": "QueueMember",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "pbx.queueMember"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "queue": {
+ "type": "string"
+ },
+ "extension": {
+ "type": "string"
+ }
+ },
+ "relations": {
+ "queueRelation": {
+ "type": "belongsTo",
+ "model": "Queue",
+ "foreignKey": "queue",
+ "primaryKey": "name"
+ }
+ },
+ "acls": [
+ {
+ "property": "*",
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "employee",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index d4bc13730..7f7e50dd3 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -546,7 +546,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
(6, 'Weight', 'weight'),
(7, 'InvoiceOut', 'invoiceOut'),
(8, 'DropOff', 'dropOff'),
- (9, 'Sustitución', 'substitution');
+ (9, 'Sustitución', 'substitution'),
+ (10, 'Finance', 'finance');
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
VALUES
@@ -3988,3 +3989,25 @@ VALUES
INSERT IGNORE INTO ormConfig
SET id =1,
selectLimit = 1000;
+
+INSERT INTO pbx.queueMultiConfig
+ SET id = 'ring',
+ strategy = 20,
+ timeout = 2,
+ retry = 0,
+ weight = 0,
+ maxLen = 0,
+ ringInUse = 0;
+
+INSERT INTO pbx.queue (description, name, config)
+ VALUES ('X-men', '1000', 1),
+ ('Avengers', '2000', 1);
+
+INSERT IGNORE INTO pbx.queueMember
+ SET queue = '1000',
+ extension = '1010';
+
+UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
+UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
+
+
diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql
index b383cd135..bbfa9432a 100644
--- a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql
+++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql
@@ -1,52 +1,52 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost`
-PROCEDURE `hedera`.`orderRow_updateOverstocking`(vOrderFk INT)
-BEGIN
-/**
-* Set amount = 0 to avoid overbooking sales
-*
-* @param vOrderFk hedera.order.id
-*/
- DECLARE vCalcFk INT;
- DECLARE vDone BOOL;
- DECLARE vWarehouseFk INT;
-
- DECLARE cWarehouses CURSOR FOR
- SELECT DISTINCT warehouseFk
- FROM orderRow
- WHERE orderFk = vOrderFk
- AND shipment = util.VN_CURDATE();
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- OPEN cWarehouses;
- checking: LOOP
- SET vDone = FALSE;
-
- FETCH cWarehouses INTO vWarehouseFk;
-
- IF vDone THEN
- LEAVE checking;
- END IF;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
-
- UPDATE orderRow r
- JOIN `order` o ON o.id = r.orderFk
- JOIN orderConfig oc
- JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
- SET r.amount = 0
- WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW()
- AND a.available <= 0
- AND r.warehouseFk = vWarehouseFk
- AND r.orderFk = vOrderFk;
- END LOOP;
- CLOSE cWarehouses;
-END$$
-DELIMITER ;
\ No newline at end of file
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
+PROCEDURE `hedera`.`orderRow_updateOverstocking`(vOrderFk INT)
+BEGIN
+/**
+* Set amount = 0 to avoid overbooking sales
+*
+* @param vOrderFk hedera.order.id
+*/
+ DECLARE vCalcFk INT;
+ DECLARE vDone BOOL;
+ DECLARE vWarehouseFk INT;
+
+ DECLARE cWarehouses CURSOR FOR
+ SELECT DISTINCT warehouseFk
+ FROM orderRow
+ WHERE orderFk = vOrderFk
+ AND shipment = util.VN_CURDATE();
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ OPEN cWarehouses;
+ checking: LOOP
+ SET vDone = FALSE;
+
+ FETCH cWarehouses INTO vWarehouseFk;
+
+ IF vDone THEN
+ LEAVE checking;
+ END IF;
+
+ CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
+
+ UPDATE orderRow r
+ JOIN `order` o ON o.id = r.orderFk
+ JOIN orderConfig oc
+ JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
+ SET r.amount = 0
+ WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW()
+ AND a.available <= 0
+ AND r.warehouseFk = vWarehouseFk
+ AND r.orderFk = vOrderFk;
+ END LOOP;
+ CLOSE cWarehouses;
+END$$
+DELIMITER ;
diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql
index 026f589e9..644d68a87 100644
--- a/db/routines/hedera/procedures/order_confirmWithUser.sql
+++ b/db/routines/hedera/procedures/order_confirmWithUser.sql
@@ -22,7 +22,6 @@ BEGIN
DECLARE vItemFk INT;
DECLARE vConcept VARCHAR(30);
DECLARE vAmount INT;
- DECLARE vAvailable INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vSaleFk INT;
DECLARE vRowFk INT;
@@ -32,7 +31,6 @@ BEGIN
DECLARE vClientFk INT;
DECLARE vCompanyFk INT;
DECLARE vAgencyModeFk INT;
- DECLARE vCalcFk INT;
DECLARE vIsTaxDataChecked BOOL;
DECLARE vDates CURSOR FOR
@@ -109,9 +107,9 @@ BEGIN
) INTO vHas0Amount;
IF vHas0Amount THEN
- CALL util.throw('Remove lines with quantity = 0 before confirming');
+ CALL util.throw('Hay líneas vacías. Por favor, elimínelas');
END IF;
-
+
START TRANSACTION;
CALL order_checkEditable(vSelf);
diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql
index af1a1479f..7196dce10 100644
--- a/db/routines/hedera/triggers/orderRow_afterInsert.sql
+++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql
@@ -1,10 +1,10 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert`
- AFTER INSERT ON `orderRow`
- FOR EACH ROW
-BEGIN
- UPDATE `order`
- SET rowUpdated = NOW()
- WHERE id = NEW.orderFk;
-END$$
-DELIMITER ;
\ No newline at end of file
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert`
+ AFTER INSERT ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ UPDATE `order`
+ SET rowUpdated = util.VN_NOW()
+ WHERE id = NEW.orderFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql
index 518e2dd7b..7151129bf 100644
--- a/db/routines/vn/procedures/collection_getAssigned.sql
+++ b/db/routines/vn/procedures/collection_getAssigned.sql
@@ -5,100 +5,139 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_getAssigne
)
BEGIN
/**
- * Comprueba si existen colecciones libres que se ajustan al perfil del usuario
- * y le asigna la más antigua.
- * Añade un registro al semillero de colecciones y hace la reserva para la colección
- *
+ * Comprueba si existen colecciones libres que se ajustan
+ * al perfil del usuario y le asigna la más antigua.
+ * Añade un registro al semillero de colecciones.
+ *
* @param vUserFk Id de usuario
* @param vCollectionFk Id de colección
*/
DECLARE vHasTooMuchCollections BOOL;
- DECLARE vItemPackingTypeFk VARCHAR(1);
- DECLARE vWarehouseFk INT;
- DECLARE vLockName VARCHAR(215);
- DECLARE vLockTime INT DEFAULT 30;
+ DECLARE vDone BOOL DEFAULT FALSE;
+ DECLARE vCollectionWorker INT;
+ DECLARE vMaxNotAssignedCollectionLifeTime TIME;
+
+ DECLARE vCollections CURSOR FOR
+ WITH collections AS (
+ SELECT tc.collectionFk,
+ SUM(sv.volume) volume,
+ c.saleTotalCount,
+ c.itemPackingTypeFk,
+ c.trainFk,
+ c.warehouseFk,
+ c.wagons
+ FROM vn.ticketCollection tc
+ JOIN vn.collection c ON c.id = tc.collectionFk
+ JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk
+ WHERE c.workerFk IS NULL
+ AND sv.shipped >= util.VN_CURDATE()
+ GROUP BY tc.collectionFk
+ ) SELECT c.collectionFk
+ FROM collections c
+ JOIN vn.operator o
+ WHERE o.workerFk = vUserFk
+ AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL)
+ AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL)
+ AND o.numberOfWagons = c.wagons
+ AND o.trainFk = c.trainFk
+ AND o.warehouseFk = c.warehouseFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ -- Si hay colecciones sin terminar, sale del proceso
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
- IF vLockName IS NOT NULL THEN
- DO RELEASE_LOCK(vLockName);
- END IF;
-
+ ROLLBACK;
RESIGNAL;
END;
- -- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk);
- SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
- pc.collection_assign_lockname
- INTO vHasTooMuchCollections,
- vLockName
- FROM tmp.collection c
- JOIN productionConfig pc;
+ SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime
+ INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime
+ FROM productionConfig pc
+ LEFT JOIN tmp.collection ON TRUE;
DROP TEMPORARY TABLE tmp.collection;
IF vHasTooMuchCollections THEN
- CALL util.throw('There are pending collections');
- END IF;
-
- SELECT warehouseFk, itemPackingTypeFk
- INTO vWarehouseFk, vItemPackingTypeFk
- FROM operator
- WHERE workerFk = vUserFk;
-
- SET vLockName = CONCAT_WS('/',
- vLockName,
- vWarehouseFk,
- vItemPackingTypeFk
- );
-
- IF NOT GET_LOCK(vLockName, vLockTime) THEN
- CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
+ CALL util.throw('Hay colecciones pendientes');
END IF;
-- Se eliminan las colecciones sin asignar que estan obsoletas
- INSERT INTO ticketTracking(stateFk, ticketFk)
- SELECT s.id, tc.ticketFk
- FROM collection c
- JOIN ticketCollection tc ON tc.collectionFk = c.id
- JOIN state s ON s.code = 'PRINTED_AUTO'
- JOIN productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
- DELETE c
- FROM collection c
- JOIN productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
+ INSERT INTO ticketTracking(stateFk, ticketFk)
+ SELECT s.id, tc.ticketFk
+ FROM `collection` c
+ JOIN ticketCollection tc ON tc.collectionFk = c.id
+ JOIN `state` s ON s.code = 'PRINTED_AUTO'
+ WHERE c.workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime;
+
+ DELETE FROM `collection`
+ WHERE workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime;
-- Se añade registro al semillero
- INSERT INTO collectionHotbed
- SET userFk = vUserFk;
+
+ INSERT INTO collectionHotbed(userFk) VALUES(vUserFk);
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
- SELECT MIN(c.id) INTO vCollectionFk
- FROM collection c
- JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk
- OR c.itemPackingTypeFk IS NULL)
- AND o.numberOfWagons = c.wagons
- AND o.trainFk = c.trainFk
- AND o.warehouseFk = c.warehouseFk
- AND c.workerFk IS NULL
- WHERE o.workerFk = vUserFk;
+
+ OPEN vCollections;
+ l: LOOP
+ SET vDone = FALSE;
+ FETCH vCollections INTO vCollectionFk;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
+
+ BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ SET vCollectionFk = NULL;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT workerFk INTO vCollectionWorker
+ FROM `collection`
+ WHERE id = vCollectionFk FOR UPDATE;
+
+ IF vCollectionWorker IS NULL THEN
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+
+ COMMIT;
+ LEAVE l;
+ END IF;
+
+ ROLLBACK;
+ END;
+ END LOOP;
+ CLOSE vCollections;
IF vCollectionFk IS NULL THEN
CALL collection_new(vUserFk, vCollectionFk);
+
+ START TRANSACTION;
+
+ SELECT workerFk INTO vCollectionWorker
+ FROM `collection`
+ WHERE id = vCollectionFk FOR UPDATE;
+
+ IF vCollectionWorker IS NULL THEN
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+ END IF;
+
+ COMMIT;
END IF;
-
- UPDATE collection
- SET workerFk = vUserFk
- WHERE id = vCollectionFk;
-
CALL itemShelvingSale_addByCollection(vCollectionFk);
-
- DO RELEASE_LOCK(vLockName);
END$$
DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql
index 6b7a794a9..fed7a3eb6 100644
--- a/db/routines/vn/procedures/collection_getTickets.sql
+++ b/db/routines/vn/procedures/collection_getTickets.sql
@@ -45,7 +45,7 @@ BEGIN
LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE t.id = vParamFk
AND t.shipped >= vYesterday
- UNION ALL
+ UNION
SELECT t.id ticketFk,
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
am.name agencyName,
@@ -66,7 +66,7 @@ BEGIN
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE tc.collectionFk = vParamFk
- UNION ALL
+ UNION
SELECT sg.ticketFk,
NULL `level`,
am.name agencyName,
@@ -83,6 +83,7 @@ BEGIN
LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN vn.client c ON c.id = t.clientFk
WHERE sc.id = vParamFk
- AND t.shipped >= vYesterday;
+ AND t.shipped >= vYesterday
+ GROUP BY ticketFk;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql
new file mode 100644
index 000000000..9b15e82d1
--- /dev/null
+++ b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql
@@ -0,0 +1,49 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_deleteAdded`(
+ vSelf INT(11)
+)
+proc: BEGIN
+/**
+ * Borra una reservea devolviendo la cantidad al itemShelving
+ *
+ * @param vSelf Identificador del itemShelvingSale
+ */
+ DECLARE vSaleFk INT;
+ DECLARE vHasSalesPicked BOOL;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT iss.saleFk INTO vSaleFk
+ FROM itemShelvingSale iss
+ JOIN sale s ON s.id = iss.saleFk
+ WHERE iss.id = vSelf AND s.isAdded
+ FOR UPDATE;
+
+ IF vSaleFk IS NULL THEN
+ CALL util.throw('The sale can not be deleted');
+ END IF;
+
+ SELECT COUNT(*) INTO vHasSalesPicked
+ FROM itemShelvingSale
+ WHERE saleFk = vSaleFk AND isPicked;
+
+ IF vHasSalesPicked THEN
+ CALL util.throw('A sale with picked sales cannot be deleted');
+ END IF;
+
+ UPDATE itemShelvingSale iss
+ JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
+ SET ish.available = ish.available + iss.quantity
+ WHERE iss.saleFk = vSaleFk;
+
+ DELETE FROM sale WHERE id = vSaleFk;
+
+ COMMIT;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql
new file mode 100644
index 000000000..5af44da4f
--- /dev/null
+++ b/db/routines/vn/procedures/queueMember_updateQueue.sql
@@ -0,0 +1,29 @@
+DELIMITER $$
+
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
+ vBusinessFk INT
+)
+BEGIN
+ /**
+ * Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
+ *
+ * @param vBusinessFk ID del negocio
+ */
+ DECLARE vNewQueue VARCHAR(10);
+ DECLARE vExtension VARCHAR(10);
+ DECLARE exit handler FOR SQLEXCEPTION
+
+ SELECT d.pbxQueue, s.extension
+ INTO vNewQueue, vExtension
+ FROM business b
+ JOIN department d ON d.id = b.departmentFk
+ JOIN pbx.sip s ON s.user_id = b.workerFk
+ WHERE b.id = vBusinessFk;
+
+ DELETE FROM pbx.queueMember
+ WHERE extension = vExtension COLLATE utf8_general_ci;
+
+ INSERT IGNORE INTO pbx.queueMember (queue, extension)
+ VALUES (vNewQueue, vExtension);
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/worker_updateBusiness.sql b/db/routines/vn/procedures/worker_updateBusiness.sql
index a160c417a..43edb0416 100644
--- a/db/routines/vn/procedures/worker_updateBusiness.sql
+++ b/db/routines/vn/procedures/worker_updateBusiness.sql
@@ -21,6 +21,8 @@ BEGIN
SET businessFk = vNewBusinessFk
WHERE id = vSelf;
+ CALL queueMember_updateQueue(vNewBusinessFk);
+
IF vOldBusinessFk IS NULL THEN
CALL account.account_enable(vSelf);
diff --git a/db/routines/vn/triggers/business_afterUpdate.sql b/db/routines/vn/triggers/business_afterUpdate.sql
index 888308b9a..11aeb88b6 100644
--- a/db/routines/vn/triggers/business_afterUpdate.sql
+++ b/db/routines/vn/triggers/business_afterUpdate.sql
@@ -3,10 +3,20 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
AFTER UPDATE ON `business`
FOR EACH ROW
BEGIN
+ DECLARE vIsActive BOOL;
+ DECLARE vExtension VARCHAR(10);
+
CALL worker_updateBusiness(NEW.workerFk);
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
CALL worker_updateBusiness(OLD.workerFk);
END IF;
+
+ IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
+ SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
+ IF vIsActive THEN
+ CALL queueMember_updateQueue(NEW.id);
+ END IF;
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql
index fabdf8efb..53f85de01 100644
--- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql
+++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql
@@ -9,5 +9,8 @@ BEGIN
SET NEW.userFk = account.myUser_getId();
END IF;
+ IF NEW.shelvingFk <> OLD.shelvingFk THEN
+ SET NEW.movingState = NULL;
+ END IF;
END$$
DELIMITER ;
diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql
new file mode 100644
index 000000000..f69e20611
--- /dev/null
+++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql
@@ -0,0 +1,3 @@
+ALTER TABLE vn.clientObservation DROP COLUMN IF EXISTS observationTypeFk;
+ALTER TABLE vn.clientObservation ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NULL;
+ALTER TABLE vn.clientObservation ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY IF NOT EXISTS (observationTypeFk) REFERENCES vn.observationType(id);
diff --git a/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql b/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql
new file mode 100644
index 000000000..983419111
--- /dev/null
+++ b/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql
@@ -0,0 +1,3 @@
+INSERT IGNORE INTO vn.observationType
+ SET description = 'Finance',
+ code = 'finance';
\ No newline at end of file
diff --git a/db/versions/11242-whiteAnthurium/00-firstScript.sql b/db/versions/11242-whiteAnthurium/00-firstScript.sql
new file mode 100644
index 000000000..43dccf374
--- /dev/null
+++ b/db/versions/11242-whiteAnthurium/00-firstScript.sql
@@ -0,0 +1,3 @@
+DELETE FROM salix.ACL
+ WHERE model = 'WorkerLog'
+ AND property = '*';
\ No newline at end of file
diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
new file mode 100644
index 000000000..801405e59
--- /dev/null
+++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
@@ -0,0 +1,3 @@
+UPDATE vn.sale
+ SET originalQuantity = quantity
+ WHERE originalQuantity IS NULL
diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql
new file mode 100644
index 000000000..e3e08e0aa
--- /dev/null
+++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';
\ No newline at end of file
diff --git a/db/versions/11284-turquoiseLaurel/00-firstScript.sql b/db/versions/11284-turquoiseLaurel/00-firstScript.sql
new file mode 100644
index 000000000..34762faf6
--- /dev/null
+++ b/db/versions/11284-turquoiseLaurel/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+ALTER TABLE vn.itemShelving ADD IF NOT EXISTS isMoving BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica que se ha marcado este registro para transferirlo a otro sector';
diff --git a/db/versions/11285-orangeErica/00-firstScript.sql b/db/versions/11285-orangeErica/00-firstScript.sql
new file mode 100644
index 000000000..c13571f3a
--- /dev/null
+++ b/db/versions/11285-orangeErica/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
+ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
diff --git a/db/versions/11287-azureRaphis/00-firstScript.sql b/db/versions/11287-azureRaphis/00-firstScript.sql
new file mode 100644
index 000000000..77d60eb40
--- /dev/null
+++ b/db/versions/11287-azureRaphis/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL
+ COMMENT 'Timestamp for last updated record in orderRow table';
\ No newline at end of file
diff --git a/db/versions/11288-purpleFern/00-firstScript.sql b/db/versions/11288-purpleFern/00-firstScript.sql
new file mode 100644
index 000000000..77d60eb40
--- /dev/null
+++ b/db/versions/11288-purpleFern/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL
+ COMMENT 'Timestamp for last updated record in orderRow table';
\ No newline at end of file
diff --git a/db/versions/11289-azureAralia/00-firstScript.sql b/db/versions/11289-azureAralia/00-firstScript.sql
new file mode 100644
index 000000000..ab091f53f
--- /dev/null
+++ b/db/versions/11289-azureAralia/00-firstScript.sql
@@ -0,0 +1,2 @@
+
+ALTER TABLE vn.sector ADD isOnReservationMode tinyint(1) DEFAULT FALSE NULL;
diff --git a/db/versions/11294-azureFern/00-firstScript.sql b/db/versions/11294-azureFern/00-firstScript.sql
new file mode 100644
index 000000000..2d6ed3a5b
--- /dev/null
+++ b/db/versions/11294-azureFern/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
+ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
\ No newline at end of file
diff --git a/db/versions/11295-brownLaurel/00-firstScript.sql b/db/versions/11295-brownLaurel/00-firstScript.sql
new file mode 100644
index 000000000..2d6ed3a5b
--- /dev/null
+++ b/db/versions/11295-brownLaurel/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
+ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
\ No newline at end of file
diff --git a/db/versions/11298-wheatIvy/00-closure.sql b/db/versions/11298-wheatIvy/00-closure.sql
new file mode 100644
index 000000000..7b33939cf
--- /dev/null
+++ b/db/versions/11298-wheatIvy/00-closure.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `vn`.`ticketConfig`
+ADD COLUMN `closureDaysAgo` int(11) NOT NULL DEFAULT 2 COMMENT 'Number of days to look back for ticket closure',
+ADD CONSTRAINT `closureDaysAgo_check` CHECK (`closureDaysAgo` > 0);
diff --git a/e2e/paths/02-client/08_add_notes.spec.js b/e2e/paths/02-client/08_add_notes.spec.js
deleted file mode 100644
index d0c483a11..000000000
--- a/e2e/paths/02-client/08_add_notes.spec.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import selectors from '../../helpers/selectors';
-import getBrowser from '../../helpers/puppeteer';
-
-describe('Client Add notes path', () => {
- let browser;
- let page;
- beforeAll(async() => {
- browser = await getBrowser();
- page = browser.page;
- await page.loginAndModule('employee', 'client');
- await page.accessToSearchResult('Bruce Banner');
- await page.accessToSection('client.card.note.index');
- });
-
- afterAll(async() => {
- await browser.close();
- });
-
- it(`should reach the notes index`, async() => {
- await page.waitForState('client.card.note.index');
- });
-
- it(`should click on the add note button`, async() => {
- await page.waitToClick(selectors.clientNotes.addNoteFloatButton);
- await page.waitForState('client.card.note.create');
- });
-
- it(`should create a note`, async() => {
- await page.waitForSelector(selectors.clientNotes.note);
- await page.type(`${selectors.clientNotes.note} textarea`, 'Meeting with Black Widow 21st 9am');
- await page.waitToClick(selectors.clientNotes.saveButton);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Data saved!');
- });
-
- it('should confirm the note was created', async() => {
- const result = await page.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');
-
- expect(result).toEqual('Meeting with Black Widow 21st 9am');
- });
-});
diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js
index 2bb3d6254..01f394bc8 100644
--- a/e2e/paths/02-client/21_defaulter.spec.js
+++ b/e2e/paths/02-client/21_defaulter.spec.js
@@ -28,12 +28,12 @@ describe('Client defaulter path', () => {
const salesPersonName =
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
- expect(clientName).toEqual('Bruce Banner');
- expect(salesPersonName).toEqual('developer');
+ expect(clientName).toEqual('Ororo Munroe');
+ expect(salesPersonName).toEqual('salesperson');
});
it('should first observation not changed', async() => {
- const expectedObservation = 'Meeting with Black Widow 21st 9am';
+ const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push';
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
expect(result).toContain(expectedObservation);
@@ -62,13 +62,4 @@ describe('Client defaulter path', () => {
await page.write(selectors.clientDefaulter.observation, 'My new observation');
await page.waitToClick(selectors.clientDefaulter.saveButton);
});
-
- it('should first observation changed', async() => {
- const message = await page.waitForSnackbar();
- await page.waitForSelector(selectors.clientDefaulter.firstObservation);
- const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
-
- expect(message.text).toContain('Observation saved!');
- expect(result).toContain('My new observation');
- });
});
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 796c945e8..9308fd4ec 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -381,5 +381,6 @@
"The entry does not have stickers": "La entrada no tiene etiquetas",
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
"No valid travel thermograph found": "No se encontró un termógrafo válido",
- "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea"
-}
+ "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
+ "type cannot be blank": "Se debe rellenar el tipo"
+}
\ No newline at end of file
diff --git a/modules/account/back/models/sip.json b/modules/account/back/models/sip.json
index f2e2221b5..dbcef3b9e 100644
--- a/modules/account/back/models/sip.json
+++ b/modules/account/back/models/sip.json
@@ -25,7 +25,12 @@
"type": "belongsTo",
"model": "VnUser",
"foreignKey": "user_id"
+ },
+ "queueMember": {
+ "type": "belongsTo",
+ "model": "QueueMember",
+ "foreignKey": "extension",
+ "primaryKey": "extension"
}
}
-}
-
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/client/back/models/client-observation.js b/modules/client/back/models/client-observation.js
index e34eedca9..d022a440a 100644
--- a/modules/client/back/models/client-observation.js
+++ b/modules/client/back/models/client-observation.js
@@ -1,8 +1,11 @@
module.exports = function(Self) {
- Self.validate('text', isEnabled, {message: 'Description cannot be blank'});
- function isEnabled(err) {
+ Self.validate('text', function(err) {
if (!this.text) err();
- }
+ }, {message: 'Description cannot be blank'});
+
+ Self.validate('observationTypeFk', function(err) {
+ if (!this.observationTypeFk) err();
+ }, {message: 'type cannot be blank'});
Self.observe('before save', function(ctx, next) {
ctx.instance.created = Date();
diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json
index b204ebeb4..86351862d 100644
--- a/modules/client/back/models/client-observation.json
+++ b/modules/client/back/models/client-observation.json
@@ -1,10 +1,10 @@
{
- "name": "ClientObservation",
+ "name": "ClientObservation",
"description": "Client notes",
"base": "VnModel",
- "mixins": {
- "Loggable": true
- },
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "clientObservation"
@@ -26,6 +26,10 @@
"created": {
"type": "date",
"description": "Creation date and time"
+ },
+ "observationTypeFk": {
+ "type": "number",
+ "description": "Type of observation"
}
},
"relations": {
@@ -44,14 +48,18 @@
"include": {
"relation": "worker",
"scope": {
- "fields": ["id"],
+ "fields": [
+ "id"
+ ],
"include": {
"relation": "user",
"scope": {
- "fields": ["nickname"]
+ "fields": [
+ "nickname"
+ ]
}
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/client/front/note/index/index.html b/modules/client/front/note/index/index.html
index 634a9c3ce..e69de29bb 100644
--- a/modules/client/front/note/index/index.html
+++ b/modules/client/front/note/index/index.html
@@ -1,31 +0,0 @@
-
-
-
-
-