Compare commits

...

34 Commits

Author SHA1 Message Date
Robert Ferrús f7a28eea58 Merge branch 'dev' into 5854-itemShelvingTraduciones
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-02 06:27:08 +00:00
Javier Segarra 703e16ffcd Merge pull request '#6434 - signIn_issue' (!1892) from 6434-signIn_issue into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1892
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
2023-12-22 09:36:29 +00:00
Javier Segarra ec1befcfb0 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head This commit looks good Details
2023-12-22 09:25:57 +00:00
Carlos Satorres 36698c1ace Merge pull request 'refs #5925 models table docuware' (!1889) from 5925-docuwareTablet into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1889
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2023-12-21 13:20:01 +00:00
Alex Moreno 9951e911ae refs #5925 feat(docuware_upload): use userConfig.tabletFk
gitea/salix/pipeline/head This commit looks good Details
2023-12-21 10:39:46 +01:00
Javier Segarra dc661f298b refs #6434 test: update tests
gitea/salix/pipeline/head This commit looks good Details
2023-12-21 09:10:18 +00:00
Alex Moreno d30dcd7d70 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5925-docuwareTablet 2023-12-21 09:22:49 +01:00
Javier Segarra 0feb8e5a16 Merge branch '6434-signIn_issue' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-21 09:01:07 +01:00
Javier Segarra daef9ee59a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue 2023-12-21 09:01:02 +01:00
Alex Moreno 38279b0786 refs #6594 deploy: init version 24.02
gitea/salix/pipeline/head This commit looks good Details
2023-12-21 08:37:30 +01:00
Alex Moreno f4489a7b56 Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev 2023-12-21 08:34:44 +01:00
Alex Moreno 7b0c5fe0a0 refs #5739 fix: sql
gitea/salix/pipeline/head This commit looks good Details
2023-12-21 08:33:50 +01:00
Javier Segarra 3c8ff346e2 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-21 06:58:09 +00:00
Alex Moreno 3094c330df Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev 2023-12-21 07:47:07 +01:00
Alex Moreno f2dcbe214a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into test 2023-12-21 07:44:41 +01:00
Javier Segarra 748d4724b5 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 13:29:29 +00:00
Javier Segarra cb35c36328 refs #6434 test: update tests
gitea/salix/pipeline/head This commit looks good Details
2023-12-20 10:59:36 +00:00
Javier Segarra 57b3d96628 refs #6434 fix: bad throw error
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 09:27:25 +00:00
Javier Segarra c3b91e1719 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 09:25:15 +00:00
Javier Segarra 5151cdca48 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-19 07:06:36 +00:00
Alex Moreno d7454cdb19 refs #6576 fix: correct version
gitea/salix/pipeline/head This commit looks good Details
2023-12-14 11:41:59 +01:00
Javier Segarra 8a66391cd5 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:31:53 +00:00
Javier Segarra 11b54d66af refs #6434 fix: bad merge
gitea/salix/pipeline/head Build queued... Details
2023-12-13 13:31:32 +01:00
Javier Segarra 5a36fabf05 refs #6434 feat: insert record just when fail
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:07:57 +01:00
Javier Segarra 6af99b7669 refs #6434 feat: delete records whe !owner 2023-12-13 12:07:41 +01:00
Carlos Satorres 4e8bec5684 refs #5925 user error
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:03:04 +01:00
Javier Segarra 5f93b8c440 refs #6434 fix: bad merge
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:01:18 +01:00
Javier Segarra 5b3645a641 refs #6434 fix: bad merge
gitea/salix/pipeline/head Build queued... Details
2023-12-13 11:59:00 +01:00
Javier Segarra d69b59b63e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 11:54:28 +01:00
Carlos Satorres 2393625a48 refs #5925 Tablet
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 08:22:58 +01:00
Carlos Satorres 412cac7e94 refs #5925 models table docuware
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-12 14:42:36 +01:00
Javier Segarra add3a81032 refs #6434 feat: remove recursively fn
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-15 09:29:26 +01:00
Javier Segarra 7f82243ce6 refs #6434 feat: create signInLog table
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-14 15:00:03 +01:00
Javier Segarra 5c777c705f refs #6434 feat: add new error message
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-14 13:00:20 +01:00
21 changed files with 136 additions and 47 deletions

View File

@ -3,7 +3,7 @@
// Carácter predeterminado de final de línea.
"files.eol": "\n",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"search.useIgnoreFiles": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",

View File

