diff --git a/CHANGELOG.md b/CHANGELOG.md
index 708ebbc4b..fa2ebcd62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,13 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2326.01] - 2023-06-29
### Added
+- (Entradas -> Correo) Al cambiar el tipo de cambio enviará un correo a las personas designadas
### Changed
### Fixed
-
-## [2324.01] - 2023-06-08
+## [2324.01] - 2023-06-15
### Added
- (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén
diff --git a/README.md b/README.md
index f73a8551b..59f5dbcf7 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Salix is also the scientific name of a beautifull tree! :)
Required applications.
-* Node.js = 14.x LTS
+* Node.js >= 16.x LTS
* Docker
* Git
@@ -71,7 +71,7 @@ $ npm run test:e2e
Open Visual Studio Code, press Ctrl+P and paste the following commands.
-In Visual Studio Code we use the ESLint extension.
+In Visual Studio Code we use the ESLint extension.
```
ext install dbaeumer.vscode-eslint
```
diff --git a/back/methods/docuware/specs/upload.spec.js b/back/methods/docuware/specs/upload.spec.js
index 7ac873e95..3b8c55a50 100644
--- a/back/methods/docuware/specs/upload.spec.js
+++ b/back/methods/docuware/specs/upload.spec.js
@@ -2,8 +2,9 @@ const models = require('vn-loopback/server/server').models;
describe('docuware upload()', () => {
const userId = 9;
- const ticketId = 10;
+ const ticketIds = [10];
const ctx = {
+ args: {ticketIds},
req: {
getLocale: () => {
return 'en';
@@ -27,7 +28,7 @@ describe('docuware upload()', () => {
let error;
try {
- await models.Docuware.upload(ctx, ticketId, fileCabinetName);
+ await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
} catch (e) {
error = e.message;
}
diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js
index ea9ee3622..096301e56 100644
--- a/back/methods/docuware/upload.js
+++ b/back/methods/docuware/upload.js
@@ -3,34 +3,34 @@ const axios = require('axios');
module.exports = Self => {
Self.remoteMethodCtx('upload', {
- description: 'Upload an docuware PDF',
+ description: 'Upload docuware PDFs',
accessType: 'WRITE',
accepts: [
{
- arg: 'id',
- type: 'number',
- description: 'The ticket id',
- http: {source: 'path'}
+ arg: 'ticketIds',
+ type: ['number'],
+ description: 'The ticket ids',
+ required: true
},
{
arg: 'fileCabinet',
type: 'string',
- description: 'The file cabinet'
- },
- {
- arg: 'dialog',
- type: 'string',
- description: 'The dialog'
+ description: 'The file cabinet',
+ required: true
}
],
- returns: [],
+ returns: {
+ type: 'object',
+ root: true
+ },
http: {
- path: `/:id/upload`,
+ path: `/upload`,
verb: 'POST'
}
});
- Self.upload = async function(ctx, id, fileCabinet) {
+ Self.upload = async function(ctx, ticketIds, fileCabinet) {
+ delete ctx.args.ticketIds;
const models = Self.app.models;
const action = 'store';
@@ -38,104 +38,114 @@ module.exports = Self => {
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
- // get delivery note
- const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
- id,
- type: 'deliveryNote'
- });
-
- // get ticket data
- const ticket = await models.Ticket.findById(id, {
- include: [{
- relation: 'client',
- scope: {
- fields: ['id', 'socialName', 'fi']
- }
- }]
- });
-
- // upload file
- const templateJson = {
- 'Fields': [
- {
- 'FieldName': 'N__ALBAR_N',
- 'ItemElementName': 'string',
- 'Item': id,
- },
- {
- 'FieldName': 'CIF_PROVEEDOR',
- 'ItemElementName': 'string',
- 'Item': ticket.client().fi,
- },
- {
- 'FieldName': 'CODIGO_PROVEEDOR',
- 'ItemElementName': 'string',
- 'Item': ticket.client().id,
- },
- {
- 'FieldName': 'NOMBRE_PROVEEDOR',
- 'ItemElementName': 'string',
- 'Item': ticket.client().socialName,
- },
- {
- 'FieldName': 'FECHA_FACTURA',
- 'ItemElementName': 'date',
- 'Item': ticket.shipped,
- },
- {
- 'FieldName': 'TOTAL_FACTURA',
- 'ItemElementName': 'Decimal',
- 'Item': ticket.totalWithVat,
- },
- {
- 'FieldName': 'ESTADO',
- 'ItemElementName': 'string',
- 'Item': 'Pendiente procesar',
- },
- {
- 'FieldName': 'FIRMA_',
- 'ItemElementName': 'string',
- 'Item': 'Si',
- },
- {
- 'FieldName': 'FILTRO_TABLET',
- 'ItemElementName': 'string',
- 'Item': 'Tablet1',
- }
- ]
- };
-
- if (process.env.NODE_ENV != 'production')
- throw new UserError('Action not allowed on the test environment');
-
- // delete old
- const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
- if (docuwareFile) {
- const deleteJson = {
- 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
- };
- const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
- await axios.put(deleteUri, deleteJson, options.headers);
- }
-
- const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
- const FormData = require('form-data');
- const data = new FormData();
-
- data.append('document', JSON.stringify(templateJson), 'schema.json');
- data.append('file[]', deliveryNote[0], 'file.pdf');
- const uploadOptions = {
- headers: {
- 'Content-Type': 'multipart/form-data',
- 'X-File-ModifiedDate': Date.vnNew(),
- 'Cookie': options.headers.headers.Cookie,
- ...data.getHeaders()
- },
- };
-
- return await axios.post(uploadUri, data, uploadOptions)
- .catch(() => {
- throw new UserError('Failed to upload file');
+ const uploaded = [];
+ for (id of ticketIds) {
+ // get delivery note
+ ctx.args.id = id;
+ const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
+ id,
+ type: 'deliveryNote'
});
+ // get ticket data
+ const ticket = await models.Ticket.findById(id, {
+ include: [{
+ relation: 'client',
+ scope: {
+ fields: ['id', 'name', 'fi']
+ }
+ }]
+ });
+
+ // upload file
+ const templateJson = {
+ 'Fields': [
+ {
+ 'FieldName': 'N__ALBAR_N',
+ 'ItemElementName': 'string',
+ 'Item': id,
+ },
+ {
+ 'FieldName': 'CIF_PROVEEDOR',
+ 'ItemElementName': 'string',
+ 'Item': ticket.client().fi,
+ },
+ {
+ 'FieldName': 'CODIGO_PROVEEDOR',
+ 'ItemElementName': 'string',
+ 'Item': ticket.client().id,
+ },
+ {
+ 'FieldName': 'NOMBRE_PROVEEDOR',
+ 'ItemElementName': 'string',
+ 'Item': ticket.client().name + ' - ' + id,
+ },
+ {
+ 'FieldName': 'FECHA_FACTURA',
+ 'ItemElementName': 'date',
+ 'Item': ticket.shipped,
+ },
+ {
+ 'FieldName': 'TOTAL_FACTURA',
+ 'ItemElementName': 'Decimal',
+ 'Item': ticket.totalWithVat,
+ },
+ {
+ 'FieldName': 'ESTADO',
+ 'ItemElementName': 'string',
+ 'Item': 'Pendiente procesar',
+ },
+ {
+ 'FieldName': 'FIRMA_',
+ 'ItemElementName': 'string',
+ 'Item': 'Si',
+ },
+ {
+ 'FieldName': 'FILTRO_TABLET',
+ 'ItemElementName': 'string',
+ 'Item': 'Tablet1',
+ }
+ ]
+ };
+
+ if (process.env.NODE_ENV != 'production')
+ throw new UserError('Action not allowed on the test environment');
+
+ // delete old
+ const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
+ if (docuwareFile) {
+ const deleteJson = {
+ 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
+ };
+ const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
+ await axios.put(deleteUri, deleteJson, options.headers);
+ }
+
+ const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
+ const FormData = require('form-data');
+ const data = new FormData();
+
+ data.append('document', JSON.stringify(templateJson), 'schema.json');
+ data.append('file[]', deliveryNote[0], 'file.pdf');
+ const uploadOptions = {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ 'X-File-ModifiedDate': Date.vnNew(),
+ 'Cookie': options.headers.headers.Cookie,
+ ...data.getHeaders()
+ },
+ };
+
+ try {
+ await axios.post(uploadUri, data, uploadOptions);
+ } catch (err) {
+ const $t = ctx.req.__;
+ const message = $t('Failed to upload delivery note', {id});
+ if (uploaded.length)
+ await models.TicketTracking.setDelivered(ctx, uploaded);
+ throw new UserError(message);
+ }
+ uploaded.push(id);
+ }
+ return models.TicketTracking.setDelivered(ctx, ticketIds);
};
};
diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js
new file mode 100644
index 000000000..1f3532bd6
--- /dev/null
+++ b/back/methods/vn-user/renew-token.js
@@ -0,0 +1,38 @@
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('renewToken', {
+ description: 'Checks if the token has more than renewPeriod seconds to live and if so, renews it',
+ accepts: [],
+ returns: {
+ type: 'Object',
+ root: true
+ },
+ http: {
+ path: `/renewToken`,
+ verb: 'POST'
+ }
+ });
+
+ Self.renewToken = async function(ctx) {
+ const models = Self.app.models;
+ const userId = ctx.req.accessToken.userId;
+ const created = ctx.req.accessToken.created;
+ const tokenId = ctx.req.accessToken.id;
+
+ const now = new Date();
+ const differenceMilliseconds = now - created;
+ const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
+
+ const accessTokenConfig = await models.AccessTokenConfig.findOne({fields: ['renewPeriod']});
+
+ if (differenceSeconds <= accessTokenConfig.renewPeriod)
+ throw new UserError(`The renew period has not been exceeded`);
+
+ await Self.logout(tokenId);
+ const user = await Self.findById(userId);
+ const accessToken = await user.createAccessToken();
+
+ return {token: accessToken.id, created: accessToken.created};
+ };
+};
diff --git a/back/methods/vn-user/signIn.js b/back/methods/vn-user/signIn.js
index d7db90a21..c98f1da54 100644
--- a/back/methods/vn-user/signIn.js
+++ b/back/methods/vn-user/signIn.js
@@ -62,10 +62,9 @@ module.exports = Self => {
scopes: ['change-password'],
userId: vnUser.id
});
- throw new UserError('Pass expired', 'passExpired', {
- id: vnUser.id,
- token: changePasswordToken.id
- });
+ const err = new UserError('Pass expired', 'passExpired');
+ err.details = {token: changePasswordToken};
+ throw err;
}
try {
@@ -77,6 +76,6 @@ module.exports = Self => {
let loginInfo = Object.assign({password}, userInfo);
token = await Self.login(loginInfo, 'user');
- return {token: token.id};
+ return {token: token.id, created: token.created};
};
};
diff --git a/back/methods/vn-user/specs/signIn.js b/back/methods/vn-user/specs/signIn.spec.js
similarity index 91%
rename from back/methods/vn-user/specs/signIn.js
rename to back/methods/vn-user/specs/signIn.spec.js
index b46c645d6..c3f4630c6 100644
--- a/back/methods/vn-user/specs/signIn.js
+++ b/back/methods/vn-user/specs/signIn.spec.js
@@ -9,7 +9,7 @@ describe('VnUser signIn()', () => {
expect(login.token).toBeDefined();
- await models.VnUser.signOut(ctx);
+ await models.VnUser.logout(ctx.req.accessToken.id);
});
it('should return the token if the user doesnt exist but the client does', async() => {
@@ -19,7 +19,7 @@ describe('VnUser signIn()', () => {
expect(login.token).toBeDefined();
- await models.VnUser.signOut(ctx);
+ await models.VnUser.logout(ctx.req.accessToken.id);
});
});
diff --git a/back/methods/vn-user/specs/signOut.js b/back/methods/vn-user/specs/signOut.js
deleted file mode 100644
index c84e86f05..000000000
--- a/back/methods/vn-user/specs/signOut.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const {models} = require('vn-loopback/server/server');
-
-describe('VnUser signOut()', () => {
- it('should logout and remove token after valid login', async() => {
- let loginResponse = await models.VnUser.signOut('buyer', 'nightmare');
- let accessToken = await models.AccessToken.findById(loginResponse.token);
- let ctx = {req: {accessToken: accessToken}};
-
- let logoutResponse = await models.VnUser.signOut(ctx);
- let tokenAfterLogout = await models.AccessToken.findById(loginResponse.token);
-
- expect(logoutResponse).toBeTrue();
- expect(tokenAfterLogout).toBeNull();
- });
-
- it('should throw a 401 error when token is invalid', async() => {
- let error;
- let ctx = {req: {accessToken: {id: 'invalidToken'}}};
-
- try {
- response = await models.VnUser.signOut(ctx);
- } catch (e) {
- error = e;
- }
-
- expect(error).toBeDefined();
- expect(error.statusCode).toBe(401);
- });
-
- it('should throw an error when no token is passed', async() => {
- let error;
- let ctx = {req: {accessToken: null}};
-
- try {
- response = await models.VnUser.signOut(ctx);
- } catch (e) {
- error = e;
- }
-
- expect(error).toBeDefined();
- });
-});
diff --git a/back/model-config.json b/back/model-config.json
index ff2bf5850..d945f3250 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -2,6 +2,14 @@
"AccountingType": {
"dataSource": "vn"
},
+ "AccessTokenConfig": {
+ "dataSource": "vn",
+ "options": {
+ "mysql": {
+ "table": "salix.accessTokenConfig"
+ }
+ }
+ },
"Bank": {
"dataSource": "vn"
},
diff --git a/back/models/access-token-config.json b/back/models/access-token-config.json
new file mode 100644
index 000000000..6d90a0f4d
--- /dev/null
+++ b/back/models/access-token-config.json
@@ -0,0 +1,30 @@
+{
+ "name": "AccessTokenConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "accessTokenConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "renewPeriod": {
+ "type": "number",
+ "required": true
+ },
+ "renewInterval": {
+ "type": "number",
+ "required": true
+ }
+ },
+ "acls": [{
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }]
+}
diff --git a/back/models/vn-user.js b/back/models/vn-user.js
index 1b9743769..b58395acc 100644
--- a/back/models/vn-user.js
+++ b/back/models/vn-user.js
@@ -10,6 +10,7 @@ module.exports = function(Self) {
require('../methods/vn-user/recover-password')(Self);
require('../methods/vn-user/validate-token')(Self);
require('../methods/vn-user/privileges')(Self);
+ require('../methods/vn-user/renew-token')(Self);
Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create');
diff --git a/back/process.yml b/back/process.yml
index 38d2b9eaf..a29323240 100644
--- a/back/process.yml
+++ b/back/process.yml
@@ -4,4 +4,4 @@ apps:
instances: 1
max_restarts: 3
restart_delay: 15000
- node_args: --tls-min-v1.0
+ node_args: --tls-min-v1.0 --openssl-legacy-provider
diff --git a/db/changes/232601/.gitkeep b/db/changes/232601/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/changes/232601/00-entry_updateComission.sql b/db/changes/232601/00-entry_updateComission.sql
new file mode 100644
index 000000000..5a25d72e8
--- /dev/null
+++ b/db/changes/232601/00-entry_updateComission.sql
@@ -0,0 +1,40 @@
+DELIMITER $$
+$$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_updateComission`(vCurrency INT)
+BEGIN
+/**
+ * Actualiza la comision de las entradas de hoy a futuro y las recalcula
+ *
+ * @param vCurrency id del tipo de moneda(SAR,EUR,USD,GBP,JPY)
+ */
+ DECLARE vCurrencyName VARCHAR(25);
+ DECLARE vComission INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tmp.recalcEntryCommision
+ SELECT e.id
+ FROM vn.entry e
+ JOIN vn.travel t ON t.id = e.travelFk
+ JOIN vn.warehouse w ON w.id = t.warehouseInFk
+ WHERE t.shipped >= util.VN_CURDATE()
+ AND e.currencyFk = vCurrency;
+
+ SET vComission = currency_getCommission(vCurrency);
+
+ UPDATE vn.entry e
+ JOIN tmp.recalcEntryCommision tmp ON tmp.id = e.id
+ SET e.commission = vComission;
+
+ SELECT `name` INTO vCurrencyName
+ FROM currency
+ WHERE id = vCurrency;
+
+ CALL entry_recalc();
+ SELECT util.notification_send(
+ 'entry-update-comission',
+ JSON_OBJECT('currencyName', vCurrencyName, 'referenceCurrent', vComission),
+ account.myUser_getId()
+ );
+
+ DROP TEMPORARY TABLE tmp.recalcEntryCommision;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/changes/232601/00-packingSiteAdvanced.sql b/db/changes/232601/00-packingSiteAdvanced.sql
new file mode 100644
index 000000000..0e33744cd
--- /dev/null
+++ b/db/changes/232601/00-packingSiteAdvanced.sql
@@ -0,0 +1,71 @@
+CREATE TABLE `vn`.`packingSiteAdvanced` (
+ `ticketFk` int(11),
+ `workerFk` int(10) unsigned,
+ PRIMARY KEY (`ticketFk`),
+ KEY `packingSiteAdvanced_FK_1` (`workerFk`),
+ CONSTRAINT `packingSiteAdvanced_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `packingSiteAdvanced_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('PackingSiteAdvanced', '*', '*', 'ALLOW', 'ROLE', 'production');
+
+ DROP PROCEDURE IF EXISTS `vn`.`packingSite_startCollection`;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT)
+proc: BEGIN
+/**
+ * @param vSelf packingSite id
+ * @param vTicketFk A ticket id from the collection to start
+ */
+ DECLARE vExists BOOL;
+ DECLARE vIsAdvanced BOOL;
+ DECLARE vNewCollectionFk INT;
+ DECLARE vOldCollectionFk INT;
+ DECLARE vIsPackingByOther BOOL;
+
+ SELECT id, collectionFk
+ INTO vExists, vOldCollectionFk
+ FROM packingSite
+ WHERE id = vSelf;
+
+ IF NOT vExists THEN
+ CALL util.throw('packingSiteNotExists');
+ END IF;
+
+ SELECT COUNT(*) > 0
+ INTO vIsAdvanced
+ FROM packingSiteAdvanced
+ WHERE ticketFk = vTicketFk;
+
+ IF vIsAdvanced THEN
+ LEAVE proc;
+ END IF;
+
+ SELECT collectionFk INTO vNewCollectionFk
+ FROM ticketCollection WHERE ticketFk = vTicketFk;
+
+ IF vOldCollectionFk IS NOT NULL
+ AND vOldCollectionFk <> vNewCollectionFk THEN
+ SELECT COUNT(*) > 0
+ INTO vIsPackingByOther
+ FROM packingSite
+ WHERE id <> vSelf
+ AND collectionFk = vOldCollectionFk;
+
+ IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) THEN
+ CALL util.throw('cannotChangeCollection');
+ END IF;
+ END IF;
+
+ UPDATE packingSite SET collectionFk = vNewCollectionFk
+ WHERE id = vSelf;
+END$$
+DELIMITER ;
+
+
+
diff --git a/db/changes/232601/00-salix.sql b/db/changes/232601/00-salix.sql
new file mode 100644
index 000000000..dc1ed69be
--- /dev/null
+++ b/db/changes/232601/00-salix.sql
@@ -0,0 +1,10 @@
+CREATE TABLE `salix`.`accessTokenConfig` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `renewPeriod` int(10) unsigned DEFAULT NULL,
+ `renewInterval` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+INSERT IGNORE INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `renewInterval`)
+ VALUES
+ (1, 21600, 300);
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index a6557ff89..9c930222f 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2736,7 +2736,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(1, 'print-email', 'notification fixture one'),
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
- (4, 'supplier-pay-method-update', 'A supplier pay method has been updated');
+ (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
+ (5, 'modified-entry', 'An entry has been modified');
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
@@ -2894,6 +2895,10 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
(2, 1, 50, 2),
(3, 1, 0, 3);
+INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `renewInterval`)
+ VALUES
+ (1, 21600, 300);
+
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
VALUES
(1, 1, 1, 1, 442);
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 039f6ee8f..b8eaa99a1 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -311,9 +311,9 @@ export default {
},
clientDefaulter: {
anyClient: 'vn-client-defaulter tbody > tr',
- firstClientName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(2) > span',
- firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(3) > span',
- firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]',
+ firstClientName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(2) > span',
+ firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(3) > span',
+ firstObservation: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]',
allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check',
addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]',
observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]',
@@ -334,15 +334,15 @@ export default {
},
itemsIndex: {
createItemButton: `vn-float-button`,
- firstSearchResult: 'vn-item-index tbody tr:nth-child(1)',
+ firstSearchResult: 'vn-item-index tbody tr:nth-child(2)',
searchResult: 'vn-item-index tbody tr:not(.empty-rows)',
- firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]',
+ firstResultPreviewButton: 'vn-item-index tbody > :nth-child(2) .buttons > [icon="preview"]',
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
closeItemSummaryPreview: '.vn-popup.shown',
shownColumns: 'vn-item-index vn-button[id="shownColumns"]',
shownColumnsList: '.vn-popover.shown .content',
- firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img',
+ firstItemImage: 'vn-item-index tbody > tr:nth-child(2) > td:nth-child(1) > img',
firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)',
firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)',
idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]',
@@ -523,11 +523,11 @@ export default {
searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar',
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
- fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)',
- fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
+ fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
+ fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(6)',
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
- firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]',
- firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
+ firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) vn-icon-button[icon="delete"]',
+ firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) [ng-model="weekly.agencyModeFk"]',
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
},
createTicketView: {
@@ -572,8 +572,8 @@ export default {
submitNotesButton: 'button[type=submit]'
},
ticketExpedition: {
- firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(1) vn-check[ng-model="expedition.checked"]',
- thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(3) vn-check[ng-model="expedition.checked"]',
+ firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(2) vn-check[ng-model="expedition.checked"]',
+ thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(4) vn-check[ng-model="expedition.checked"]',
deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]',
moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]',
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
@@ -712,7 +712,7 @@ export default {
problems: 'vn-check[label="With problems"]',
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
moveButton: 'vn-button[vn-tooltip="Future tickets"]',
- firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
+ firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
multiCheck: 'vn-multi-check',
tableId: 'vn-textfield[name="id"]',
tableFutureId: 'vn-textfield[name="futureId"]',
@@ -736,7 +736,7 @@ export default {
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
acceptButton: '.vn-confirm.shown button[response="accept"]',
- firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
+ firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
tableId: 'vn-textfield[name="id"]',
tableFutureId: 'vn-textfield[name="futureId"]',
tableLiters: 'vn-textfield[name="liters"]',
@@ -810,7 +810,7 @@ export default {
claimAction: {
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
anyLine: 'vn-claim-action vn-tbody > vn-tr',
- firstDeleteLine: 'vn-claim-action tr:nth-child(1) vn-icon-button[icon="delete"]',
+ firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
},
ordersIndex: {
@@ -1216,7 +1216,7 @@ export default {
addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]',
itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]',
itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]',
- firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)',
+ firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(2)',
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',
diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
index 526afa140..9c37ce9ba 100644
--- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
+++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
@@ -19,15 +19,14 @@ describe('SmartTable SearchBar integration', () => {
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
- await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3);
+ await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
await page.reload({
waitUntil: 'networkidle2'
});
- await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3);
+ await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
- await page.waitToClick(selectors.itemsIndex.advancedSmartTableButton);
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
await page.keyboard.press('Enter');
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
@@ -36,7 +35,7 @@ describe('SmartTable SearchBar integration', () => {
waitUntil: 'networkidle2'
});
- await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
+ await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
});
it('should filter in section without smart-table and search in searchBar go to zone section', async() => {
diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js
index 97e62abef..2bb3d6254 100644
--- a/e2e/paths/02-client/21_defaulter.spec.js
+++ b/e2e/paths/02-client/21_defaulter.spec.js
@@ -19,7 +19,7 @@ describe('Client defaulter path', () => {
it('should count the amount of clients in the turns section', async() => {
const result = await page.countElement(selectors.clientDefaulter.anyClient);
- expect(result).toEqual(5);
+ expect(result).toEqual(6);
});
it('should check contain expected client', async() => {
diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js
index e24fa6a9f..e09ecb778 100644
--- a/e2e/paths/04-item/01_summary.spec.js
+++ b/e2e/paths/04-item/01_summary.spec.js
@@ -18,11 +18,11 @@ describe('Item summary path', () => {
await page.doSearch('Ranged weapon');
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
- await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon');
+ await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon');
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
const isVisible = await page.isVisible(selectors.itemSummary.basicData);
- expect(resultsCount).toBe(3);
+ expect(resultsCount).toBe(4);
expect(isVisible).toBeTruthy();
});
@@ -66,7 +66,7 @@ describe('Item summary path', () => {
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
- expect(resultsCount).toBe(2);
+ expect(resultsCount).toBe(3);
});
it(`should now check the item summary preview shows fields from basic data`, async() => {
diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js
index dc467044d..c88fbd337 100644
--- a/e2e/paths/04-item/10_item_log.spec.js
+++ b/e2e/paths/04-item/10_item_log.spec.js
@@ -18,7 +18,7 @@ describe('Item log path', () => {
await page.doSearch('Knowledge artifact');
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
- expect(nResults).toEqual(0);
+ expect(nResults).toEqual(1);
});
it('should access to the create item view by clicking the create floating button', async() => {
diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
index edccd5561..b97576940 100644
--- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
+++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
@@ -27,6 +27,6 @@ describe('Ticket expeditions and log path', () => {
const result = await page
.countElement(selectors.ticketExpedition.expeditionRow);
- expect(result).toEqual(3);
+ expect(result).toEqual(4);
});
});
diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js
index 0ba57aa9d..a9cce2ead 100644
--- a/e2e/paths/05-ticket/09_weekly.spec.js
+++ b/e2e/paths/05-ticket/09_weekly.spec.js
@@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => {
it('should count the amount of tickets in the turns section', async() => {
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
- expect(result).toEqual(6);
+ expect(result).toEqual(7);
});
it('should go back to the ticket index then search and access a ticket summary', async() => {
@@ -89,7 +89,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch('11');
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
- expect(nResults).toEqual(1);
+ expect(nResults).toEqual(2);
});
it('should delete the weekly ticket 11', async() => {
@@ -104,7 +104,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch();
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
- expect(nResults).toEqual(6);
+ expect(nResults).toEqual(7);
});
it('should update the agency then remove it afterwards', async() => {
diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js
index cf1c5ded3..ae23c9c99 100644
--- a/e2e/paths/05-ticket/20_moveExpedition.spec.js
+++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js
@@ -29,7 +29,7 @@ describe('Ticket expeditions', () => {
const result = await page
.countElement(selectors.ticketExpedition.expeditionRow);
- expect(result).toEqual(1);
+ expect(result).toEqual(2);
});
it(`should move one expedition to new ticket with route`, async() => {
@@ -45,6 +45,6 @@ describe('Ticket expeditions', () => {
const result = await page
.countElement(selectors.ticketExpedition.expeditionRow);
- expect(result).toEqual(1);
+ expect(result).toEqual(2);
});
});
diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js
index c854dcbaf..7b7d478f7 100644
--- a/e2e/paths/05-ticket/21_future.spec.js
+++ b/e2e/paths/05-ticket/21_future.spec.js
@@ -87,7 +87,7 @@ describe('Ticket Future path', () => {
await page.clearInput(selectors.ticketFuture.futureState);
await page.waitToClick(selectors.ticketFuture.submit);
- await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4);
+ await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 5);
await page.waitToClick(selectors.ticketFuture.multiCheck);
await page.waitToClick(selectors.ticketFuture.firstCheck);
await page.waitToClick(selectors.ticketFuture.moveButton);
diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js
index b2380a62f..c3b927c62 100644
--- a/front/core/components/smart-table/index.js
+++ b/front/core/components/smart-table/index.js
@@ -40,6 +40,8 @@ export default class SmartTable extends Component {
this._options = options;
if (!options) return;
+ options.defaultSearch = true;
+
if (options.defaultSearch)
this.displaySearch();
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index 41cd27f03..ef6c07637 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -64,7 +64,7 @@ export default class Auth {
}
onLoginOk(json, remember) {
- this.vnToken.set(json.data.token, remember);
+ this.vnToken.set(json.data.token, json.data.created, remember);
return this.loadAcls().then(() => {
let continueHash = this.$state.params.continue;
diff --git a/front/core/services/index.js b/front/core/services/index.js
index 867a13df0..855f2fab1 100644
--- a/front/core/services/index.js
+++ b/front/core/services/index.js
@@ -11,3 +11,4 @@ import './report';
import './email';
import './file';
import './date';
+
diff --git a/front/core/services/token.js b/front/core/services/token.js
index 126fbb604..c1bb5a173 100644
--- a/front/core/services/token.js
+++ b/front/core/services/token.js
@@ -9,25 +9,33 @@ export default class Token {
constructor() {
try {
this.token = sessionStorage.getItem('vnToken');
- if (!this.token)
+ this.created = sessionStorage.getItem('vnTokenCreated');
+ if (!this.token) {
this.token = localStorage.getItem('vnToken');
+ this.created = localStorage.getItem('vnTokenCreated');
+ }
} catch (e) {}
}
- set(value, remember) {
+ set(token, created, remember) {
this.unset();
try {
- if (remember)
- localStorage.setItem('vnToken', value);
- else
- sessionStorage.setItem('vnToken', value);
+ if (remember) {
+ localStorage.setItem('vnToken', token);
+ localStorage.setItem('vnTokenCreated', created);
+ } else {
+ sessionStorage.setItem('vnToken', token);
+ sessionStorage.setItem('vnTokenCreated', created);
+ }
} catch (e) {}
- this.token = value;
+ this.token = token;
+ this.created = created;
}
unset() {
localStorage.removeItem('vnToken');
sessionStorage.removeItem('vnToken');
this.token = null;
+ this.created = null;
}
}
diff --git a/front/salix/components/change-password/index.js b/front/salix/components/change-password/index.js
index 3d660e894..baa9d96e5 100644
--- a/front/salix/components/change-password/index.js
+++ b/front/salix/components/change-password/index.js
@@ -15,7 +15,7 @@ export default class Controller {
}
$onInit() {
- if (!this.$state.params || !this.$state.params.id || !this.$state.params.token)
+ if (!this.$state.params.id)
this.$state.go('login');
this.$http.get('UserPasswords/findOne')
@@ -25,7 +25,7 @@ export default class Controller {
}
submit() {
- const id = this.$state.params.id;
+ const userId = this.$state.params.userId;
const newPassword = this.newPassword;
const oldPassword = this.oldPassword;
@@ -35,12 +35,12 @@ export default class Controller {
throw new UserError(`Passwords don't match`);
const headers = {
- Authorization: this.$state.params.token
+ Authorization: this.$state.params.id
};
this.$http.post('VnUsers/change-password',
{
- id,
+ id: userId,
oldPassword,
newPassword
},
diff --git a/front/salix/components/layout/index.js b/front/salix/components/layout/index.js
index 48f50f404..dc2313f4f 100644
--- a/front/salix/components/layout/index.js
+++ b/front/salix/components/layout/index.js
@@ -3,13 +3,14 @@ import Component from 'core/lib/component';
import './style.scss';
export class Layout extends Component {
- constructor($element, $, vnModules) {
+ constructor($element, $, vnModules, vnToken) {
super($element, $);
this.modules = vnModules.get();
}
$onInit() {
this.getUserData();
+ this.getAccessTokenConfig();
}
getUserData() {
@@ -30,8 +31,42 @@ export class Layout extends Component {
refresh() {
window.location.reload();
}
+
+ getAccessTokenConfig() {
+ this.$http.get('AccessTokenConfigs').then(json => {
+ const firtsResult = json.data[0];
+ if (!firtsResult) return;
+ this.renewPeriod = firtsResult.renewPeriod;
+ this.renewInterval = firtsResult.renewInterval;
+
+ const intervalMilliseconds = firtsResult.renewInterval * 1000;
+ this.inservalId = setInterval(this.checkTokenValidity.bind(this), intervalMilliseconds);
+ });
+ }
+
+ checkTokenValidity() {
+ const now = new Date();
+ const differenceMilliseconds = now - new Date(this.vnToken.created);
+ const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
+
+ if (differenceSeconds > this.renewPeriod) {
+ this.$http.post('VnUsers/renewToken')
+ .then(json => {
+ if (json.data.token) {
+ let remember = true;
+ if (window.sessionStorage.vnToken) remember = false;
+
+ this.vnToken.set(json.data.token, json.data.created, remember);
+ }
+ });
+ }
+ }
+
+ $onDestroy() {
+ clearInterval(this.inservalId);
+ }
}
-Layout.$inject = ['$element', '$scope', 'vnModules'];
+Layout.$inject = ['$element', '$scope', 'vnModules', 'vnToken'];
ngModule.vnComponent('vnLayout', {
template: require('./index.html'),
diff --git a/front/salix/components/layout/index.spec.js b/front/salix/components/layout/index.spec.js
index 0d70c4806..8f65f32ce 100644
--- a/front/salix/components/layout/index.spec.js
+++ b/front/salix/components/layout/index.spec.js
@@ -37,4 +37,49 @@ describe('Component vnLayout', () => {
expect(url).not.toBeDefined();
});
});
+
+ describe('getAccessTokenConfig()', () => {
+ it(`should set the renewPeriod and renewInterval properties in localStorage`, () => {
+ const response = [{
+ renewPeriod: 100,
+ renewInterval: 5
+ }];
+
+ $httpBackend.expect('GET', `AccessTokenConfigs`).respond(response);
+ controller.getAccessTokenConfig();
+ $httpBackend.flush();
+
+ expect(controller.renewPeriod).toBe(100);
+ expect(controller.renewInterval).toBe(5);
+ expect(controller.inservalId).toBeDefined();
+ });
+ });
+
+ describe('checkTokenValidity()', () => {
+ it(`should not call renewToken and not set vnToken in the controller`, () => {
+ controller.renewPeriod = 100;
+ controller.vnToken.created = new Date();
+
+ controller.checkTokenValidity();
+
+ expect(controller.vnToken.token).toBeNull();
+ });
+
+ it(`should call renewToken and set vnToken properties in the controller`, () => {
+ const response = {
+ token: 999,
+ created: new Date()
+ };
+ controller.renewPeriod = 100;
+ const oneHourBefore = new Date(Date.now() - (60 * 60 * 1000));
+ controller.vnToken.created = oneHourBefore;
+
+ $httpBackend.expect('POST', `VnUsers/renewToken`).respond(response);
+ controller.checkTokenValidity();
+ $httpBackend.flush();
+
+ expect(controller.vnToken.token).toBe(999);
+ expect(controller.vnToken.created).toEqual(response.created);
+ });
+ });
});
diff --git a/front/salix/components/login/index.js b/front/salix/components/login/index.js
index 0412f3b74..8e8f08244 100644
--- a/front/salix/components/login/index.js
+++ b/front/salix/components/login/index.js
@@ -27,10 +27,9 @@ export default class Controller {
this.loading = false;
this.password = '';
this.focusUser();
- if (req?.data?.error?.code == 'passExpired') {
- const [args] = req.data.error.translateArgs;
- this.$state.go('change-password', args);
- }
+ const err = req.data?.error;
+ if (err?.code == 'passExpired')
+ this.$state.go('change-password', err.details.token);
throw req;
});
diff --git a/front/salix/routes.js b/front/salix/routes.js
index d6dea244a..675da719a 100644
--- a/front/salix/routes.js
+++ b/front/salix/routes.js
@@ -38,7 +38,7 @@ function config($stateProvider, $urlRouterProvider) {
})
.state('change-password', {
parent: 'outLayout',
- url: '/change-password?id&token',
+ url: '/change-password?id&userId',
description: 'Change password',
template: ''
})
diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js
index f92e1ea09..22b535f62 100644
--- a/loopback/common/models/vn-model.js
+++ b/loopback/common/models/vn-model.js
@@ -200,22 +200,20 @@ module.exports = function(Self) {
const connector = this.dataSource.connector;
let conn;
let res;
- const opts = Object.assign({}, options);
try {
if (userId) {
- conn = await new Promise((resolve, reject) => {
- connector.client.getConnection(function(err, conn) {
- if (err)
- reject(err);
- else
- resolve(conn);
+ if (!options.transaction) {
+ options = Object.assign({}, options);
+ conn = await new Promise((resolve, reject) => {
+ connector.client.getConnection(function(err, conn) {
+ if (err)
+ reject(err);
+ else
+ resolve(conn);
+ });
});
- });
-
- const opts = Object.assign({}, options);
- if (!opts.transaction) {
- opts.transaction = {
+ options.transaction = {
connection: conn,
connector
};
@@ -223,15 +221,14 @@ module.exports = function(Self) {
await connector.executeP(
'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))',
- [userId], opts
+ [userId], options
);
}
- res = await connector.executeP(query, params, opts);
+ res = await connector.executeP(query, params, options);
- if (userId) {
- await connector.executeP('CALL account.myUser_logout()', null, opts);
- }
+ if (userId)
+ await connector.executeP('CALL account.myUser_logout()', null, options);
} finally {
if (conn) conn.release();
}
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index 8bc9d4056..43ff4b86a 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -174,5 +174,6 @@
"A claim with that sale already exists": "A claim with that sale already exists",
"Pass expired": "The password has expired, change it from Salix",
"Can't transfer claimed sales": "Can't transfer claimed sales",
- "Invalid quantity": "Invalid quantity"
+ "Invalid quantity": "Invalid quantity",
+ "Failed to upload delivery note": "Error to upload delivery note {{id}}"
}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 5dcfab364..895d087dc 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -258,7 +258,7 @@
"App name does not exist": "El nombre de aplicación no es válido",
"Try again": "Vuelve a intentarlo",
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
- "Failed to upload file": "Error al subir archivo",
+ "Failed to upload delivery note": "Error al subir albarán {{id}}",
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
@@ -293,5 +293,6 @@
"Pass expired": "La contraseña ha caducado, cambiela desde Salix",
"Invalid NIF for VIES": "Invalid NIF for VIES",
"Ticket does not exist": "Este ticket no existe",
- "Ticket is already signed": "Este ticket ya ha sido firmado"
+ "Ticket is already signed": "Este ticket ya ha sido firmado",
+ "The renew period has not been exceeded": "El periodo de renovación no ha sido superado"
}
diff --git a/modules/account/back/locale/account/en.yml b/modules/account/back/locale/account/en.yml
new file mode 100644
index 000000000..221afef5f
--- /dev/null
+++ b/modules/account/back/locale/account/en.yml
@@ -0,0 +1,3 @@
+name: account
+columns:
+ id: id
diff --git a/modules/account/back/locale/account/es.yml b/modules/account/back/locale/account/es.yml
new file mode 100644
index 000000000..a79b1f40c
--- /dev/null
+++ b/modules/account/back/locale/account/es.yml
@@ -0,0 +1,3 @@
+name: cuenta
+columns:
+ id: id
diff --git a/modules/account/back/locale/mail-alias-account/en.yml b/modules/account/back/locale/mail-alias-account/en.yml
new file mode 100644
index 000000000..bf805d66f
--- /dev/null
+++ b/modules/account/back/locale/mail-alias-account/en.yml
@@ -0,0 +1,5 @@
+name: mail alias
+columns:
+ id: id
+ mailAlias: alias
+ account: account
diff --git a/modules/account/back/locale/mail-alias-account/es.yml b/modules/account/back/locale/mail-alias-account/es.yml
new file mode 100644
index 000000000..b53ade996
--- /dev/null
+++ b/modules/account/back/locale/mail-alias-account/es.yml
@@ -0,0 +1,5 @@
+name: alias de correo
+columns:
+ id: id
+ mailAlias: alias
+ account: cuenta
diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js
index 7a341b0b0..0e78ab8d6 100644
--- a/modules/account/front/accounts/index.js
+++ b/modules/account/front/accounts/index.js
@@ -5,8 +5,7 @@ import UserError from 'core/lib/user-error';
export default class Controller extends Section {
onSynchronizeAll() {
this.vnApp.showSuccess(this.$t('Synchronizing in the background'));
- this.$http.patch(`Accounts/syncAll`)
- .then(() => this.vnApp.showSuccess(this.$t('Users synchronized!')));
+ this.$http.patch(`Accounts/syncAll`);
}
onUserSync() {
diff --git a/modules/client/back/methods/tpv-transaction/confirm.js b/modules/client/back/methods/tpv-transaction/confirm.js
index 4faa21bb5..41229a1fd 100644
--- a/modules/client/back/methods/tpv-transaction/confirm.js
+++ b/modules/client/back/methods/tpv-transaction/confirm.js
@@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
const base64url = require('base64url');
module.exports = Self => {
- Self.remoteMethodCtx('confirm', {
+ Self.remoteMethod('confirm', {
description: 'Confirms electronic payment transaction',
accessType: 'WRITE',
accepts: [
@@ -30,7 +30,7 @@ module.exports = Self => {
}
});
- Self.confirm = async(ctx, signatureVersion, merchantParameters, signature) => {
+ Self.confirm = async(signatureVersion, merchantParameters, signature) => {
const $ = Self.app.models;
let transaction;
@@ -83,7 +83,7 @@ module.exports = Self => {
params['Ds_Currency'],
params['Ds_Response'],
params['Ds_ErrorCode']
- ], {userId: ctx.req.accessToken.userId});
+ ]);
return true;
} catch (err) {
diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js
index f7e1b637e..bfbd1b416 100644
--- a/modules/entry/back/methods/entry/addFromBuy.js
+++ b/modules/entry/back/methods/entry/addFromBuy.js
@@ -46,7 +46,7 @@ module.exports = Self => {
}
try {
- let buy = await models.Buy.findOne({where: {entryFk: args.id}}, myOptions);
+ let buy = await models.Buy.findOne({where: {entryFk: args.id, itemFk: args.item}}, myOptions);
if (buy)
await buy.updateAttribute('printedStickers', args.printedStickers, myOptions);
else {
diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html
index 6d5b16329..3f0a10650 100644
--- a/modules/invoiceOut/front/global-invoicing/index.html
+++ b/modules/invoiceOut/front/global-invoicing/index.html
@@ -118,7 +118,8 @@
label="Company"
show-field="code"
value-field="id"
- ng-model="$ctrl.companyFk">
+ ng-model="$ctrl.companyFk"
+ on-change="$ctrl.getInvoiceDate(value)">
{
- this.companyFk = res.data.companyFk;
- const params = {
- companyFk: this.companyFk
- };
- return this.$http.get('InvoiceOuts/getInvoiceDate', {params});
- })
- .then(res => {
- this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
- this.invoiceDate = this.minInvoicingDate;
- });
- }
+ .then(res => {
+ this.companyFk = res.data.companyFk;
+ this.getInvoiceDate(this.companyFk);
+ });
+ }
+
+ getInvoiceDate(companyFk) {
+ const params = { companyFk: companyFk };
+ this.fetchInvoiceDate(params);
+ }
+
+ fetchInvoiceDate(params) {
+ this.$http.get('InvoiceOuts/getInvoiceDate', { params })
+ .then(res => {
+ this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
+ this.invoiceDate = this.minInvoicingDate;
+ });
+ }
stopInvoicing() {
this.status = 'stopping';
@@ -42,7 +48,7 @@ class Controller extends Section {
throw new UserError('Invoice date and the max date should be filled');
if (this.invoiceDate < this.maxShipped)
throw new UserError('Invoice date can\'t be less than max date');
- if (this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
+ if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
throw new UserError('Exists an invoice with a previous date');
if (!this.companyFk)
throw new UserError('Choose a valid company');
diff --git a/modules/invoiceOut/front/negative-bases/index.js b/modules/invoiceOut/front/negative-bases/index.js
index 1a838507c..f60668b20 100644
--- a/modules/invoiceOut/front/negative-bases/index.js
+++ b/modules/invoiceOut/front/negative-bases/index.js
@@ -19,7 +19,8 @@ export default class Controller extends Section {
this.smartTableOptions = {
activeButtons: {
search: true,
- }, columns: [
+ },
+ columns: [
{
field: 'isActive',
searchable: false
diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js
index a39cd6602..fe6788e9c 100644
--- a/modules/item/front/fixed-price/index.js
+++ b/modules/item/front/fixed-price/index.js
@@ -13,7 +13,6 @@ export default class Controller extends Section {
activeButtons: {
search: true
},
- defaultSearch: true,
columns: [
{
field: 'warehouseFk',
diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html
index bdd4e76ff..94a950baf 100644
--- a/modules/monitor/front/index/tickets/index.html
+++ b/modules/monitor/front/index/tickets/index.html
@@ -50,13 +50,13 @@
Salesperson
|
-
+ |
Date
|
-
+ |
Theoretical
|
-
+ |
Practical
|
diff --git a/modules/order/back/methods/order/confirm.js b/modules/order/back/methods/order/confirm.js
index 5fdab29b3..1fcb3a760 100644
--- a/modules/order/back/methods/order/confirm.js
+++ b/modules/order/back/methods/order/confirm.js
@@ -21,7 +21,6 @@ module.exports = Self => {
Self.confirm = async(ctx, orderFk) => {
const userId = ctx.req.accessToken.userId;
-
const query = `CALL hedera.order_confirmWithUser(?, ?)`;
const response = await Self.rawSql(query, [orderFk, userId], {userId});
diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html
index 7a64a9aff..9384af6be 100644
--- a/modules/route/front/index/index.html
+++ b/modules/route/front/index/index.html
@@ -1,11 +1,26 @@
+
+
+
+
+
+
-
|