diff --git a/back/methods/collection/assignCollection.js b/back/methods/collection/assignCollection.js
index 2ff37ab595..2a7ec9ad56 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 8f1bb54c10..8941916ec4 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/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index d475ef02fb..7f7e50dd33 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
diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql
index 6e4087ad8f..644d68a878 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,7 +107,7 @@ 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;
diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql
index 44499f225b..7196dce10f 100644
--- a/db/routines/hedera/triggers/orderRow_afterInsert.sql
+++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql
@@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterIns
FOR EACH ROW
BEGIN
UPDATE `order`
- SET rowUpdated = NOW()
+ 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 518e2dd7be..7151129bf7 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/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql
new file mode 100644
index 0000000000..f69e206111
--- /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 0000000000..983419111e
--- /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/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
index 6ec0a66bb3..801405e59c 100644
--- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql
+++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
@@ -1,5 +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
index c942e04000..e3e08e0aa2 100644
--- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql
+++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql
@@ -1 +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
+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/11288-purpleFern/00-firstScript.sql b/db/versions/11288-purpleFern/00-firstScript.sql
new file mode 100644
index 0000000000..77d60eb40e
--- /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 0000000000..ab091f53fe
--- /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/11295-brownLaurel/00-firstScript.sql b/db/versions/11295-brownLaurel/00-firstScript.sql
new file mode 100644
index 0000000000..2d6ed3a5b8
--- /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 0000000000..7b33939cfa
--- /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 d0c483a114..0000000000
--- 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 2bb3d62546..01f394bc80 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 796c945e85..9308fd4ec7 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/client/back/models/client-observation.js b/modules/client/back/models/client-observation.js
index e34eedca9a..d022a440a8 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 b204ebeb4a..86351862d3 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 634a9c3ce7..e69de29bb2 100644
--- a/modules/client/front/note/index/index.html
+++ b/modules/client/front/note/index/index.html
@@ -1,31 +0,0 @@
-
-
-
-
-