@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2352.01] - 2023-12-28
## [2402.01] - 2024-01-11
### Added
### Changed
### Fixed
## [2400.01] - 2024-01-04
### Added
### Changed
@ -13,9 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2350.01] - 2023-12-14
### Added
### Changed
### Fixed
### Características Añadidas 🆕
- **Tickets → Expediciones:** Añadido soporte para Viaexpress
## [2348.01] - 2023-11-30

View File

@ -24,15 +24,40 @@ describe('docuware upload()', () => {
});
it('should try upload file', async() => {
const tx = await models.Docuware.beginTransaction({});
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
let error;
try {
await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
const options = {transaction: tx};
const user = await models.UserConfig.findById(userId, null, options);
await user.updateAttribute('tabletFk', 'Tablet1');
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
await tx.rollback();
} catch (e) {
error = e.message;
error = e;
await tx.rollback();
}
expect(error).toEqual('Action not allowed on the test environment');
expect(error.message).toEqual('Action not allowed on the test environment');
});
it('should throw error when not have tablet assigned', async() => {
const tx = await models.Docuware.beginTransaction({});
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
let error;
try {
const options = {transaction: tx};
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
expect(error.message).toEqual('This user does not have an assigned tablet');
});
});

View File

@ -29,12 +29,24 @@ module.exports = Self => {
}
});
Self.upload = async function(ctx, ticketIds, fileCabinet) {
Self.upload = async function(ctx, ticketIds, fileCabinet, options) {
delete ctx.args.ticketIds;
const models = Self.app.models;
const action = 'store';
const options = await Self.getOptions();
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const userConfig = await models.UserConfig.findById(ctx.req.accessToken.userId, {
fields: ['tabletFk']
}, myOptions);
if (!userConfig?.tabletFk)
throw new UserError('This user does not have an assigned tablet');
const docuwareOptions = await Self.getOptions();
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
@ -45,7 +57,7 @@ module.exports = Self => {
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
id,
type: 'deliveryNote'
});
}, myOptions);
// get ticket data
const ticket = await models.Ticket.findById(id, {
include: [{
@ -54,7 +66,7 @@ module.exports = Self => {
fields: ['id', 'name', 'fi']
}
}]
});
}, myOptions);
// upload file
const templateJson = {
@ -102,7 +114,7 @@ module.exports = Self => {
{
'FieldName': 'FILTRO_TABLET',
'ItemElementName': 'string',
'Item': 'Tablet1',
'Item': userConfig.tabletFk,
}
]
};
@ -116,11 +128,11 @@ module.exports = Self => {
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 deleteUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
await axios.put(deleteUri, deleteJson, docuwareOptions.headers);
}
const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
const uploadUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
const FormData = require('form-data');
const data = new FormData();
@ -130,7 +142,7 @@ module.exports = Self => {
headers: {
'Content-Type': 'multipart/form-data',
'X-File-ModifiedDate': Date.vnNew(),
'Cookie': options.headers.headers.Cookie,
'Cookie': docuwareOptions.headers.headers.Cookie,
...data.getHeaders()
},
};
@ -141,11 +153,11 @@ module.exports = Self => {
const $t = ctx.req.__;
const message = $t('Failed to upload delivery note', {id});
if (uploaded.length)
await models.TicketTracking.setDelivered(ctx, uploaded);
await models.TicketTracking.setDelivered(ctx, uploaded, myOptions);
throw new UserError(message);
}
uploaded.push(id);
}
return models.TicketTracking.setDelivered(ctx, ticketIds);
return models.TicketTracking.setDelivered(ctx, ticketIds, myOptions);
};
};

View File

@ -27,8 +27,10 @@ describe('Renew Token', () => {
jasmine.clock().uninstall();
});
it('should renew process', async() => {
jasmine.clock().mockDate(new Date(startingTime + 21600000));
it('should renew token', async() => {
const mockDate = new Date(startingTime + 26600000);
jasmine.clock().mockDate(mockDate);
console.log(startingTime, mockDate)
const {id} = await models.VnUser.renewToken(ctx);
expect(id).not.toEqual(ctx.req.accessToken.id);

View File

@ -20,10 +20,7 @@ describe('VnUser Sign-in()', () => {
let ctx = {req: {accessToken: accessToken}};
let signInLog = await SignInLog.find({where: {token: accessToken.id}});
expect(signInLog.length).toEqual(1);
expect(signInLog[0].userFk).toEqual(accessToken.userId);
expect(signInLog[0].owner).toEqual(true);
expect(login.token).toBeDefined();
expect(signInLog.length).toEqual(0);
await VnUser.logout(ctx.req.accessToken.id);
});

View File

@ -0,0 +1,17 @@
{
"name": "docuwareTablet",
"base": "VnModel",
"options": {
"mysql": {
"table": "docuwareTablet"
}
},
"properties": {
"tablet": {
"type": "string"
},
"description": {
"type": "string"
}
}
}

View File

@ -26,6 +26,9 @@
},
"darkMode": {
"type": "boolean"
},
"tabletFk": {
"type": "string"
}
},
"relations": {
@ -43,6 +46,11 @@
"type": "belongsTo",
"model": "VnUser",
"foreignKey": "userFk"
}
},
"Tablet": {
"type": "belongsTo",
"model": "docuwareTablet",
"foreignKey": "tabletFk"
}
}
}

