diff --git a/CHANGELOG.md b/CHANGELOG.md
index 913b9c487..42abaa06c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,18 +5,33 @@ 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).
-## [2322.01] - 2023-06-08
+## [2324.01] - 2023-06-08
+
+### Added
+-
+
+
+### Changed
+-
+
+### Fixed
+-
+
+
+
+## [2322.01] - 2023-06-01
### Added
- (Tickets -> Crear Factura) Al facturar se envia automáticamente el pdf al cliente
-
-
+- (Artículos -> Histórico) Filtro para mostrar lo anterior al inventario
+- (Trabajadores -> Nuevo trabajador) Permite elegir el método de pago
### Changed
- (Trabajadores -> Nuevo trabajador) Los clientes se crean sin 'TR' pero se añade tipo de negocio 'Trabajador'
- (Tickets -> Expediciones) Interfaz mejorada y contador añadido
### Fixed
- (Tickets -> Líneas) Se permite hacer split de líneas al mismo ticket
+- (Tickets -> Cambiar estado) Ahora muestra la lista completa de todos los estados
@@ -39,10 +54,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- (Usuarios -> Histórico) Nueva sección
- (Roles -> Histórico) Nueva sección
-- (General -> Traducciones) Correo de bienvenida a clientes al portugués y al francés
+- (Trabajadores -> Dar de alta) Permite elegir el método de pago
### Changed
- (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral
+- (Trabajadores -> Dar de alta) Quitada obligatoriedad del iban
### Fixed
- (Ticket -> Boxing) Arreglado selección de horas
diff --git a/back/methods/docuware/deliveryNoteEmail.js b/back/methods/docuware/deliveryNoteEmail.js
index 1497dcdf9..1557a3a87 100644
--- a/back/methods/docuware/deliveryNoteEmail.js
+++ b/back/methods/docuware/deliveryNoteEmail.js
@@ -58,7 +58,10 @@ module.exports = Self => {
for (const param in args)
params[param] = args[param];
- if (!recipient) params.recipient = models.Client.findById(recipientId, {fields: ['email']});
+ if (!recipient) {
+ client = await models.Client.findById(recipientId, {fields: ['email']});
+ params.recipient = client.email;
+ }
const email = new Email('delivery-note', params);
diff --git a/back/methods/edi/sql/item.sql b/back/methods/edi/sql/item.sql
index 8d794c7cf..cd1bef88d 100644
--- a/back/methods/edi/sql/item.sql
+++ b/back/methods/edi/sql/item.sql
@@ -1,9 +1,9 @@
LOAD DATA LOCAL INFILE ?
INTO TABLE `edi`.`item`
+ CHARACTER SET ascii
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12)
- SET
- id = @col2,
+ SET id = @col2,
product_name = @col4,
name = @col5,
plant_id = @col7,
@@ -11,3 +11,4 @@ LOAD DATA LOCAL INFILE ?
entry_date = STR_TO_DATE(@col10, '%Y%m%d'),
expiry_date = IFNULL(NULL,STR_TO_DATE(@col11, '%Y%m%d')),
change_date_time = STR_TO_DATE(@col12, '%Y%m%d%H%i')
+
\ No newline at end of file
diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js
index 232695f4e..1057be39b 100644
--- a/back/methods/edi/updateData.js
+++ b/back/methods/edi/updateData.js
@@ -3,236 +3,237 @@ const path = require('path');
const fs = require('fs-extra');
module.exports = Self => {
- Self.remoteMethodCtx('updateData', {
- description: 'Updates schema data from external provider',
- accessType: 'WRITE',
- returns: {
- type: 'object',
- root: true
- },
- http: {
- path: `/updateData`,
- verb: 'POST'
- }
- });
+ Self.remoteMethodCtx('updateData', {
+ description: 'Updates schema data from external provider',
+ accessType: 'WRITE',
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/updateData`,
+ verb: 'POST'
+ }
+ });
- Self.updateData = async() => {
- const models = Self.app.models;
+ Self.updateData = async() => {
+ const models = Self.app.models;
- // Get files checksum
- const tx = await Self.beginTransaction({});
+ // Get files checksum
+ const tx = await Self.beginTransaction({});
- try {
- const options = {transaction: tx};
- const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
+ try {
+ const options = {transaction: tx};
+ const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
- const updatableFiles = [];
- for (const file of files) {
- const fileChecksum = await getChecksum(file);
+ const updatableFiles = [];
+ for (const file of files) {
+ const fileChecksum = await getChecksum(file);
- if (file.checksum != fileChecksum) {
- updatableFiles.push({
- name: file.name,
- checksum: fileChecksum
- });
- } else
- console.debug(`File already updated, skipping...`);
- }
+ if (file.checksum != fileChecksum) {
+ updatableFiles.push({
+ name: file.name,
+ checksum: fileChecksum
+ });
+ } else
+ console.debug(`File already updated, skipping...`);
+ }
- if (updatableFiles.length === 0)
- return false;
+ if (updatableFiles.length === 0)
+ return false;
- // Download files
- const container = await models.TempContainer.container('edi');
- const tempPath = path.join(container.client.root, container.name);
+ // Download files
+ const container = await models.TempContainer.container('edi');
+ const tempPath = path.join(container.client.root, container.name);
- let remoteFile;
- let tempDir;
- let tempFile;
+ let remoteFile;
+ let tempDir;
+ let tempFile;
- const fileNames = updatableFiles.map(file => file.name);
+ const fileNames = updatableFiles.map(file => file.name);
- const tables = await Self.rawSql(`
- SELECT fileName, toTable, file
- FROM edi.tableConfig
- WHERE file IN (?)`, [fileNames], options);
+ const tables = await Self.rawSql(`
+ SELECT fileName, toTable, file
+ FROM edi.tableConfig
+ WHERE file IN (?)`, [fileNames], options);
- for (const table of tables) {
- const fileName = table.file;
+ for (const table of tables) {
+ const fileName = table.file;
- remoteFile = `codes/${fileName}.ZIP`;
- tempDir = `${tempPath}/${fileName}`;
- tempFile = `${tempPath}/${fileName}.zip`;
+ remoteFile = `codes/${fileName}.ZIP`;
+ tempDir = `${tempPath}/${fileName}`;
+ tempFile = `${tempPath}/${fileName}.zip`;
- try {
- await fs.readFile(tempFile);
- } catch (error) {
- if (error.code === 'ENOENT') {
- console.debug(`Downloading file ${fileName}...`);
- const downloadOutput = await downloadFile(remoteFile, tempFile);
- if (downloadOutput.error)
- continue;
- }
- }
+ try {
+ await fs.readFile(tempFile);
+ } catch (error) {
+ if (error.code === 'ENOENT') {
+ console.debug(`Downloading file ${fileName}...`);
+ const downloadOutput = await downloadFile(remoteFile, tempFile);
+ if (downloadOutput.error)
+ continue;
+ }
+ }
- await extractFile(fileName, tempFile, tempDir);
+ await extractFile(fileName, tempFile, tempDir);
- console.debug(`Updating table ${table.toTable}...`);
- await dumpData(tempDir, table, options);
- }
+ console.debug(`Updating table ${table.toTable}...`);
+ await dumpData(tempDir, table, options);
+ }
- // Update files checksum
- for (const file of updatableFiles) {
- console.log(`Updating file ${file.name} checksum...`);
- await Self.rawSql(`
- UPDATE edi.fileConfig
- SET checksum = ?
- WHERE name = ?`,
- [file.checksum, file.name], options);
- }
+ // Update files checksum
+ for (const file of updatableFiles) {
+ console.log(`Updating file ${file.name} checksum...`);
+ await Self.rawSql(`
+ UPDATE edi.fileConfig
+ SET checksum = ?
+ WHERE name = ?`,
+ [file.checksum, file.name], options);
+ }
- await tx.commit();
+ await tx.commit();
- // Clean files
- try {
- console.debug(`Cleaning files...`);
- await fs.remove(tempPath);
- } catch (error) {
- if (error.code !== 'ENOENT')
- throw e;
- }
+ // Clean files
+ try {
+ console.debug(`Cleaning files...`);
+ await fs.remove(tempPath);
+ } catch (error) {
+ if (error.code !== 'ENOENT')
+ throw e;
+ }
- return true;
- } catch (error) {
- await tx.rollback();
- throw error;
- }
- };
+ return true;
+ } catch (error) {
+ await tx.rollback();
+ throw error;
+ }
+ };
- let ftpClient;
- async function getFtpClient() {
- if (!ftpClient) {
- const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig');
- console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`);
+ let ftpClient;
+ async function getFtpClient() {
+ if (!ftpClient) {
+ const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig');
+ console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`);
- const FtpClient = require('ftps');
+ const FtpClient = require('ftps');
- ftpClient = new FtpClient({
- host: ftpConfig.host,
- username: ftpConfig.user,
- password: ftpConfig.password,
- procotol: 'ftp'
- });
- }
+ ftpClient = new FtpClient({
+ host: ftpConfig.host,
+ username: ftpConfig.user,
+ password: ftpConfig.password,
+ procotol: 'ftp',
+ additionalLftpCommands: 'set ssl:verify-certificate no'
+ });
+ }
- return ftpClient;
- }
+ return ftpClient;
+ }
- async function getChecksum(file) {
- const ftpClient = await getFtpClient();
- console.debug(`Checking checksum for file ${file.name}...`);
+ async function getChecksum(file) {
+ const ftpClient = await getFtpClient();
+ console.debug(`Checking checksum for file ${file.name}...`);
- ftpClient.cat(`codes/${file.name}.txt`);
+ ftpClient.cat(`codes/${file.name}.TXT`);
- const response = await new Promise((resolve, reject) => {
- ftpClient.exec((err, response) => {
- if (err || response.error) {
- console.debug(`Error downloading checksum file... ${response.error}`);
- return reject(err);
- }
+ const response = await new Promise((resolve, reject) => {
+ ftpClient.exec((err, response) => {
+ if (err || response.error) {
+ console.debug(`Error downloading checksum file... ${response.error}`);
+ return reject(err);
+ }
- resolve(response);
- });
- });
+ resolve(response);
+ });
+ });
- if (response && response.data) {
- const fileContents = response.data;
- const rows = fileContents.split('\n');
- const row = rows[4];
- const columns = row.split(/\s+/);
+ if (response && response.data) {
+ const fileContents = response.data;
+ const rows = fileContents.split('\n');
+ const row = rows[4];
+ const columns = row.split(/\s+/);
- let fileChecksum;
- if (file.keyValue)
- fileChecksum = columns[1];
+ let fileChecksum;
+ if (file.keyValue)
+ fileChecksum = columns[1];
- if (!file.keyValue)
- fileChecksum = columns[0];
+ if (!file.keyValue)
+ fileChecksum = columns[0];
- return fileChecksum;
- }
- }
+ return fileChecksum;
+ }
+ }
- async function downloadFile(remoteFile, tempFile) {
- const ftpClient = await getFtpClient();
+ async function downloadFile(remoteFile, tempFile) {
+ const ftpClient = await getFtpClient();
- ftpClient.get(remoteFile, tempFile);
+ ftpClient.get(remoteFile, tempFile);
- return new Promise((resolve, reject) => {
- ftpClient.exec((err, response) => {
- if (err || response.error) {
- console.debug(`Error downloading file... ${response.error}`);
- return reject(err);
- }
+ return new Promise((resolve, reject) => {
+ ftpClient.exec((err, response) => {
+ if (err || response.error) {
+ console.debug(`Error downloading file... ${response.error}`);
+ return reject(err);
+ }
- resolve(response);
- });
- });
- }
+ resolve(response);
+ });
+ });
+ }
- async function extractFile(fileName, tempFile, tempDir) {
- const JSZip = require('jszip');
+ async function extractFile(fileName, tempFile, tempDir) {
+ const JSZip = require('jszip');
- try {
- await fs.mkdir(tempDir);
- console.debug(`Extracting file ${fileName}...`);
- } catch (error) {
- if (error.code !== 'EEXIST')
- throw e;
- }
+ try {
+ await fs.mkdir(tempDir);
+ console.debug(`Extracting file ${fileName}...`);
+ } catch (error) {
+ if (error.code !== 'EEXIST')
+ throw e;
+ }
- const fileStream = await fs.readFile(tempFile);
- if (fileStream) {
- const zip = new JSZip();
- const zipContents = await zip.loadAsync(fileStream);
+ const fileStream = await fs.readFile(tempFile);
+ if (fileStream) {
+ const zip = new JSZip();
+ const zipContents = await zip.loadAsync(fileStream);
- if (!zipContents) return;
+ if (!zipContents) return;
- const fileNames = Object.keys(zipContents.files);
+ const fileNames = Object.keys(zipContents.files);
- for (const fileName of fileNames) {
- const fileContent = await zip.file(fileName).async('nodebuffer');
- const dest = path.join(tempDir, fileName);
- await fs.writeFile(dest, fileContent);
- }
- }
- }
+ for (const fileName of fileNames) {
+ const fileContent = await zip.file(fileName).async('nodebuffer');
+ const dest = path.join(tempDir, fileName);
+ await fs.writeFile(dest, fileContent);
+ }
+ }
+ }
- async function dumpData(tempDir, table, options) {
- const toTable = table.toTable;
- const baseName = table.fileName;
+ async function dumpData(tempDir, table, options) {
+ const toTable = table.toTable;
+ const baseName = table.fileName;
- console.log(`Emptying table ${toTable}...`);
- const tableName = `edi.${toTable}`;
- await Self.rawSql(`DELETE FROM ??`, [tableName]);
+ console.log(`Emptying table ${toTable}...`);
+ const tableName = `edi.${toTable}`;
+ await Self.rawSql(`DELETE FROM ??`, [tableName]);
- const dirFiles = await fs.readdir(tempDir);
- const files = dirFiles.filter(file => file.startsWith(baseName));
+ const dirFiles = await fs.readdir(tempDir);
+ const files = dirFiles.filter(file => file.startsWith(baseName));
- for (const file of files) {
- console.log(`Dumping data from file ${file}...`);
+ for (const file of files) {
+ console.log(`Dumping data from file ${file}...`);
- const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
- const sqlTemplate = await fs.readFile(templatePath, 'utf8');
- const filePath = path.join(tempDir, file);
+ const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
+ const sqlTemplate = await fs.readFile(templatePath, 'utf8');
+ const filePath = path.join(tempDir, file);
- await Self.rawSql(sqlTemplate, [filePath], options);
- await Self.rawSql(`
- UPDATE edi.tableConfig
- SET updated = ?
- WHERE fileName = ?
- `, [Date.vnNew(), baseName], options);
- }
+ await Self.rawSql(sqlTemplate, [filePath], options);
+ await Self.rawSql(`
+ UPDATE edi.tableConfig
+ SET updated = ?
+ WHERE fileName = ?
+ `, [Date.vnNew(), baseName], options);
+ }
- console.log(`Updated table ${toTable}\n`);
- }
+ console.log(`Updated table ${toTable}\n`);
+ }
};
diff --git a/back/methods/image/download.js b/back/methods/image/download.js
index 3a8bcf30e..c4037b809 100644
--- a/back/methods/image/download.js
+++ b/back/methods/image/download.js
@@ -67,7 +67,7 @@ module.exports = Self => {
if (!image) return false;
- const hasReadRole = models.ImageCollection.hasReadRole(ctx, collection);
+ const hasReadRole = await models.ImageCollection.hasReadRole(ctx, collection);
if (!hasReadRole)
throw new UserError(`You don't have enough privileges`);
diff --git a/back/models/dms-type.json b/back/models/dms-type.json
index c7a1815fe..de3d564b4 100644
--- a/back/models/dms-type.json
+++ b/back/models/dms-type.json
@@ -44,4 +44,4 @@
"principalId": "$everyone",
"permission": "ALLOW"
}]
-}
\ No newline at end of file
+}
diff --git a/back/models/image-collection.js b/back/models/image-collection.js
index 2c4d274ee..69905beca 100644
--- a/back/models/image-collection.js
+++ b/back/models/image-collection.js
@@ -9,10 +9,11 @@ module.exports = Self => {
* @return {boolean} True for user with read privileges
*/
Self.hasReadRole = async(ctx, name, options) => {
- const collection = await Self.findOne({where: {name}}, {
+ const collection = await Self.findOne({
include: {
relation: 'readRole'
- }
+ },
+ where: {name}
}, options);
return await hasRole(ctx, collection, options);
diff --git a/db/changes/230202/00-itemConfig.sql b/db/.archive/230202/00-itemConfig.sql
similarity index 100%
rename from db/changes/230202/00-itemConfig.sql
rename to db/.archive/230202/00-itemConfig.sql
diff --git a/db/changes/230401/00-ACL.sql b/db/.archive/230401/00-ACL.sql
similarity index 100%
rename from db/changes/230401/00-ACL.sql
rename to db/.archive/230401/00-ACL.sql
diff --git a/db/changes/230401/00-ACL_tag_update.sql b/db/.archive/230401/00-ACL_tag_update.sql
similarity index 100%
rename from db/changes/230401/00-ACL_tag_update.sql
rename to db/.archive/230401/00-ACL_tag_update.sql
diff --git a/db/changes/230401/00-createWorker.sql b/db/.archive/230401/00-createWorker.sql
similarity index 100%
rename from db/changes/230401/00-createWorker.sql
rename to db/.archive/230401/00-createWorker.sql
diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/.archive/230401/00-ticket_canAdvance.sql
similarity index 100%
rename from db/changes/230401/00-ticket_canAdvance.sql
rename to db/.archive/230401/00-ticket_canAdvance.sql
diff --git a/db/changes/230401/00-updateIsToBeMailed.sql b/db/.archive/230401/00-updateIsToBeMailed.sql
similarity index 100%
rename from db/changes/230401/00-updateIsToBeMailed.sql
rename to db/.archive/230401/00-updateIsToBeMailed.sql
diff --git a/db/changes/230403/00-clienteCompensado.sql b/db/.archive/230403/00-clienteCompensado.sql
similarity index 100%
rename from db/changes/230403/00-clienteCompensado.sql
rename to db/.archive/230403/00-clienteCompensado.sql
diff --git a/db/changes/230404/00-ticket_canAdvance.sql b/db/.archive/230404/00-ticket_canAdvance.sql
similarity index 100%
rename from db/changes/230404/00-ticket_canAdvance.sql
rename to db/.archive/230404/00-ticket_canAdvance.sql
diff --git a/db/changes/230601/00-acl_claim.sql b/db/.archive/230601/00-acl_claim.sql
similarity index 100%
rename from db/changes/230601/00-acl_claim.sql
rename to db/.archive/230601/00-acl_claim.sql
diff --git a/db/changes/230601/00-acl_notifications.sql b/db/.archive/230601/00-acl_notifications.sql
similarity index 100%
rename from db/changes/230601/00-acl_notifications.sql
rename to db/.archive/230601/00-acl_notifications.sql
diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/.archive/230601/00-itemConfig_warehouseFk.sql
similarity index 100%
rename from db/changes/230601/00-itemConfig_warehouseFk.sql
rename to db/.archive/230601/00-itemConfig_warehouseFk.sql
diff --git a/db/changes/230601/00-uniqueKeyNotificationSubscription.sql b/db/.archive/230601/00-uniqueKeyNotificationSubscription.sql
similarity index 100%
rename from db/changes/230601/00-uniqueKeyNotificationSubscription.sql
rename to db/.archive/230601/00-uniqueKeyNotificationSubscription.sql
diff --git a/db/changes/230601/01-alter_notSubs.sql b/db/.archive/230601/01-alter_notSubs.sql
similarity index 100%
rename from db/changes/230601/01-alter_notSubs.sql
rename to db/.archive/230601/01-alter_notSubs.sql
diff --git a/db/changes/230801/00-acl_itemConfig.sql b/db/.archive/230801/00-acl_itemConfig.sql
similarity index 100%
rename from db/changes/230801/00-acl_itemConfig.sql
rename to db/.archive/230801/00-acl_itemConfig.sql
diff --git a/db/changes/230801/00-supplierIsVies.sql b/db/.archive/230801/00-supplierIsVies.sql
similarity index 100%
rename from db/changes/230801/00-supplierIsVies.sql
rename to db/.archive/230801/00-supplierIsVies.sql
diff --git a/db/changes/230801/00-workerLocker.sql b/db/.archive/230801/00-workerLocker.sql
similarity index 100%
rename from db/changes/230801/00-workerLocker.sql
rename to db/.archive/230801/00-workerLocker.sql
diff --git a/db/changes/230801/01-sage_supplierAdd.sql b/db/.archive/230801/01-sage_supplierAdd.sql
similarity index 100%
rename from db/changes/230801/01-sage_supplierAdd.sql
rename to db/.archive/230801/01-sage_supplierAdd.sql
diff --git a/db/changes/231001/00-delivery.sql b/db/.archive/231001/00-delivery.sql
similarity index 100%
rename from db/changes/231001/00-delivery.sql
rename to db/.archive/231001/00-delivery.sql
diff --git a/db/changes/231001/00-invoiceOut.sql b/db/.archive/231001/00-invoiceOut.sql
similarity index 100%
rename from db/changes/231001/00-invoiceOut.sql
rename to db/.archive/231001/00-invoiceOut.sql
diff --git a/db/changes/231001/00-invoiceOut_getWeight.sql b/db/.archive/231001/00-invoiceOut_getWeight.sql
similarity index 100%
rename from db/changes/231001/00-invoiceOut_getWeight.sql
rename to db/.archive/231001/00-invoiceOut_getWeight.sql
diff --git a/db/changes/231001/00-report.sql b/db/.archive/231001/00-report.sql
similarity index 100%
rename from db/changes/231001/00-report.sql
rename to db/.archive/231001/00-report.sql
diff --git a/db/changes/231001/01-invoiceOut_getMaxIssued.sql b/db/.archive/231001/01-invoiceOut_getMaxIssued.sql
similarity index 100%
rename from db/changes/231001/01-invoiceOut_getMaxIssued.sql
rename to db/.archive/231001/01-invoiceOut_getMaxIssued.sql
diff --git a/db/changes/231001/02-invoiceOut_new.sql b/db/.archive/231001/02-invoiceOut_new.sql
similarity index 100%
rename from db/changes/231001/02-invoiceOut_new.sql
rename to db/.archive/231001/02-invoiceOut_new.sql
diff --git a/db/changes/231001/03-ticketPackaging_add.sql b/db/.archive/231001/03-ticketPackaging_add.sql
similarity index 100%
rename from db/changes/231001/03-ticketPackaging_add.sql
rename to db/.archive/231001/03-ticketPackaging_add.sql
diff --git a/db/changes/231201/00-wagon.sql b/db/changes/231201/00-wagon.sql
index 3e4d225d7..9e817bac4 100644
--- a/db/changes/231201/00-wagon.sql
+++ b/db/changes/231201/00-wagon.sql
@@ -56,8 +56,6 @@ CREATE TABLE `vn`.`collectionWagonTicket` (
ALTER TABLE `vn`.`wagon` ADD `typeFk` int(11) unsigned NOT NULL;
ALTER TABLE `vn`.`wagon` ADD `label` int(11) unsigned NOT NULL;
-ALTER TABLE `vn`.`wagon` ADD CONSTRAINT `wagon_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE;
-
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('WagonType', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
@@ -70,3 +68,4 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
('WagonType', 'createWagonType', '*', 'ALLOW', 'ROLE', 'productionAssi'),
('WagonType', 'deleteWagonType', '*', 'ALLOW', 'ROLE', 'productionAssi'),
('WagonType', 'editWagonType', '*', 'ALLOW', 'ROLE', 'productionAssi');
+
diff --git a/db/changes/231801/00-client_setRatingAcl.sql b/db/changes/231801/00-client_setRatingAcl.sql
index b041b131a..6687b11ec 100644
--- a/db/changes/231801/00-client_setRatingAcl.sql
+++ b/db/changes/231801/00-client_setRatingAcl.sql
@@ -27,7 +27,6 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('Client', 'summary', '*', 'ALLOW', 'ROLE', 'employee'),
('Client', 'updateAddress', '*', 'ALLOW', 'ROLE', 'employee'),
('Client', 'updateFiscalData', '*', 'ALLOW', 'ROLE', 'employee'),
- ('Client', 'updateUser', '*', 'ALLOW', 'ROLE', 'employee'),
('Client', 'uploadFile', '*', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsPdf', '*', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsEmail', '*', 'ALLOW', 'ROLE', 'employee'),
diff --git a/db/changes/232001/00-wagon.sql b/db/changes/232001/00-wagon.sql
new file mode 100644
index 000000000..bdb384db5
--- /dev/null
+++ b/db/changes/232001/00-wagon.sql
@@ -0,0 +1 @@
+ALTER TABLE `vn`.`wagon` ADD CONSTRAINT `wagon_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE;
diff --git a/db/changes/232001/00-procedurecanAdvance.sql b/db/changes/232201/00-procedurecanAdvance.sql
similarity index 100%
rename from db/changes/232001/00-procedurecanAdvance.sql
rename to db/changes/232201/00-procedurecanAdvance.sql
diff --git a/db/changes/232001/00-procedurecanbePostponed.sql b/db/changes/232201/00-procedurecanbePostponed.sql
similarity index 100%
rename from db/changes/232001/00-procedurecanbePostponed.sql
rename to db/changes/232201/00-procedurecanbePostponed.sql
diff --git a/db/changes/232201/00-workerConfigPayMethod.sql b/db/changes/232201/00-workerConfigPayMethod.sql
new file mode 100644
index 000000000..8896f636d
--- /dev/null
+++ b/db/changes/232201/00-workerConfigPayMethod.sql
@@ -0,0 +1,7 @@
+ALTER TABLE `vn`.`workerConfig` ADD payMethodFk tinyint(3) unsigned NULL;
+ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK FOREIGN KEY (roleFk) REFERENCES account.`role`(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK_1 FOREIGN KEY (payMethodFk) REFERENCES `vn`.`payMethod`(id) ON DELETE SET NULL ON UPDATE CASCADE;
+
+UPDATE `vn`.`workerConfig`
+ SET payMethodFk = 4
+ WHERE id=1;
diff --git a/db/changes/232201/.gitkeep b/db/changes/232401/.gitkeep
similarity index 100%
rename from db/changes/232201/.gitkeep
rename to db/changes/232401/.gitkeep
diff --git a/db/changes/232401/00-buyConfig_travelConfig.sql b/db/changes/232401/00-buyConfig_travelConfig.sql
new file mode 100644
index 000000000..0f73ddc8c
--- /dev/null
+++ b/db/changes/232401/00-buyConfig_travelConfig.sql
@@ -0,0 +1,28 @@
+CREATE TABLE `vn`.`buyConfig` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `monthsAgo` int(11) NOT NULL DEFAULT 6 COMMENT 'Meses desde la última compra',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+CREATE TABLE `vn`.`travelConfig` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen',
+ `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino',
+ `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto',
+ `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto',
+ PRIMARY KEY (`id`),
+ KEY `travelConfig_FK` (`warehouseInFk`),
+ KEY `travelConfig_FK_1` (`warehouseOutFk`),
+ KEY `travelConfig_FK_2` (`agencyFk`),
+ KEY `travelConfig_FK_3` (`companyFk`),
+ CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`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
+ ('Entry', 'addFromPackaging', 'WRITE', 'ALLOW', 'ROLE', 'production'),
+ ('Entry', 'addFromBuy', 'WRITE', 'ALLOW', 'ROLE', 'production'),
+ ('Supplier', 'getItemsPackaging', 'READ', 'ALLOW', 'ROLE', 'production');
diff --git a/db/changes/232401/00-useSpecificsAcls.sql b/db/changes/232401/00-useSpecificsAcls.sql
new file mode 100644
index 000000000..0d17ca948
--- /dev/null
+++ b/db/changes/232401/00-useSpecificsAcls.sql
@@ -0,0 +1,121 @@
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'),
+ ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryBoss'),
+ ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'),
+ ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
+ ('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'),
+ ('State', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('State', 'isSomeEditable', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('State', 'isAllEditable', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('State', 'isAllEditable', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Agency', 'seeExpired', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Agency', 'seeExpired', 'READ', 'ALLOW', 'ROLE', 'productionBoss'),
+ ('Claim', 'createAfterDeadline', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Client', 'editAddressLogifloraAllowed', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
+ ('Client', 'editFiscalDataWithoutTaxDataCheck', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
+ ('Client', 'editVerifiedDataWithoutTaxDataCheck', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
+ ('Client', 'editCredit', 'WRITE', 'ALLOW', 'ROLE', 'financialBoss'),
+ ('Client', 'isNotEditableCredit', 'WRITE', 'ALLOW', 'ROLE', 'financialBoss'),
+ ('InvoiceOut', 'canCreatePdf', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'),
+ ('Supplier', 'editPayMethodCheck', 'WRITE', 'ALLOW', 'ROLE', 'financial'),
+ ('Worker', 'isTeamBoss', 'WRITE', 'ALLOW', 'ROLE', 'teamBoss'),
+ ('Worker', 'forceIsSubordinate', 'READ', 'ALLOW', 'ROLE', 'hr'),
+ ('Claim', 'editState', 'WRITE', 'ALLOW', 'ROLE', 'claimManager');
+
+DELETE FROM `salix`.`ACL`
+ WHERE
+ model = 'Claim'
+ AND property = '*'
+ AND accessType = '*';
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('Claim', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'findById', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'findOne', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'getSummary', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'updateClaim', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'regularizeClaim', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Claim', 'updateClaimDestination', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Claim', 'downloadFile', 'READ', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Claim', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
+ ('Claim', 'filter', 'READ', 'ALLOW', 'ROLE', 'salesPerson'),
+ ('Claim', 'logs', 'READ', 'ALLOW', 'ROLE', 'claimManager');
+
+DELETE FROM `salix`.`ACL`
+ WHERE
+ model = 'Ticket'
+ AND property = '*'
+ AND accessType = '*';
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('Ticket', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'getVolume', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'getTotalVolume', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'priceDifference', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'componentUpdate', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'new', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'isEditable', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'setDeleted', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'restore', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'getSales', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'getSalesPersonMana', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'makeInvoice', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'updateEditableTicket', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'updateDiscount', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'transferSales', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'sendSms', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'isLocked', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'freightCost', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'getComponentsSum', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Ticket', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'delivery'), -- Change Priority in Route tickets
+ ('Ticket', 'deliveryNoteCsv', 'READ', 'ALLOW', 'ROLE', 'employee');
+
+DELETE FROM `salix`.`ACL`
+ WHERE
+ model = 'State'
+ AND property = '*'
+ AND accessType = 'READ';
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('State', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('State', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('State', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee');
+
+DELETE FROM `salix`.`ACL`
+ WHERE
+ model = 'Worker'
+ AND property = '*'
+ AND accessType = 'READ';
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('Worker', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'getWorkedHours', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'active', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'activeWithRole', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
+ ('Worker', 'contracts', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'holidays', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'activeContract', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('Worker', 'activeWithInheritedRole', 'READ', 'ALLOW', 'ROLE', 'employee');
+
+DELETE FROM `salix`.`ACL`
+ WHERE model = 'Client'
+ AND property = 'updateUser'
+ AND accessType = '*';
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 9f06de5b0..279de67ae 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -905,7 +905,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
VALUES
- (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15,3),
+ (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3),
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2),
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5),
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
@@ -2332,26 +2332,26 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
VALUES
- (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'),
- (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'),
- (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'),
- (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'),
- (5, 'Otros', 'otros', 1, 1, 'miscellaneous'),
- (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'),
- (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'),
- (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'),
- (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'),
- (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'),
- (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'),
- (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'),
- (13, 'Basura', 'basura', 1, 1, 'trash'),
- (14, 'Ticket', 'tickets', 1, 1, 'ticket'),
- (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'),
- (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
- (17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
- (18, 'dua', 'dua', NULL, NULL, 'dua'),
- (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'),
- (20, 'Reclamación', 'reclamacion', 1, 1, 'claim');
+ (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'),
+ (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'),
+ (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'),
+ (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'),
+ (5, 'Otros', 'otros', 1, 1, 'miscellaneous'),
+ (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'),
+ (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'),
+ (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'),
+ (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'),
+ (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'),
+ (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'),
+ (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'),
+ (13, 'Basura', 'basura', 1, 1, 'trash'),
+ (14, 'Ticket', 'tickets', 1, 1, 'ticket'),
+ (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'),
+ (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
+ (17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
+ (18, 'dua', 'dua', NULL, NULL, 'dua'),
+ (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'),
+ (20, 'Reclamación', 'reclamacion', 1, 1, 'claim');
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
@@ -2824,9 +2824,9 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
VALUES
(1, 1);
-INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `businessTypeFk`)
+INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`)
VALUES
- (1, NULL, 1, 'worker');
+ (1, NULL, 1, 4, 'worker');
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
VALUES
@@ -2886,6 +2886,10 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
(2, 1, 50, 2),
(3, 1, 0, 3);
+INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
+ VALUES
+ (1, 1, 1, 1, 442);
-
-
+INSERT INTO `vn`.`buyConfig` (`id`, `monthsAgo`)
+ VALUES
+ (1, 6);
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index aff6e5f8f..3ce7f7bb5 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -61943,141 +61943,204 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`(vItemFk int, vWarehouseFk int, vDate DATETIME)
BEGIN
- DECLARE vDateInventory DATETIME;
- DECLARE vCurdate DATE DEFAULT util.VN_CURDATE();
- DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate);
+/**
+ * @vItemFk item a buscar
+ * @vWarehouseFk almacen donde buscar
+ * @vDate Si la fecha es null, muestra el histórico desde el inventario. Si la fecha no es null, muestra histórico desde la fecha pasada.
+ */
+ DECLARE vDateInventory DATETIME;
+ DECLARE vInvCalculated INT;
- SELECT inventoried INTO vDateInventory FROM config;
- SET @a = 0;
- SET @currentLineFk = 0;
- SET @shipped = '';
+ IF vDate IS NULL THEN
+ SELECT inventoried INTO vDateInventory
+ FROM config;
+ ELSE
+ SELECT mockUtcTime INTO vDateInventory
+ FROM util.config;
+ END IF;
- SELECT DATE(@shipped:= shipped) shipped,
- alertLevel,
- stateName,
- origin,
- reference,
- clientFk,
- name,
- `in` AS invalue,
- `out`,
- @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
- @currentLineFk := IF (@shipped < util.VN_CURDATE()
- OR (@shipped = util.VN_CURDATE() AND (isPicked OR alertLevel >= 2)),
- lineFk,@currentLineFk) lastPreparedLineFk,
- isTicket,
- lineFk,
- isPicked,
- clientType,
- claimFk
- FROM
- ( SELECT tr.landed AS shipped,
- b.quantity AS `in`,
- NULL AS `out`,
- al.id AS alertLevel,
- st.name AS stateName,
- s.name AS name,
- e.invoiceNumber AS reference,
- e.id AS origin,
- s.id AS clientFk,
- IF(al.id = 3, TRUE, FALSE) isPicked,
- FALSE AS isTicket,
- b.id lineFk,
- NULL `order`,
- NULL AS clientType,
- NULL AS claimFk
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN supplier s ON s.id = e.supplierFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN tr.landed < util.VN_CURDATE() THEN 3
- WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
- ELSE 0
- END
- JOIN state st ON st.code = al.code
- WHERE tr.landed >= vDateInventory
- AND vWarehouse = tr.warehouseInFk
- AND b.itemFk = vItemId
- AND e.isExcludedFromAvailable = FALSE
- AND e.isRaid = FALSE
- UNION ALL
+ CREATE OR REPLACE TEMPORARY TABLE itemDiary(
+ shipped DATE,
+ `in` INT(11),
+ `out` INT(11),
+ alertLevel INT(11),
+ stateName VARCHAR(20),
+ `name` VARCHAR(50),
+ reference VARCHAR(50),
+ origin INT(11),
+ clientFk INT(11),
+ isPicked INT(11),
+ isTicket TINYINT(1),
+ lineFk INT(11),
+ `order` TINYINT(3) UNSIGNED,
+ clientType VARCHAR(20),
+ claimFk INT(10) UNSIGNED
+ );
- SELECT tr.shipped,
- NULL,
- b.quantity,
- al.id,
- st.name,
- s.name,
- e.invoiceNumber,
- e.id,
- s.id,
- IF(al.id = 3, TRUE, FALSE),
- FALSE,
- b.id,
- NULL,
- NULL,
- NULL
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN warehouse w ON w.id = tr.warehouseOutFk
- JOIN supplier s ON s.id = e.supplierFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN tr.shipped < util.VN_CURDATE() THEN 3
- WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
- ELSE 0
- END
- JOIN state st ON st.code = al.code
- WHERE tr.shipped >= vDateInventory
- AND vWarehouse =tr.warehouseOutFk
- AND s.id <> 4
- AND b.itemFk = vItemId
- AND e.isExcludedFromAvailable = FALSE
- AND w.isFeedStock = FALSE
- AND e.isRaid = FALSE
- UNION ALL
+ INSERT INTO itemDiary
+ SELECT tr.landed shipped,
+ b.quantity `in`,
+ NULL `out`,
+ al.id alertLevel,
+ st.name stateName,
+ s.name `name`,
+ e.invoiceNumber reference,
+ e.id origin,
+ s.id clientFk,
+ IF(al.code = 'DELIVERED', TRUE, FALSE) isPicked,
+ FALSE isTicket,
+ b.id lineFk,
+ NULL `order`,
+ NULL clientType,
+ NULL claimFk
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel tr ON tr.id = e.travelFk
+ JOIN supplier s ON s.id = e.supplierFk
+ JOIN alertLevel al ON al.code =
+ CASE
+ WHEN tr.landed < util.VN_CURDATE() THEN 'DELIVERED'
+ WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED'
+ ELSE 'FREE'
+ END
+ JOIN state st ON st.code = al.code
+ WHERE tr.landed >= vDateInventory
+ AND vWarehouseFk = tr.warehouseInFk
+ AND b.itemFk = vItemFk
+ AND e.isExcludedFromAvailable = FALSE
+ AND e.isRaid = FALSE
+ UNION ALL
+ SELECT tr.shipped,
+ NULL,
+ b.quantity,
+ al.id,
+ st.name,
+ s.name,
+ e.invoiceNumber,
+ e.id,
+ s.id,
+ IF(al.code = 'DELIVERED', TRUE, FALSE),
+ FALSE,
+ b.id,
+ NULL,
+ NULL,
+ NULL
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel tr ON tr.id = e.travelFk
+ JOIN warehouse w ON w.id = tr.warehouseOutFk
+ JOIN supplier s ON s.id = e.supplierFk
+ JOIN alertLevel al ON al.code =
+ CASE
+ WHEN tr.shipped < util.VN_CURDATE() THEN 'DELIVERED'
+ WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED'
+ ELSE 'FREE'
+ END
+ JOIN state st ON st.code = al.code
+ JOIN entryConfig ec
+ WHERE tr.shipped >= vDateInventory
+ AND vWarehouseFk =tr.warehouseOutFk
+ AND s.id <> ec.inventorySupplierFk
+ AND b.itemFk = vItemFk
+ AND e.isExcludedFromAvailable = FALSE
+ AND w.isFeedStock = FALSE
+ AND e.isRaid = FALSE
+ UNION ALL
+ SELECT DATE(t.shipped),
+ NULL,
+ s.quantity,
+ al3.id,
+ st.name,
+ t.nickname,
+ t.refFk,
+ t.id,
+ t.clientFk,
+ stk.id,
+ TRUE,
+ s.id,
+ st.`order`,
+ ct.code,
+ cb.claimFk
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ LEFT JOIN ticketState ts ON ts.ticket = t.id
+ LEFT JOIN state st ON st.code = ts.code
+ JOIN client c ON c.id = t.clientFk
+ JOIN clientType ct ON ct.id = c.clientTypeFk
+ JOIN alertLevel al ON al.code = 'DELIVERED'
+ JOIN alertLevel al2 ON al2.code = 'FREE'
+ JOIN alertLevel al3 ON al3.id =
+ CASE
+ WHEN t.shipped < util.VN_CURDATE() THEN al.code
+ WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN al2.code
+ ELSE IFNULL(ts.alertLevel, al2.code)
+ END
+ LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
+ LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
+ LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
+ WHERE t.shipped >= vDateInventory
+ AND s.itemFk = vItemFk
+ AND vWarehouseFk =t.warehouseFk
+ ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC;
- SELECT DATE(t.shipped),
- NULL,
- s.quantity,
- al.id,
- st.name,
- t.nickname,
- t.refFk,
- t.id,
- t.clientFk,
- stk.id,
- TRUE,
- s.id,
- st.`order`,
- ct.code,
- cb.claimFk
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- LEFT JOIN ticketState ts ON ts.ticket = t.id
- LEFT JOIN state st ON st.code = ts.code
- JOIN client c ON c.id = t.clientFk
- JOIN clientType ct ON ct.id = c.clientTypeFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN t.shipped < util.VN_CURDATE() THEN 3
- WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0
- ELSE IFNULL(ts.alertLevel, 0)
- END
- LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
- LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
- LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
- WHERE t.shipped >= vDateInventory
- AND s.itemFk = vItemId
- AND vWarehouse =t.warehouseFk
- ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC
- ) AS itemDiary;
+ IF vDate IS NULL THEN
+ SET @a = 0;
+ SET @currentLineFk = 0;
+ SET @shipped = '';
+ SELECT DATE(@shipped:= shipped) shipped,
+ alertLevel,
+ stateName,
+ origin,
+ reference,
+ clientFk,
+ name,
+ `in` AS invalue,
+ `out`,
+ @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
+ @currentLineFk := IF (@shipped < util.VN_CURDATE()
+ OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.code >= 'ON_PREPARATION')),
+ lineFk, @currentLineFk) lastPreparedLineFk,
+ isTicket,
+ lineFk,
+ isPicked,
+ clientType,
+ claimFk
+ FROM itemDiary
+ JOIN alertLevel a ON a.id = itemDiary.alertLevel;
+ ELSE
+ SELECT sum(`in`) - sum(`out`) INTO vInvCalculated
+ FROM itemDiary
+ WHERE shipped < vDate;
+
+ SELECT p1.*
+ FROM(
+ SELECT vDate shipped,
+ 0 alertLevel,
+ 0 stateName,
+ 0 origin,
+ '' reference,
+ 0 clientFk,
+ 'Inventario calculado',
+ vInvCalculated invalue,
+ NULL `out`,
+ 0 balance,
+ 0 lastPreparedLineFk,
+ 0 isTicket,
+ 0 lineFk,
+ 0 isPicked,
+ 0 clientType,
+ 0 claimFk
+ UNION ALL
+ SELECT shipped, alertlevel, stateName, origin, reference, clientFk, name, `in`, `out`, 0,0, isTicket, lineFk, isPicked, clientType, claimFk
+ FROM itemDiary
+ WHERE shipped >= vDate
+ )as p1;
+ END IF;
+
+ DROP TEMPORARY TABLE itemDiary;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
diff --git a/docker-compose.yml b/docker-compose.yml
index 13a7bc751..0d2db1a63 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -43,7 +43,7 @@ services:
- node.role == worker
resources:
limits:
- memory: 4G
+ memory: 8G
configs:
datasources:
external: true
diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js
index abd76b434..ac4f6cc02 100644
--- a/e2e/helpers/puppeteer.js
+++ b/e2e/helpers/puppeteer.js
@@ -22,7 +22,8 @@ export async function getBrowser() {
env.E2E_SHOW = true;
}
- const headless = !env.E2E_SHOW;
+ const headless = env.E2E_SHOW ? false : 'new';
+
const browser = await Puppeteer.launch({
args,
defaultViewport: null,
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 2e384fba6..db65c8ae1 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -625,6 +625,7 @@ export default {
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[ng-model="sale.checked"]',
thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[ng-model="sale.checked"]',
+ fourthSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(4) vn-check[ng-model="sale.checked"]',
deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]',
transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]',
moveToTicketInput: 'form vn-input-number[ng-model="$ctrl.transfer.ticketId"] input',
diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js
index 2158eec8b..2c9646708 100644
--- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js
+++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js
@@ -251,7 +251,6 @@ describe('Ticket Edit sale path', () => {
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
await page.waitToClick(selectors.globalItems.acceptButton);
- await page.waitToClick(selectors.globalItems.acceptButton);
await page.waitForState('claim.card.basicData');
});
diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js
index 758dc2ee3..9656ea656 100644
--- a/e2e/paths/06-claim/05_summary.spec.js
+++ b/e2e/paths/06-claim/05_summary.spec.js
@@ -17,7 +17,7 @@ describe('Claim summary path', () => {
});
it('should navigate to the target claim summary section', async() => {
- await page.loginAndModule('employee', 'claim');
+ await page.loginAndModule('salesPerson', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForState('claim.card.summary');
});
diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js
index 0826bad63..059bd68dd 100644
--- a/e2e/paths/06-claim/06_descriptor.spec.js
+++ b/e2e/paths/06-claim/06_descriptor.spec.js
@@ -16,7 +16,7 @@ describe('Claim descriptor path', () => {
});
it('should now navigate to the target claim summary section', async() => {
- await page.loginAndModule('employee', 'claim');
+ await page.loginAndModule('salesPerson', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForState('claim.card.summary');
});
diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js
index 80c6c79b2..891b769c9 100644
--- a/e2e/paths/13-supplier/03_fiscal_data.spec.js
+++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js
@@ -1,5 +1,20 @@
import getBrowser from '../../helpers/puppeteer';
+const $ = {
+ saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
+};
+const $inputs = {
+ province: 'vn-supplier-fiscal-data [name="province"]',
+ country: 'vn-supplier-fiscal-data [name="country"]',
+ postcode: 'vn-supplier-fiscal-data [name="postcode"]',
+ city: 'vn-supplier-fiscal-data [name="city"]',
+ socialName: 'vn-supplier-fiscal-data [name="socialName"]',
+ taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]',
+ account: 'vn-supplier-fiscal-data [name="account"]',
+ sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]',
+ sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]'
+};
+
describe('Supplier fiscal data path', () => {
let browser;
let page;
diff --git a/front/salix/components/descriptor/style.scss b/front/salix/components/descriptor/style.scss
index 27f482f26..b96e900c4 100644
--- a/front/salix/components/descriptor/style.scss
+++ b/front/salix/components/descriptor/style.scss
@@ -7,22 +7,24 @@ vn-descriptor-content {
.photo {
position: relative;
+ width: 100%;
+ text-align: center;
+ overflow: hidden;
& > img[ng-src] {
min-height: 16em;
display: block;
- max-width: 100%;
height: 256px;
}
vn-float-button {
- position: absolute;
- margin: 1em;
- bottom: 0;
+ position: absolute;
+ margin: 1em;
+ bottom: 0;
right: 0
}
}
-
+
& > vn-spinner {
display: block;
height: 40px;
@@ -39,7 +41,7 @@ vn-descriptor-content {
align-items: stretch;
color: $color-font-dark;
- & > a,
+ & > a,
& > vn-icon-button {
display: flex;
min-width: 45px;
@@ -89,7 +91,7 @@ vn-descriptor-content {
display: flex;
align-items: center;
justify-content: center;
-
+
& > vn-icon {
padding: $spacing-xs $spacing-sm;
font-size: 1.5rem;
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js
index 7452c6636..ef1b370b5 100644
--- a/front/salix/components/log/index.js
+++ b/front/salix/components/log/index.js
@@ -150,10 +150,10 @@ export default class Controller extends Section {
if (value == null || value == '') return null;
switch (prop) {
case 'search':
- const or = [{changedModelId: value}];
- if (!/^[0-9]+$/.test(value))
- or.push({changedModelValue: {like: `%${value}%`}});
- return {or};
+ if (/^[0-9]+$/.test(value))
+ return {changedModelId: value};
+ else
+ return {changedModelValue: {like: `%${value}%`}};
case 'changes':
return {or: [
{oldInstance: {like: `%${value}%`}},
diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js
index f469e893a..37328247b 100644
--- a/loopback/common/models/vn-model.js
+++ b/loopback/common/models/vn-model.js
@@ -1,6 +1,8 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const UserError = require('vn-loopback/util/user-error');
+const utils = require('loopback/lib/utils');
+const {util} = require('webpack');
module.exports = function(Self) {
Self.ParameterizedSQL = ParameterizedSQL;
@@ -164,23 +166,21 @@ module.exports = function(Self) {
function rewriteMethod(methodName) {
const realMethod = this[methodName];
- return async(data, options, cb) => {
- if (options instanceof Function) {
- cb = options;
- options = null;
- }
+ return function(...args) {
+ let cb;
+ const lastArg = args[args.length - 1];
+ if (lastArg instanceof Function) {
+ cb = lastArg;
+ args.pop();
+ } else
+ cb = utils.createPromiseCallback();
- try {
- const result = await realMethod.call(this, data, options);
-
- if (cb) cb(null, result);
- else return result;
- } catch (err) {
- let myErr = replaceErr(err, replaceErrFunc);
- if (cb) cb(myErr);
- else
- throw myErr;
- }
+ args.push(function(err, res) {
+ if (err) err = replaceErr(err, replaceErrFunc);
+ cb(err, res);
+ });
+ realMethod.apply(this, args);
+ return cb.promise;
};
}
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index e950b981b..14ffffeb5 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -171,5 +171,7 @@
"Added observation": "Added observation",
"Comment added to client": "Comment added to client",
"This ticket is already a refund": "This ticket is already a refund",
- "A claim with that sale already exists": "A claim with that sale already exists"
+ "A claim with that sale already exists": "A claim with that sale already exists",
+ "Can't transfer claimed sales": "Can't transfer claimed sales",
+ "Invalid quantity": "Invalid quantity"
}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 45993bdd5..d88a4ebc9 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -84,6 +84,7 @@
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
+ "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)",
"Please select at least one sale": "Por favor selecciona al menos una linea",
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
@@ -290,5 +291,7 @@
"isTaxDataChecked": "Datos comprobados",
"comercialId": "Id comercial",
"comercialName": "Comercial",
- "Invalid NIF for VIES": "Invalid NIF for VIES"
-}
\ No newline at end of file
+ "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"
+}
diff --git a/modules/account/back/locale/vn-user/en.yml b/modules/account/back/locale/vn-user/en.yml
index 135cf75b4..51de7c40d 100644
--- a/modules/account/back/locale/vn-user/en.yml
+++ b/modules/account/back/locale/vn-user/en.yml
@@ -15,3 +15,7 @@ columns:
image: image
hasGrant: has grant
userFk: user
+ recoverPass: recover password
+ role: role
+ sync: pending sync
+ lastPassChange: password changed
diff --git a/modules/account/back/locale/vn-user/es.yml b/modules/account/back/locale/vn-user/es.yml
index 53086ae2d..85e8bc0dc 100644
--- a/modules/account/back/locale/vn-user/es.yml
+++ b/modules/account/back/locale/vn-user/es.yml
@@ -15,3 +15,7 @@ columns:
image: imagen
hasGrant: puede delegar
userFk: usuario
+ recoverPass: recuperar contraseña
+ role: rol
+ sync: Pendiente de sincronizar
+ lastPassChange: contraseña modificada
diff --git a/modules/claim/back/methods/claim/createFromSales.js b/modules/claim/back/methods/claim/createFromSales.js
index 10d0b9b28..07bdb30aa 100644
--- a/modules/claim/back/methods/claim/createFromSales.js
+++ b/modules/claim/back/methods/claim/createFromSales.js
@@ -59,12 +59,14 @@ module.exports = Self => {
const landedPlusWeek = new Date(ticket.landed);
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
- const hasClaimManagerRole = await models.VnUser.hasRole(userId, 'claimManager', myOptions);
const isClaimable = landedPlusWeek >= Date.vnNew();
+ const canCreateClaimAfterDeadline =
+ await models.ACL.checkAccessAcl(ctx, 'Claim', 'createAfterDeadline', 'WRITE');
+
if (ticket.isDeleted)
throw new UserError(`You can't create a claim for a removed ticket`);
- if (!isClaimable && !hasClaimManagerRole)
+ if (!isClaimable && !canCreateClaimAfterDeadline)
throw new UserError(`You can't create a claim from a ticket delivered more than seven days ago`);
const newClaim = await Self.create({
diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js
index f10c68b21..cc7392e39 100644
--- a/modules/claim/back/methods/claim/updateClaim.js
+++ b/modules/claim/back/methods/claim/updateClaim.js
@@ -46,7 +46,6 @@ module.exports = Self => {
Self.updateClaim = async(ctx, id, options) => {
const models = Self.app.models;
- const userId = ctx.req.accessToken.userId;
const args = ctx.args;
let tx;
const myOptions = {};
@@ -81,9 +80,9 @@ module.exports = Self => {
if (args.claimStateFk) {
const canEditOldState = await models.ClaimState.isEditable(ctx, claim.claimStateFk, myOptions);
const canEditNewState = await models.ClaimState.isEditable(ctx, args.claimStateFk, myOptions);
- const isClaimManager = await models.VnUser.hasRole(userId, 'claimManager', myOptions);
+ const canEditState = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editState', 'WRITE');
- if (!canEditOldState || !canEditNewState || changedHasToPickUp && !isClaimManager)
+ if (!canEditOldState || !canEditNewState || changedHasToPickUp && !canEditState)
throw new UserError(`You don't have enough privileges to change that field`);
}
diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js
index 414cbe058..48840b036 100644
--- a/modules/client/back/methods/client/getCard.js
+++ b/modules/client/back/methods/client/getCard.js
@@ -59,6 +59,12 @@ module.exports = function(Self) {
fields: ['id', 'name']
}
},
+ {
+ relation: 'businessType',
+ scope: {
+ fields: ['description']
+ }
+ },
{
relation: 'account',
scope: {
diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js
index e521870fd..7342b28f1 100644
--- a/modules/client/back/methods/client/updateAddress.js
+++ b/modules/client/back/methods/client/updateAddress.js
@@ -87,15 +87,15 @@ module.exports = function(Self) {
Self.updateAddress = async(ctx, clientId, addressId, options) => {
const models = Self.app.models;
const args = ctx.args;
- const userId = ctx.req.accessToken.userId;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
- const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions);
+ const canEditAddressLogifloraAllowed =
+ await models.ACL.checkAccessAcl(ctx, 'Client', 'editAddressLogifloraAllowed');
- if (args.isLogifloraAllowed && !isSalesAssistant)
+ if (args.isLogifloraAllowed && !canEditAddressLogifloraAllowed)
throw new UserError(`You don't have enough privileges`);
const address = await models.Address.findOne({
diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js
index c63dc3991..697c567a3 100644
--- a/modules/client/back/methods/client/updateFiscalData.js
+++ b/modules/client/back/methods/client/updateFiscalData.js
@@ -131,9 +131,10 @@ module.exports = Self => {
myOptions.transaction = tx;
}
try {
- const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions);
+ const canEditNotTaxDataChecked =
+ await models.ACL.checkAccessAcl(ctx, 'Client', 'editFiscalDataWithoutTaxDataCheck', 'WRITE');
const client = await models.Client.findById(clientId, null, myOptions);
- if (!isSalesAssistant && client.isTaxDataChecked)
+ if (!canEditNotTaxDataChecked && client.isTaxDataChecked)
throw new UserError(`Not enough privileges to edit a client with verified data`);
// Sage data validation
const taxDataChecked = args.isTaxDataChecked;
diff --git a/modules/client/back/methods/client/updateUser.js b/modules/client/back/methods/client/updateUser.js
index 479b4da47..55f1accdd 100644
--- a/modules/client/back/methods/client/updateUser.js
+++ b/modules/client/back/methods/client/updateUser.js
@@ -2,6 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateUser', {
description: 'Updates the user information',
+ accessType: 'WRITE',
accepts: [
{
arg: 'id',
@@ -32,7 +33,6 @@ module.exports = Self => {
Self.updateUser = async function(ctx, id, options) {
const models = Self.app.models;
- const userId = ctx.req.accessToken.userId;
let tx;
const myOptions = {};
@@ -45,9 +45,8 @@ module.exports = Self => {
}
try {
- const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions);
-
- if (!isSalesPerson)
+ const canEdit = await models.ACL.checkAccessAcl(ctx, 'Client', 'updateUser', 'WRITE');
+ if (!canEdit)
throw new UserError(`Not enough privileges to edit a client`);
const isClient = await models.Client.findById(id, null, myOptions);
diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js
index 56adc8b03..7b577fa98 100644
--- a/modules/client/back/models/client.js
+++ b/modules/client/back/models/client.js
@@ -218,9 +218,9 @@ module.exports = Self => {
const models = Self.app.models;
const loopBackContext = LoopBackContext.getCurrentContext();
- const userId = loopBackContext.active.accessToken.userId;
+ const accessToken = {req: loopBackContext.active.accessToken};
- const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', ctx.options);
+ const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(accessToken, 'Client', 'editVerifiedDataWithoutTaxDataCheck', 'WRITE');
const hasChanges = orgData && changes;
const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked);
@@ -232,8 +232,8 @@ module.exports = Self => {
const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk);
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
- const cantEditVerifiedData = isTaxDataCheckedChanged && !isSalesAssistant;
- const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant;
+ const cantEditVerifiedData = isTaxDataCheckedChanged && !editVerifiedDataWithoutTaxDataChecked;
+ const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !editVerifiedDataWithoutTaxDataChecked;
if (cantEditVerifiedData || cantChangeSageData)
throw new UserError(`You don't have enough privileges`);
@@ -401,9 +401,10 @@ module.exports = Self => {
Self.changeCredit = async function changeCredit(ctx, finalState, changes) {
const models = Self.app.models;
const userId = ctx.options.accessToken.userId;
+ const accessToken = {req: {accessToken: ctx.options.accessToken} };
- const isFinancialBoss = await models.VnUser.hasRole(userId, 'financialBoss', ctx.options);
- if (!isFinancialBoss) {
+ const canEditCredit = await models.ACL.checkAccessAcl(accessToken, 'Client', 'editCredit', 'WRITE');
+ if (!canEditCredit) {
const lastCredit = await models.ClientCredit.findOne({
where: {
clientFk: finalState.id
@@ -412,10 +413,9 @@ module.exports = Self => {
}, ctx.options);
const lastAmount = lastCredit && lastCredit.amount;
- const lastWorkerId = lastCredit && lastCredit.workerFk;
- const lastWorkerIsFinancialBoss = await models.VnUser.hasRole(lastWorkerId, 'financialBoss', ctx.options);
+ const lastCreditIsNotEditable = !await models.ACL.checkAccessAcl(accessToken, 'Client', 'isNotEditableCredit', 'WRITE');
- if (lastAmount == 0 && lastWorkerIsFinancialBoss)
+ if (lastAmount == 0 && lastCreditIsNotEditable)
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
const creditLimits = await models.ClientCreditLimit.find({
diff --git a/modules/client/back/models/pay-method.json b/modules/client/back/models/pay-method.json
index c83c21e2f..6eeb2b0ee 100644
--- a/modules/client/back/models/pay-method.json
+++ b/modules/client/back/models/pay-method.json
@@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
- "table": "payMethod"
+ "table": "payMethod"
}
},
"properties": {
diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html
index 5aaecbdb0..f2dbd64b6 100644
--- a/modules/client/front/descriptor/index.html
+++ b/modules/client/front/descriptor/index.html
@@ -43,6 +43,10 @@
{{$ctrl.client.salesPersonUser.name}}
+