diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e807a7b..92c4ee3aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,13 +24,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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' ### 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 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/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/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 index 91f477bec..8896f636d 100644 --- a/db/changes/232201/00-workerConfigPayMethod.sql +++ b/db/changes/232201/00-workerConfigPayMethod.sql @@ -1,7 +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; --- Cuando se apruebe el PR quitar y poner en redmine para hacerse manualmente + UPDATE `vn`.`workerConfig` SET payMethodFk = 4 WHERE id=1; diff --git a/db/dump/structure.sql b/db/dump/structure.sql index cbb1e39c8..3ce7f7bb5 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -61950,7 +61950,6 @@ BEGIN * @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; 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/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/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/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/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}} + +
{ }, myOptions); } else { const weekDay = day.dated.getDay(); - const journeys = await models.Journey.find({ + const journeys = await models.BusinessSchedule.find({ where: { - business_id: day.businessFk, - day_id: weekDay + businessFk: day.businessFk, + weekday: weekDay } }, myOptions); let timeTableDecimalInSeconds = 0; for (let journey of journeys) { const start = Date.vnNew(); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); start.setHours(startHours, startMinutes, startSeconds, 0); const end = Date.vnNew(); - const [endHours, endMinutes, endSeconds] = getTime(journey.end); + const [endHours, endMinutes, endSeconds] = getTime(journey.ended); end.setHours(endHours, endMinutes, endSeconds, 0); const result = (end - start) / 1000; @@ -255,7 +255,7 @@ module.exports = Self => { const timeTableDecimal = timeTableDecimalInSeconds / 3600; if (day.timeWorkDecimal == timeTableDecimal) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours, startMinutes, startSeconds), @@ -263,7 +263,7 @@ module.exports = Self => { isSendMail: true }, myOptions); - const [endHours, endMinutes, endSeconds] = getTime(journey.end); + const [endHours, endMinutes, endSeconds] = getTime(journey.ended); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(endHours, endMinutes, endSeconds), @@ -276,7 +276,7 @@ module.exports = Self => { }); if (journey == minStart) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours, startMinutes, startSeconds), @@ -304,7 +304,7 @@ module.exports = Self => { }); if (journey == minStart) { const timed = new Date(day.dated); - const [startHours, startMinutes, startSeconds] = getTime(journey.start); + const [startHours, startMinutes, startSeconds] = getTime(journey.started); await models.WorkerTimeControl.create({ userFk: day.workerFk, timed: timed.setHours(startHours + 1, startMinutes, startSeconds), diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index fd34c013b..60ec273a5 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -2,6 +2,9 @@ "AbsenceType": { "dataSource": "vn" }, + "BusinessSchedule": { + "dataSource": "vn" + }, "Calendar": { "dataSource": "vn" }, @@ -38,9 +41,6 @@ "EducationLevel": { "dataSource": "vn" }, - "Journey": { - "dataSource": "vn" - }, "ProfileType":{ "dataSource": "vn" }, diff --git a/modules/worker/back/models/journey.json b/modules/worker/back/models/business-schedule.json similarity index 65% rename from modules/worker/back/models/journey.json rename to modules/worker/back/models/business-schedule.json index b7d5f2817..0cc17c844 100644 --- a/modules/worker/back/models/journey.json +++ b/modules/worker/back/models/business-schedule.json @@ -1,26 +1,26 @@ { - "name": "Journey", + "name": "BusinessSchedule", "base": "VnModel", "options": { "mysql": { - "table": "postgresql.journey" + "table": "businessSchedule" } }, "properties": { - "journey_id": { + "id": { "id": true, "type": "number" }, - "day_id": { + "weekday": { "type": "number" }, - "start": { + "started": { "type": "date" }, - "end": { + "ended": { "type": "date" }, - "business_id": { + "businessFk": { "type": "number" } } diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 25a0ffbcf..61093a456 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -72,7 +72,7 @@ "state": "worker.card.workerLog", "component": "vn-worker-log", "description": "Log", - "acl": ["salesAssistant"] + "acl": ["hr"] }, { "url": "/note", "state": "worker.card.note",