View File

@ -134,15 +134,16 @@ module.exports = function(Self) {
Self.signInValidate = async(user, userToken, token, ctx) => {
const [[key, value]] = Object.entries(Self.userUses(user));
const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
await Self.app.models.SignInLog.create({
userName: user,
token: token.id,
userFk: userToken.id,
ip: ctx.req.ip,
owner: isOwner
});
if (!isOwner)
throw new UserError('Try again');
if (!isOwner) {
await Self.app.models.SignInLog.create({
userName: user,
token: token.id,
userFk: userToken.id,
ip: ctx.req.ip,
owner: isOwner
});
throw new UserError('Try again');
}
};
/**

View File

@ -1,4 +1,4 @@
RENAME TABLE `vn`.`clientCreditLimit` TO `vn`.`roleCreditLimit`;
ALTER TABLE `vn`.`clientCreditLimit` DROP FOREIGN KEY `clientCreditLimit_FK`;
ALTER TABLE `vn`.`roleCreditLimit` DROP FOREIGN KEY `clientCreditLimit_FK`;
ALTER TABLE `vn`.`roleCreditLimit` ADD CONSTRAINT `roleCreditLimit_FK` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1 @@
DELETE FROM `account`.`signInLog` where owner <> FALSE

View File

@ -1,6 +1,9 @@
CREATE SCHEMA IF NOT EXISTS `vn2008`;
USE `vn`;
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`ticketState`
VIEW `ticketState`
AS SELECT `tt`.`created` AS `updated`,
`tt`.`stateFk` AS `stateFk`,
`tt`.`userFk` AS `workerFk`,
@ -15,10 +18,10 @@ AS SELECT `tt`.`created` AS `updated`,
`s`.`isPicked` AS `isPicked`
FROM (
(
`vn`.`ticketLastState` `tls`
JOIN `vn`.`ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
`ticketLastState` `tls`
JOIN `ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
)
JOIN `vn`.`state` `s` ON(`s`.`id` = `tt`.`stateFk`)
JOIN `state` `s` ON(`s`.`id` = `tt`.`stateFk`)
);
CREATE OR REPLACE DEFINER=`root`@`localhost`
@ -33,9 +36,10 @@ AS SELECT `tt`.`id` AS `inter_id`,
`tt`.`supervisorFk` AS `Id_supervisor`
FROM `vn`.`ticketTracking` `tt`;
CREATE OR REPLACE
ALGORITHM = UNDEFINED VIEW `ticketStateToday` AS
SELECT
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `ticketStateToday`
AS SELECT
`ts`.`ticket` AS `ticket`,
`ts`.`state` AS `state`,
`ts`.`productionOrder` AS `productionOrder`,

View File

@ -0,0 +1,10 @@
-- vn.docuwareTablet definition
CREATE TABLE `vn`.`docuwareTablet` (
`tablet` varchar(100) NOT NULL PRIMARY KEY,
`description` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
ALTER TABLE `vn`.`userConfig`
ADD COLUMN tabletFk varchar(100) DEFAULT NULL,
ADD FOREIGN KEY (tabletFk) REFERENCES `vn`.`docuwareTablet`(tablet);

View File

@ -3009,3 +3009,8 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
(1, 'Error in VAT calculation'),
(2, 'Error in sales details'),
(3, 'Error in customer data');
INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
VALUES
('Tablet1','Jarvis tablet'),
('Tablet2','Avengers tablet');

View File

@ -26391,6 +26391,7 @@ CREATE TABLE `cplusCorrectingType` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `cplusRectificationType`
--

View File

@ -329,5 +329,6 @@
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}"
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada"
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "salix-back",
"version": "23.50.01",
"version": "24.02.01",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "salix-back",
"version": "23.50.01",
"version": "24.02.01",
"license": "GPL-3.0",
"dependencies": {
"axios": "^1.2.2",

View File

@ -1,6 +1,6 @@
{
"name": "salix-back",
"version": "23.52.01",
"version": "24.02.01",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",